cvx-kit 0.1.35 → 2.0.0-beta.0

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.
Files changed (327) hide show
  1. package/README.md +92 -49
  2. package/dist/agent-tools.d.mts +21 -25
  3. package/dist/agent-tools.mjs +1 -1
  4. package/dist/agent-tools.mjs.map +1 -1
  5. package/dist/auth.d.mts +20 -14
  6. package/dist/auth.mjs +1 -1
  7. package/dist/auth.mjs.map +1 -1
  8. package/dist/components/approvals/_generated/api.d.mts +4 -5
  9. package/dist/components/approvals/_generated/api.mjs.map +1 -1
  10. package/dist/components/approvals/_generated/component.d.mts +0 -2
  11. package/dist/components/approvals/_generated/dataModel.d.mts +1 -3
  12. package/dist/components/approvals/_generated/server.d.mts +0 -2
  13. package/dist/components/approvals/_generated/server.mjs.map +1 -1
  14. package/dist/components/approvals/audit.d.mts +0 -1
  15. package/dist/components/approvals/audit.mjs +1 -1
  16. package/dist/components/approvals/audit.mjs.map +1 -1
  17. package/dist/components/approvals/client.d.mts +0 -1
  18. package/dist/components/approvals/client.mjs +1 -1
  19. package/dist/components/approvals/client.mjs.map +1 -1
  20. package/dist/components/approvals/constants.d.mts +0 -1
  21. package/dist/components/approvals/constants.mjs.map +1 -1
  22. package/dist/components/approvals/convex.config.d.mts +0 -2
  23. package/dist/components/approvals/convex.config.mjs.map +1 -1
  24. package/dist/components/approvals/decisions.d.mts +1 -4
  25. package/dist/components/approvals/decisions.mjs +1 -1
  26. package/dist/components/approvals/decisions.mjs.map +1 -1
  27. package/dist/components/approvals/functions.d.mts +0 -1
  28. package/dist/components/approvals/functions.mjs.map +1 -1
  29. package/dist/components/approvals/health.d.mts +0 -1
  30. package/dist/components/approvals/health.mjs.map +1 -1
  31. package/dist/components/approvals/requests.d.mts +106 -123
  32. package/dist/components/approvals/requests.mjs +1 -1
  33. package/dist/components/approvals/requests.mjs.map +1 -1
  34. package/dist/components/approvals/schema.d.ts +106 -315
  35. package/dist/components/approvals/schema.js +1 -1
  36. package/dist/components/approvals/validators.d.mts +321 -393
  37. package/dist/components/approvals/validators.mjs +1 -1
  38. package/dist/components/approvals/validators.mjs.map +1 -1
  39. package/dist/components/approvals/workflow.d.mts +0 -1
  40. package/dist/components/approvals/workflow.mjs +1 -1
  41. package/dist/components/approvals/workflow.mjs.map +1 -1
  42. package/dist/components/approvals/workflow_steps.d.mts +1 -2
  43. package/dist/components/approvals/workflow_steps.mjs.map +1 -1
  44. package/dist/components/foundation/_generated/api.d.mts +3 -4
  45. package/dist/components/foundation/_generated/api.mjs.map +1 -1
  46. package/dist/components/foundation/_generated/component.d.mts +0 -2
  47. package/dist/components/foundation/_generated/dataModel.d.mts +1 -3
  48. package/dist/components/foundation/_generated/server.d.mts +0 -2
  49. package/dist/components/foundation/_generated/server.mjs.map +1 -1
  50. package/dist/components/foundation/client.d.mts +0 -1
  51. package/dist/components/foundation/client.mjs +1 -1
  52. package/dist/components/foundation/client.mjs.map +1 -1
  53. package/dist/components/foundation/convex.config.d.mts +0 -2
  54. package/dist/components/foundation/convex.config.mjs.map +1 -1
  55. package/dist/components/foundation/functions.d.mts +0 -1
  56. package/dist/components/foundation/functions.mjs.map +1 -1
  57. package/dist/components/foundation/modules/command/command.d.mts +0 -1
  58. package/dist/components/foundation/modules/command/command.mjs.map +1 -1
  59. package/dist/components/foundation/modules/command/lifecycle.d.mts +0 -2
  60. package/dist/components/foundation/modules/command/lifecycle.mjs.map +1 -1
  61. package/dist/components/foundation/modules/observability/observability.d.mts +0 -1
  62. package/dist/components/foundation/modules/observability/observability.mjs.map +1 -1
  63. package/dist/components/foundation/modules/query/query.d.mts +0 -1
  64. package/dist/components/foundation/modules/query/query.mjs.map +1 -1
  65. package/dist/components/foundation/operation.d.mts +2 -3
  66. package/dist/components/foundation/operation.mjs.map +1 -1
  67. package/dist/components/foundation/result.d.mts +0 -1
  68. package/dist/components/foundation/result.mjs.map +1 -1
  69. package/dist/components/foundation/schema.d.ts +0 -2
  70. package/dist/components/foundation/telemetry.d.mts +0 -1
  71. package/dist/components/foundation/telemetry.mjs +1 -1
  72. package/dist/components/foundation/telemetry.mjs.map +1 -1
  73. package/dist/contracts.d.mts +2 -2
  74. package/dist/contracts.mjs +1 -1
  75. package/dist/crud.d.mts +93 -97
  76. package/dist/crud.mjs +1 -1
  77. package/dist/crud.mjs.map +1 -1
  78. package/dist/effect.d.mts +2 -3
  79. package/dist/effect.mjs +1 -1
  80. package/dist/errors.d.mts +2 -4
  81. package/dist/errors.mjs +1 -1
  82. package/dist/errors.mjs.map +1 -1
  83. package/dist/filters.d.mts +1 -1
  84. package/dist/filters.mjs +1 -1
  85. package/dist/idempotency.mjs +1 -1
  86. package/dist/index.d.mts +10 -7
  87. package/dist/index.mjs +1 -1
  88. package/dist/json-schema.d.mts +40 -0
  89. package/dist/json-schema.mjs +2 -0
  90. package/dist/json-schema.mjs.map +1 -0
  91. package/dist/k/compile.d.mts +17 -0
  92. package/dist/k/compile.mjs +2 -0
  93. package/dist/k/compile.mjs.map +1 -0
  94. package/dist/k/dates.d.mts +23 -0
  95. package/dist/k/dates.mjs +2 -0
  96. package/dist/k/dates.mjs.map +1 -0
  97. package/dist/k/formats.d.mts +24 -0
  98. package/dist/k/formats.mjs +2 -0
  99. package/dist/k/formats.mjs.map +1 -0
  100. package/dist/k/index.d.mts +32 -0
  101. package/dist/k/index.mjs +2 -0
  102. package/dist/k/index.mjs.map +1 -0
  103. package/dist/k/issues.d.mts +31 -0
  104. package/dist/k/issues.mjs +2 -0
  105. package/dist/k/issues.mjs.map +1 -0
  106. package/dist/k/kinds.d.mts +81 -0
  107. package/dist/k/kinds.mjs +2 -0
  108. package/dist/k/kinds.mjs.map +1 -0
  109. package/dist/k/object.d.mts +43 -0
  110. package/dist/k/object.mjs +2 -0
  111. package/dist/k/object.mjs.map +1 -0
  112. package/dist/k/parse.d.mts +29 -0
  113. package/dist/k/parse.mjs +2 -0
  114. package/dist/k/parse.mjs.map +1 -0
  115. package/dist/k/schema.d.mts +100 -0
  116. package/dist/k/schema.mjs +2 -0
  117. package/dist/k/schema.mjs.map +1 -0
  118. package/dist/k/standard.d.mts +8 -0
  119. package/dist/k/standard.mjs +2 -0
  120. package/dist/k/standard.mjs.map +1 -0
  121. package/dist/k/types.d.mts +64 -0
  122. package/dist/k/types.mjs +1 -0
  123. package/dist/k.d.mts +8 -0
  124. package/dist/k.mjs +1 -0
  125. package/dist/middleware.d.mts +0 -2
  126. package/dist/middleware.mjs +1 -1
  127. package/dist/middleware.mjs.map +1 -1
  128. package/dist/modules/contracts/binding.d.mts +1 -2
  129. package/dist/modules/contracts/binding.mjs.map +1 -1
  130. package/dist/modules/contracts/contract.d.mts +0 -2
  131. package/dist/modules/contracts/contract.mjs.map +1 -1
  132. package/dist/modules/contracts/convex.d.mts +1 -3
  133. package/dist/modules/contracts/convex.mjs.map +1 -1
  134. package/dist/modules/contracts/domain.d.mts +1 -2
  135. package/dist/modules/contracts/domain.mjs.map +1 -1
  136. package/dist/modules/contracts/errors.d.mts +161 -2
  137. package/dist/modules/contracts/errors.mjs +1 -1
  138. package/dist/modules/contracts/errors.mjs.map +1 -1
  139. package/dist/modules/contracts/exposure.d.mts +1 -2
  140. package/dist/modules/contracts/exposure.mjs.map +1 -1
  141. package/dist/modules/contracts/idempotency.d.mts +1 -2
  142. package/dist/modules/contracts/idempotency.mjs +1 -1
  143. package/dist/modules/contracts/idempotency.mjs.map +1 -1
  144. package/dist/modules/contracts/lazy.d.mts +0 -2
  145. package/dist/modules/contracts/lazy.mjs.map +1 -1
  146. package/dist/modules/contracts/standard.d.mts +7 -5
  147. package/dist/modules/contracts/standard.mjs +1 -1
  148. package/dist/modules/contracts/standard.mjs.map +1 -1
  149. package/dist/modules/contracts/workflow.d.mts +1 -2
  150. package/dist/modules/contracts/workflow.mjs.map +1 -1
  151. package/dist/modules/effect/action.d.mts +6 -7
  152. package/dist/modules/effect/action.mjs +1 -1
  153. package/dist/modules/effect/action.mjs.map +1 -1
  154. package/dist/modules/effect/agent-tools.mjs +1 -1
  155. package/dist/modules/effect/api-runtime.d.mts +1 -2
  156. package/dist/modules/effect/api-runtime.mjs +1 -1
  157. package/dist/modules/effect/api-runtime.mjs.map +1 -1
  158. package/dist/modules/effect/api.d.mts +41 -15
  159. package/dist/modules/effect/api.mjs +1 -1
  160. package/dist/modules/effect/api.mjs.map +1 -1
  161. package/dist/modules/effect/auth.d.mts +5 -6
  162. package/dist/modules/effect/auth.mjs +1 -1
  163. package/dist/modules/effect/auth.mjs.map +1 -1
  164. package/dist/modules/effect/client.d.mts +7 -8
  165. package/dist/modules/effect/client.mjs +1 -1
  166. package/dist/modules/effect/command.d.mts +7 -5
  167. package/dist/modules/effect/command.mjs +1 -1
  168. package/dist/modules/effect/command.mjs.map +1 -1
  169. package/dist/modules/effect/crud.d.mts +272 -206
  170. package/dist/modules/effect/crud.mjs +1 -1
  171. package/dist/modules/effect/crud.mjs.map +1 -1
  172. package/dist/modules/effect/domain.d.mts +5 -6
  173. package/dist/modules/effect/domain.mjs.map +1 -1
  174. package/dist/modules/effect/errors.d.mts +4 -2
  175. package/dist/modules/effect/errors.mjs +1 -1
  176. package/dist/modules/effect/errors.mjs.map +1 -1
  177. package/dist/modules/effect/failure-audit.d.mts +2 -2
  178. package/dist/modules/effect/failure-audit.mjs +1 -1
  179. package/dist/modules/effect/failure-audit.mjs.map +1 -1
  180. package/dist/modules/effect/failures.d.mts +1 -2
  181. package/dist/modules/effect/failures.mjs.map +1 -1
  182. package/dist/modules/effect/foundation.d.mts +0 -2
  183. package/dist/modules/effect/foundation.mjs.map +1 -1
  184. package/dist/modules/effect/idempotency.d.mts +2 -3
  185. package/dist/modules/effect/idempotency.mjs +1 -1
  186. package/dist/modules/effect/idempotency.mjs.map +1 -1
  187. package/dist/modules/effect/input.d.mts +10 -0
  188. package/dist/modules/effect/input.mjs +2 -0
  189. package/dist/modules/effect/input.mjs.map +1 -0
  190. package/dist/modules/effect/normalize.d.mts +0 -2
  191. package/dist/modules/effect/normalize.mjs.map +1 -1
  192. package/dist/modules/effect/operation.d.mts +2 -3
  193. package/dist/modules/effect/operation.mjs.map +1 -1
  194. package/dist/modules/effect/query.d.mts +6 -4
  195. package/dist/modules/effect/query.mjs +1 -1
  196. package/dist/modules/effect/query.mjs.map +1 -1
  197. package/dist/modules/effect/schema.d.mts +0 -2
  198. package/dist/modules/effect/schema.mjs.map +1 -1
  199. package/dist/modules/effect/scope.d.mts +0 -2
  200. package/dist/modules/effect/scope.mjs.map +1 -1
  201. package/dist/modules/effect/workflow.d.mts +4 -5
  202. package/dist/modules/effect/workflow.mjs +1 -1
  203. package/dist/modules/effect/workflow.mjs.map +1 -1
  204. package/dist/modules/foundation/foundation.d.mts +4 -5
  205. package/dist/modules/foundation/foundation.mjs +1 -1
  206. package/dist/modules/foundation/foundation.mjs.map +1 -1
  207. package/dist/modules/foundation/operation.d.mts +2 -3
  208. package/dist/modules/foundation/operation.mjs.map +1 -1
  209. package/dist/namespace.d.mts +104 -0
  210. package/dist/namespace.mjs +2 -0
  211. package/dist/namespace.mjs.map +1 -0
  212. package/dist/oxlint/architecture.d.mts +0 -2
  213. package/dist/oxlint/architecture.mjs +1 -1
  214. package/dist/oxlint/architecture.mjs.map +1 -1
  215. package/dist/oxlint/ast.d.mts +16 -8
  216. package/dist/oxlint/ast.mjs +1 -1
  217. package/dist/oxlint/ast.mjs.map +1 -1
  218. package/dist/oxlint/components.d.mts +0 -2
  219. package/dist/oxlint/components.mjs.map +1 -1
  220. package/dist/oxlint/ownership.d.mts +0 -2
  221. package/dist/oxlint/ownership.mjs +1 -1
  222. package/dist/oxlint/ownership.mjs.map +1 -1
  223. package/dist/oxlint/reserved-files.d.mts +0 -2
  224. package/dist/oxlint/reserved-files.mjs +1 -1
  225. package/dist/oxlint/reserved-files.mjs.map +1 -1
  226. package/dist/oxlint.d.mts +0 -2
  227. package/dist/oxlint.mjs +1 -1
  228. package/dist/oxlint.mjs.map +1 -1
  229. package/dist/querying/cursors.d.mts +27 -9
  230. package/dist/querying/cursors.mjs +1 -1
  231. package/dist/querying/cursors.mjs.map +1 -1
  232. package/dist/querying/execution.d.mts +6 -7
  233. package/dist/querying/execution.mjs +1 -1
  234. package/dist/querying/execution.mjs.map +1 -1
  235. package/dist/querying/failures.d.mts +0 -2
  236. package/dist/querying/failures.mjs +1 -1
  237. package/dist/querying/failures.mjs.map +1 -1
  238. package/dist/querying/filter-boundary.d.mts +18 -9
  239. package/dist/querying/filter-boundary.mjs +1 -1
  240. package/dist/querying/filter-boundary.mjs.map +1 -1
  241. package/dist/querying/filters.d.mts +71 -35
  242. package/dist/querying/filters.mjs +1 -1
  243. package/dist/querying/filters.mjs.map +1 -1
  244. package/dist/querying/planner.d.mts +16 -20
  245. package/dist/querying/planner.mjs +1 -1
  246. package/dist/querying/planner.mjs.map +1 -1
  247. package/dist/querying/relationships.d.mts +6 -6
  248. package/dist/querying/relationships.mjs +1 -1
  249. package/dist/querying/relationships.mjs.map +1 -1
  250. package/dist/querying/search.d.mts +12 -12
  251. package/dist/querying/search.mjs +1 -1
  252. package/dist/querying/search.mjs.map +1 -1
  253. package/dist/querying/security.d.mts +2 -3
  254. package/dist/querying/security.mjs.map +1 -1
  255. package/dist/querying/shared/ast.d.mts +0 -2
  256. package/dist/querying/shared/ast.mjs.map +1 -1
  257. package/dist/querying/shared/contract.d.mts +17 -23
  258. package/dist/querying/shared/contract.mjs +1 -1
  259. package/dist/querying/shared/contract.mjs.map +1 -1
  260. package/dist/querying/shared/evaluate.d.mts +0 -2
  261. package/dist/querying/shared/evaluate.mjs.map +1 -1
  262. package/dist/querying/shared/filters.d.mts +47 -29
  263. package/dist/querying/shared/filters.mjs +1 -1
  264. package/dist/querying/shared/filters.mjs.map +1 -1
  265. package/dist/querying/shared/native-json.d.mts +7 -0
  266. package/dist/querying/shared/native-json.mjs +2 -0
  267. package/dist/querying/shared/native-json.mjs.map +1 -0
  268. package/dist/querying/shared/page.d.mts +19 -22
  269. package/dist/querying/shared/page.mjs +1 -1
  270. package/dist/querying/shared/page.mjs.map +1 -1
  271. package/dist/querying.d.mts +6 -9
  272. package/dist/querying.mjs +1 -1
  273. package/dist/querying.mjs.map +1 -1
  274. package/dist/react/failures.d.mts +0 -2
  275. package/dist/react/failures.mjs.map +1 -1
  276. package/dist/react/optimistic.d.mts +2 -3
  277. package/dist/react/optimistic.mjs.map +1 -1
  278. package/dist/react/pagination-state.d.mts +1 -2
  279. package/dist/react/pagination-state.mjs.map +1 -1
  280. package/dist/react/use-command.d.mts +0 -2
  281. package/dist/react/use-command.mjs.map +1 -1
  282. package/dist/react/use-paginated-list.d.mts +1 -3
  283. package/dist/react/use-paginated-list.mjs +1 -1
  284. package/dist/react/use-paginated-list.mjs.map +1 -1
  285. package/dist/react.d.mts +1 -1
  286. package/dist/react.mjs +1 -1
  287. package/dist/registration.d.mts +65 -0
  288. package/dist/registration.mjs +2 -0
  289. package/dist/registration.mjs.map +1 -0
  290. package/dist/relations-public.d.mts +2 -2
  291. package/dist/relations-public.mjs +1 -1
  292. package/dist/relations.d.mts +55 -46
  293. package/dist/relations.mjs +1 -1
  294. package/dist/relations.mjs.map +1 -1
  295. package/dist/state-machine.d.mts +0 -2
  296. package/dist/state-machine.mjs.map +1 -1
  297. package/dist/table.d.mts +222 -0
  298. package/dist/table.mjs +2 -0
  299. package/dist/table.mjs.map +1 -0
  300. package/dist/tenancy.d.mts +0 -2
  301. package/dist/tenancy.mjs.map +1 -1
  302. package/dist/triggers.d.mts +2 -4
  303. package/dist/triggers.mjs +1 -1
  304. package/dist/triggers.mjs.map +1 -1
  305. package/dist/webhooks.d.mts +9 -9
  306. package/dist/webhooks.mjs +1 -1
  307. package/dist/webhooks.mjs.map +1 -1
  308. package/dist/workflow.mjs +1 -1
  309. package/dist/zod.d.mts +30 -0
  310. package/dist/zod.mjs +2 -0
  311. package/dist/zod.mjs.map +1 -0
  312. package/package.json +51 -29
  313. package/dist/modules/effect/api-zod.d.mts +0 -34
  314. package/dist/modules/effect/api-zod.mjs +0 -2
  315. package/dist/modules/effect/api-zod.mjs.map +0 -1
  316. package/dist/querying/schema-snapshot.d.mts +0 -49
  317. package/dist/querying/schema-snapshot.mjs +0 -2
  318. package/dist/querying/schema-snapshot.mjs.map +0 -1
  319. package/dist/zod-convex.d.mts +0 -10
  320. package/dist/zod-convex.mjs +0 -2
  321. package/dist/zod-convex.mjs.map +0 -1
  322. package/dist/zod-registration.d.mts +0 -15
  323. package/dist/zod-registration.mjs +0 -2
  324. package/dist/zod-registration.mjs.map +0 -1
  325. package/dist/zod-table.d.mts +0 -351
  326. package/dist/zod-table.mjs +0 -2
  327. package/dist/zod-table.mjs.map +0 -1
@@ -1,12 +1,21 @@
1
- import { z } from "zod";
1
+ import { KDefault } from "../k/schema.mjs";
2
+ import { KArray, KRecord, KString } from "../k/kinds.mjs";
3
+ import { KObject } from "../k/object.mjs";
4
+ import "../k.mjs";
2
5
  import { Context, ESTree, RuleMeta, Visitor } from "@oxlint/plugins";
3
- //#region src/oxlint/ast.d.ts
4
- export declare const consumerOptions: z.ZodObject<{
5
- convexDir: z.ZodDefault<z.ZodString>;
6
- componentDirs: z.ZodDefault<z.ZodArray<z.ZodString>>;
7
- domainPublicFiles: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
8
- }, z.core.$strip>;
6
+ /** Options every consumer-facing rule accepts; unknown keys are ignored. */
7
+ export declare const consumerOptions: KObject<{
8
+ convexDir: KDefault<KString>;
9
+ componentDirs: KDefault<KArray<KString>>;
10
+ domainPublicFiles: KDefault<KRecord<KString, KArray<KString>>>;
11
+ }>;
9
12
  export declare function appFile(context: Context, filename?: string): string | null;
13
+ /** Entries that export the `k` validator namespace. */
14
+ export declare const K_SOURCES: readonly string[];
15
+ /** Entries that export the table builders (`kTable`, `kVariantTable`, `tenantTable`, `createModule`). */
16
+ export declare const TABLE_SOURCES: readonly string[];
17
+ /** Factory name when `node` is a `k.<factory>(...)` call whose `k` comes from a kit entry. */
18
+ export declare function kFactory(context: Context, node: ESTree.CallExpression): string | null;
10
19
  export declare function imported(context: Context, node: ESTree.Node, active?: Set<ESTree.Node>): {
11
20
  source: string;
12
21
  name: string;
@@ -39,5 +48,4 @@ export declare function binding(context: Context, node: ESTree.Node): import("@o
39
48
  export declare function exportedNames(program: ESTree.Program): Set<string>;
40
49
  export declare function exportName(node: ESTree.Node): string | null;
41
50
  export declare function delegatingBody(node: ESTree.Node): boolean;
42
- //#endregion
43
51
  //# sourceMappingURL=ast.d.mts.map
@@ -1,2 +1,2 @@
1
- import{conventionalComponentRoot as e,findComponentRoot as t}from"./components.mjs";import{createResolver as n,resolveImport as r}from"./architecture.mjs";import{z as i}from"zod";import{dirname as a,relative as o,resolve as s,sep as c}from"node:path";import{existsSync as l,readFileSync as u,realpathSync as d}from"node:fs";import{parseSync as f}from"oxc-parser";const p=i.object({convexDir:i.string().min(1).default(`convex`),componentDirs:i.array(i.string().min(1)).default([]),domainPublicFiles:i.record(i.string(),i.array(i.string().min(1))).default({})});function m(e,t=e.filename){let n=s(e.cwd,p.parse(e.options[0]??{}).convexDir),r=l(n)?d(n):n,i=o(r,l(t)?d(t):t).split(c).join(`/`);return i===`..`||i.startsWith(`../`)||i.startsWith(`/`)?null:i}function h(e,t,n=/* @__PURE__ */ new Set){if(n.has(t)||n.size>32)return null;if(n=new Set(n).add(t),t.type===`TSAsExpression`||t.type===`TSSatisfiesExpression`||t.type===`TSNonNullExpression`)return h(e,t.expression,n);if(t.type===`CallExpression`)return h(e,t.callee,n);if(t.type===`MemberExpression`){let r=h(e,t.object,n),i=I(t);return r&&i&&[`*`,`z`,`v`,`default`].includes(r.name)?{source:r.source,name:i}:null}if(t.type!==`Identifier`)return null;let r=g(e,t);if(r&&r.type!==`CallExpression`&&r.type!==`AwaitExpression`)return h(e,r,n);let i=_(e,t);if(i){let t=h(e,i.expression,n);return t&&[`*`,`z`,`v`,`default`].includes(t.name)?{source:t.source,name:i.name}:null}for(let n of L(e,t)?.defs??[]){if(n.type!==`ImportBinding`||n.parent?.type!==`ImportDeclaration`||n.parent.importKind===`type`)continue;let e=n.node;if(e.type!==`ImportSpecifier`||e.importKind!==`type`)return{source:n.parent.source.value,name:e.type===`ImportSpecifier`?z(e.imported)??``:e.type===`ImportDefaultSpecifier`?`default`:`*`}}return null}function g(e,t){let n=L(e,t);if(!n||n.references.some(e=>e.isWrite()&&!e.init))return null;let r=n.defs.length===1?n.defs[0]:null;return r?.type===`Variable`&&r.parent?.type===`VariableDeclaration`&&r.parent.kind===`const`&&r.node.type===`VariableDeclarator`&&r.node.id.type===`Identifier`?r.node.init:null}function _(e,t){let n=L(e,t);if(!n||n.references.some(e=>e.isWrite()&&!e.init))return null;let r=n.defs.length===1?n.defs[0]:null;if(r?.type!==`Variable`||r.parent?.type!==`VariableDeclaration`||r.parent.kind!==`const`||r.node.type!==`VariableDeclarator`||r.node.id.type!==`ObjectPattern`||!r.node.init)return null;for(let e of r.node.id.properties)if(e.type===`Property`&&e.value.type===`Identifier`&&e.value.name===n.name){let t=e.computed?F(e.key):z(e.key);if(t)return{expression:r.node.init,name:t}}return null}const v=[`query`,`internalQuery`,`mutation`,`internalMutation`],y=/* @__PURE__ */ new WeakMap;function b(e,t){let n=U(e).nodes;if(n.has(t))return n.get(t)??null;n.set(t,null);let r=[{node:t,evaluation:W(e,t)}],i=null;for(;r.length;){let t=r[r.length-1],a=t.evaluation.next(i);a.done?(i=a.value,n.set(t.node,i),r.pop()):n.has(a.value)?i=n.get(a.value)??null:(n.set(a.value,null),r.push({node:a.value,evaluation:W(e,a.value)}),i=null)}return i}function x(e,t){function n(e,n){let r=F(n);r&&t(e,r)}return{ImportDeclaration(e){n(e,e.source)},ExportNamedDeclaration(e){n(e,e.source)},ExportAllDeclaration(e){n(e,e.source)},ImportExpression(e){n(e,e.source)},TSImportType(e){n(e,e.source)},CallExpression(t){t.callee.type===`Identifier`&&t.callee.name===`require`&&!L(e,t.callee)?.defs.length&&n(t,t.arguments[0])}}}function S(e,t){let i=t.startsWith(`.`)?s(a(e.filename),t):r(n(),e.filename,t);if(!i)return!1;let l=P(e,e.filename);return(l?o(l,i).split(c).join(`/`):m(e,i))?.replace(/\.[cm]?[jt]s$/,``)===`functions`}function C(e){return e.type===`TSImportType`||e.type===`ImportDeclaration`&&(e.importKind===`type`||e.specifiers.length>0&&e.specifiers.every(e=>e.type===`ImportSpecifier`&&e.importKind===`type`))||(e.type===`ExportNamedDeclaration`||e.type===`ExportAllDeclaration`)&&e.exportKind===`type`}function w(e){return e.callee.type===`MemberExpression`&&e.callee.object.type===`MemberExpression`&&I(e.callee.object)===`db`}function T(e,t){let n=h(e,t.callee);return n&&/^(?:node:)?(?:https?|net|tls|fs)(?:\/|$)|^(?:undici|axios)(?:\/|$)/.test(n.source)?!0:t.callee.type===`Identifier`&&t.callee.name===`fetch`&&!L(e,t.callee)?.defs.length||t.callee.type===`MemberExpression`&&I(t.callee)===`fetch`&&t.callee.object.type===`Identifier`&&t.callee.object.name===`globalThis`&&!L(e,t.callee.object)?.defs.length}function E(e,t){if(t.type===`MemberExpression`){let n=h(e,t.object);return n?.name===`components`&&/_generated\/api/.test(n.source)?!0:E(e,t.object)}return t.type===`ObjectExpression`&&t.properties.some(t=>t.type===`Property`&&E(e,t.value))}function D(e){return e.type===`MemberExpression`?D(e.object):e}function O(e){return e.type===`Identifier`?[e.name]:e.type===`MemberExpression`?[...O(e.object),I(e)??``]:[]}function k(e){return e.type===`MemberExpression`?I(e)===`table`||k(e.object):e.type===`CallExpression`&&k(e.callee)}function A(e){return e.callee.type===`MemberExpression`&&[`insert`,`patch`,`replace`,`delete`].includes(I(e.callee)??``)&&e.callee.object.type===`MemberExpression`&&I(e.callee.object)===`db`}function j(e,t){return e.type===`CallExpression`?e.callee.type===`MemberExpression`&&I(e.callee)===t&&(t!==`query`||I(e.callee.object)===`db`)||j(e.callee,t):e.type===`MemberExpression`&&j(e.object,t)}function M(e,t){return{type:`problem`,docs:{description:e},schema:[],messages:t}}const N=/* @__PURE__ */ new WeakMap;function P(n,r){let i=N.get(n);if(i||(i=/* @__PURE__ */ new Map,N.set(n,i)),i.has(r))return i.get(r)??null;let a=s(n.cwd,p.parse(n.options[0]??{}).convexDir),o=l(a)?d(a):a,c=l(r)?d(r):s(r),u=p.parse(n.options[0]??{}).componentDirs.map(e=>s(o,e)),f=t(c,u)??e(c,o);return i.set(r,f),f}function F(e){return e?.type===`Literal`&&`value`in e&&String(e.value)===e.value?String(e.value):e?.type===`TemplateLiteral`&&e.expressions.length===0?e.quasis[0].value.cooked:null}function I(e){return e.type===`MemberExpression`?e.computed?F(e.property):e.property.name:null}function L(e,t){if(t.type!==`Identifier`)return null;let n=e.sourceCode.getScope(t);for(;n;){let e=n.set.get(t.name);if(e)return e;n=n.upper}return null}function R(e){let t=/* @__PURE__ */ new Set;for(let n of e.body)if(n.type===`ExportNamedDeclaration`&&!n.source)for(let e of n.specifiers)t.add(z(e.local)??``);else n.type===`ExportDefaultDeclaration`&&n.declaration.type===`Identifier`&&t.add(n.declaration.name);return t}function z(e){return e.type===`Identifier`?e.name:F(e)}function B(e){return e.type===`CallExpression`?!0:e.type===`AwaitExpression`?B(e.argument):e.type===`BlockStatement`&&e.body.length>0&&e.body.every(e=>e.type===`ReturnStatement`&&e.argument!==null&&B(e.argument)||e.type===`ExpressionStatement`&&B(e.expression))}function V(e,t){let n=U(e),i=r(n.resolver,e.filename,t.source),a=i&&m(e,i);if(!i||!a||!/^(?:domain\/.+\/schema\.ts|querying\.ts|foundation\.ts)$/.test(a)&&!(P(e,i)&&/(?:^|\/)(?:schema|table|foundation)\.ts$/.test(a))||!l(i))return null;let o=`${i}:${t.name}`;if(n.imports.has(o))return n.imports.get(o)??null;let s=H(e,i,t.name);return n.imports.set(o,s),s}function H(e,t,n){let r=U(e),i=r.files.get(t);if(i||(i=f(t,u(t,`utf8`)),r.files.set(t,i)),i.errors.length)return null;let a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map,c=/* @__PURE__ */ new Map;for(let e of i.program.body){if(e.type===`ImportDeclaration`&&e.importKind!==`type`)for(let t of e.specifiers)t.type===`ImportSpecifier`&&t.importKind!==`type`&&a.set(t.local.name,{source:e.source.value,name:t.imported.type===`Identifier`?t.imported.name:``}),t.type===`ImportNamespaceSpecifier`&&a.set(t.local.name,{source:e.source.value,name:`*`});let t=e.type===`ExportNamedDeclaration`?e.declaration:e;if(t?.type===`VariableDeclaration`&&t.kind===`const`){for(let n of t.declarations)if(n.init){if(n.id.type===`ObjectPattern`)for(let t of n.id.properties){if(t.type!==`Property`||t.value.type!==`Identifier`)continue;let r=t.computed?J(t.key):t.key.type===`Identifier`?t.key.name:null;r&&(o.set(t.value.name,n.init),s.set(t.value.name,r),e.type===`ExportNamedDeclaration`&&c.set(t.value.name,t.value.name))}n.id.type===`Identifier`&&(o.set(n.id.name,n.init),e.type===`ExportNamedDeclaration`&&c.set(n.id.name,n.id.name))}}if(e.type===`ExportNamedDeclaration`&&!e.source&&e.exportKind!==`type`)for(let t of e.specifiers)t.exportKind!==`type`&&t.local.type===`Identifier`&&t.exported.type===`Identifier`&&c.set(t.exported.name,t.local.name)}let l=c.get(n);if(!l)return null;function d(e,t=/* @__PURE__ */ new Set){if(e.type===`Identifier`){if(t.has(e.name)||t.size>16)return null;let n=a.get(e.name);if(n)return n;let r=o.get(e.name);return r?d(r,new Set(t).add(e.name)):null}if(e.type===`MemberExpression`&&!e.computed&&e.property.type===`Identifier`){let n=d(e.object,t);if(n?.name===`*`)return{source:n.source,name:e.property.name}}return null}function p(e,t=/* @__PURE__ */ new Set){if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`||e.type===`ParenthesizedExpression`)return p(e.expression,t);if(e.type===`Identifier`){if(t.has(e.name)||t.size>16)return null;let n=o.get(e.name),r=n?p(n,new Set(t).add(e.name)):null;return s.has(e.name)?r===`foundation`&&s.get(e.name)===`Query`?`queryRegistry`:null:r}if(e.type===`MemberExpression`&&!e.computed&&e.property.type===`Identifier`)return p(e.object,t)===`foundation`&&e.property.name===`Query`?`queryRegistry`:null;if(e.type!==`CallExpression`&&e.type!==`NewExpression`)return null;let n=d(e.callee);return n&&K(n)?`foundation`:n&&[`cvx-kit`,`cvx-kit/zod-table`,`cvx-kit/tenancy`].includes(n.source)&&[`zodTable`,`tenantTable`,`zodVariantTable`].includes(n.name)?`table`:n&&[`cvx-kit`,`cvx-kit/querying`].includes(n.source)&&n.name===`createQueryEngine`?`engine`:null}let m=o.get(l),h=m?p(m):null;return s.has(l)?h===`foundation`&&s.get(l)===`Query`?`queryRegistry`:null:h}function U(e){let t=y.get(e);return t||(t={nodes:/* @__PURE__ */ new Map,files:/* @__PURE__ */ new Map,imports:/* @__PURE__ */ new Map,resolver:n()},y.set(e,t)),t}function*W(e,t){if(t.type===`AwaitExpression`)return yield t.argument;if(t.type===`TSAsExpression`||t.type===`TSSatisfiesExpression`||t.type===`TSNonNullExpression`)return yield t.expression;if(t.type===`Identifier`){if(L(e,t)?.references.some(e=>e.isWrite()&&!e.init))return null;let n=g(e,t);if(n)return yield n;let r=_(e,t);if(r){let e=yield r.expression;if(e===`context`&&r.name===`db`)return`db`;if(e===`page`&&r.name===`page`)return`bounded`;if(e===`table`&&r.name===`publicDto`)return`dtoSchema`;if(e===`foundation`&&r.name===`Query`)return`queryRegistry`}let i=L(e,t)?.defs[0];if(i?.type===`Parameter`&&(i.node.type===`ArrowFunctionExpression`||i.node.type===`FunctionExpression`)){let t=i.node.parent;if(t?.type===`CallExpression`&&t.arguments[0]===i.node&&i.node.params[0]===i.name&&(t.callee.type===`Identifier`||t.callee.type===`MemberExpression`)){let n=h(e,t.callee);if(n&&G(n))return`context`}if(t?.type===`CallExpression`&&t.callee.type===`MemberExpression`){let e=yield t.callee.object,n=I(t.callee);if(n===`handler`&&e===`queryOperation`&&t.arguments[0]===i.node&&i.node.params[1]===i.name)return`context`;if(i.node.params[0]!==i.name)return null;if((n===`execute`||n===`paginate`)&&t.arguments[1]===i.node&&(e===`stream`||e===`relationship`))return`bounded`;if(n===`then`&&t.arguments[0]===i.node&&(e===`bounded`||e===`page`))return e}let n=i.node.parent,r=n?.type===`Property`?n.parent:null,a=r?.type===`ObjectExpression`?r.parent:null,o=a?.type===`CallExpression`?h(e,a.callee):null;if(n?.type===`Property`&&(n.computed?F(n.key):z(n.key))===`operations`&&a?.type===`CallExpression`&&a.arguments[0]===r&&(yield a.callee)===`queryRegistry`&&r?.type===`ObjectExpression`&&i.node.params[0]?.type===`ObjectPattern`&&i.node.params[0].properties.some(e=>e.type===`Property`&&e.value===i.name&&(e.computed?F(e.key):z(e.key))===`query`)&&q(e,r))return`queryOperation`;if(n?.type===`Property`&&(n.computed?F(n.key):z(n.key))===`handler`&&a?.type===`CallExpression`&&a.arguments[0]===r&&i.node.params[1]===i.name&&(yield a.callee)===`queryOperation`||n?.type===`Property`&&(n.computed?F(n.key):z(n.key))===`handler`&&i.node.params[0]===i.name&&o&&(a?.type===`CallExpression`&&a.arguments[0]===r&&(a.callee.type===`Identifier`||a.callee.type===`MemberExpression`)&&G(o)||S(e,o.source)&&/^(?:auth|role|admin|system)(?:Query|Mutation)$/.test(o.name)))return`context`}let a=h(e,t);return a&&[`zod`,`zod/v4`,`convex/values`].includes(a.source)&&[`z`,`v`,`*`,`default`].includes(a.name)?`validator`:a?V(e,a):null}if(t.type===`MemberExpression`){let n=h(e,t);if(n){let t=V(e,n);if(t)return t}let r=yield t.object,i=I(t);return r===`context`&&i===`db`?`db`:r===`foundation`&&i===`Query`?`queryRegistry`:r===`reader`?`stream`:r===`page`&&i===`page`?`bounded`:r===`table`&&[`publicDto`,`dto`].includes(i??``)?`dtoSchema`:r===`validator`?`validator`:null}if(t.type!==`CallExpression`&&t.type!==`NewExpression`)return null;let n=yield t.callee;if(n===`engine`)return`reader`;if(n===`include`&&t.arguments[0]&&(yield t.arguments[0])===`stream`)return`stream`;let r=h(e,t.callee);if(r&&K(r))return`foundation`;if(r&&[`cvx-kit`,`cvx-kit/zod-table`,`cvx-kit/tenancy`].includes(r.source)&&[`zodTable`,`tenantTable`,`zodVariantTable`].includes(r.name))return`table`;if(r&&[`cvx-kit`,`cvx-kit/querying`].includes(r.source)&&r.name===`createQueryEngine`)return`engine`;if(r&&[`cvx-kit`,`cvx-kit/auth`].includes(r.source)&&r.name===`createInclude`)return`include`;if(r?.source===`convex-helpers/server/stream`&&r.name===`stream`&&t.arguments[0]&&(yield t.arguments[0])===`db`)return`db`;if(t.callee.type!==`MemberExpression`)return null;let i=yield t.callee.object,a=I(t.callee);if(i===`table`&&a===`toPublicDto`)return`dto`;if(i===`table`&&[`select`,`dto`].includes(a??``))return`dtoSchema`;if(i===`dtoSchema`&&[`parse`,`parseAsync`].includes(a??``))return`dto`;if(i===`db`&&a===`query`)return`stream`;if(i===`stream`&&a===`relation`)return`relationship`;if(i===`context`&&a===`include`&&t.arguments[0]&&(yield t.arguments[0])===`stream`)return`stream`;if(i===`stream`||i===`relationship`){if([`take`,`execute`].includes(a??``))return`bounded`;if(a===`paginate`)return`page`;if([`withIndex`,`withSearchIndex`,`filter`,`filterWith`,`map`,`flatMap`,`distinct`,`order`,`matching`,`when`,`otherwise`,`fullTableScan`,`where`,`with`].includes(a??``))return i}return i===`bounded`&&a===`map`?`bounded`:i===`validator`?`validator`:null}function G(e){return/_generated\/server(?:\.[cm]?[jt]s)?$/.test(e.source)&&v.includes(e.name)||e.source===`convex/server`&&v.some(t=>e.name===`${t}Generic`)}function K(e){return e.source===`cvx-kit`&&e.name===`createFoundation`||e.source===`cvx-kit/effect`&&e.name===`createEffectFoundation`||[`cvx-kit`,`cvx-kit/components/foundation`].includes(e.source)&&e.name===`Foundation`}function q(e,t){let n=t.properties.find(e=>e.type===`Property`&&(e.computed?F(e.key):z(e.key))===`context`);if(n?.type!==`Property`)return!1;let r=n.value;if(r.type!==`ArrowFunctionExpression`&&r.type!==`FunctionExpression`)return!1;let i=r.params[0];if(i?.type!==`Identifier`||L(e,i)?.references.some(e=>e.isWrite()&&!e.init))return!1;let a=r.body,o=a?.type===`BlockStatement`&&a.body.length===1&&a.body[0].type===`ReturnStatement`?a.body[0].argument:a;return o?.type===`Identifier`&&L(e,o)===L(e,i)}function J(e){return e.type===`Literal`&&String(e.value)===e.value?String(e.value):e.type===`TemplateLiteral`&&e.expressions.length===0?e.quasis[0].value.cooked:null}export{m as appFile,L as binding,P as componentRoot,p as consumerOptions,E as containsComponentReference,B as delegatingBody,z as exportName,R as exportedNames,j as hasCall,h as imported,w as isDbAccess,A as isDbWrite,T as isExternalCall,S as isFunctionsImport,k as isTableChain,_ as localDestructured,g as localInitializer,O as memberPath,M as metadata,I as propertyName,b as readProvenance,D as rootMember,x as sourceVisitors,F as staticString,C as typeOnlySource};
1
+ import{createResolver as e,resolveImport as t}from"./architecture.mjs";import{conventionalComponentRoot as n,findComponentRoot as r}from"./components.mjs";import{k as i}from"../k/index.mjs";import{dirname as a,relative as o,resolve as s,sep as c}from"node:path";import{existsSync as l,readFileSync as u,realpathSync as d}from"node:fs";import{parseSync as f}from"oxc-parser";const p=i.object({convexDir:i.string().min(1).default(`convex`),componentDirs:i.array(i.string().min(1)).default([]),domainPublicFiles:i.record(i.string(),i.array(i.string().min(1))).default({})}).strip();function m(e,t=e.filename){let n=s(e.cwd,p.parse(e.options[0]??{}).convexDir),r=l(n)?d(n):n,i=o(r,l(t)?d(t):t).split(c).join(`/`);return i===`..`||i.startsWith(`../`)||i.startsWith(`/`)?null:i}const h=[`cvx-kit`,`cvx-kit/k`],g=[`cvx-kit`,`cvx-kit/table`];function _(e,t){if(t.callee.type!==`MemberExpression`)return null;let n=v(e,t.callee.object);return n?.name===`k`&&h.includes(n.source)?z(t.callee):null}function v(e,t,n=/* @__PURE__ */ new Set){if(n.has(t)||n.size>32)return null;if(n=new Set(n).add(t),t.type===`TSAsExpression`||t.type===`TSSatisfiesExpression`||t.type===`TSNonNullExpression`)return v(e,t.expression,n);if(t.type===`CallExpression`)return v(e,t.callee,n);if(t.type===`MemberExpression`){let r=v(e,t.object,n),i=z(t);return r&&i&&[`*`,`z`,`k`,`v`,`default`].includes(r.name)?{source:r.source,name:i}:null}if(t.type!==`Identifier`)return null;let r=y(e,t);if(r&&r.type!==`CallExpression`&&r.type!==`AwaitExpression`)return v(e,r,n);let i=b(e,t);if(i){let t=v(e,i.expression,n);return t&&[`*`,`z`,`k`,`v`,`default`].includes(t.name)?{source:t.source,name:i.name}:null}for(let n of B(e,t)?.defs??[]){if(n.type!==`ImportBinding`||n.parent?.type!==`ImportDeclaration`||n.parent.importKind===`type`)continue;let e=n.node;if(e.type!==`ImportSpecifier`||e.importKind!==`type`)return{source:n.parent.source.value,name:e.type===`ImportSpecifier`?H(e.imported)??``:e.type===`ImportDefaultSpecifier`?`default`:`*`}}return null}function y(e,t){let n=B(e,t);if(!n||n.references.some(e=>e.isWrite()&&!e.init))return null;let r=n.defs.length===1?n.defs[0]:null;return r?.type===`Variable`&&r.parent?.type===`VariableDeclaration`&&r.parent.kind===`const`&&r.node.type===`VariableDeclarator`&&r.node.id.type===`Identifier`?r.node.init:null}function b(e,t){let n=B(e,t);if(!n||n.references.some(e=>e.isWrite()&&!e.init))return null;let r=n.defs.length===1?n.defs[0]:null;if(r?.type!==`Variable`||r.parent?.type!==`VariableDeclaration`||r.parent.kind!==`const`||r.node.type!==`VariableDeclarator`||r.node.id.type!==`ObjectPattern`||!r.node.init)return null;for(let e of r.node.id.properties)if(e.type===`Property`&&e.value.type===`Identifier`&&e.value.name===n.name){let t=e.computed?R(e.key):H(e.key);if(t)return{expression:r.node.init,name:t}}return null}const x=[`query`,`internalQuery`,`mutation`,`internalMutation`],S=/* @__PURE__ */ new WeakMap;function C(e,t){let n=K(e).nodes;if(n.has(t))return n.get(t)??null;n.set(t,null);let r=[{node:t,evaluation:q(e,t)}],i=null;for(;r.length;){let t=r[r.length-1],a=t.evaluation.next(i);a.done?(i=a.value,n.set(t.node,i),r.pop()):n.has(a.value)?i=n.get(a.value)??null:(n.set(a.value,null),r.push({node:a.value,evaluation:q(e,a.value)}),i=null)}return i}function w(e,t){function n(e,n){let r=R(n);r&&t(e,r)}return{ImportDeclaration(e){n(e,e.source)},ExportNamedDeclaration(e){n(e,e.source)},ExportAllDeclaration(e){n(e,e.source)},ImportExpression(e){n(e,e.source)},TSImportType(e){n(e,e.source)},CallExpression(t){t.callee.type===`Identifier`&&t.callee.name===`require`&&!B(e,t.callee)?.defs.length&&n(t,t.arguments[0])}}}function T(n,r){let i=r.startsWith(`.`)?s(a(n.filename),r):t(e(),n.filename,r);if(!i)return!1;let l=L(n,n.filename);return(l?o(l,i).split(c).join(`/`):m(n,i))?.replace(/\.[cm]?[jt]s$/,``)===`functions`}function E(e){return e.type===`TSImportType`||e.type===`ImportDeclaration`&&(e.importKind===`type`||e.specifiers.length>0&&e.specifiers.every(e=>e.type===`ImportSpecifier`&&e.importKind===`type`))||(e.type===`ExportNamedDeclaration`||e.type===`ExportAllDeclaration`)&&e.exportKind===`type`}function D(e){return e.callee.type===`MemberExpression`&&e.callee.object.type===`MemberExpression`&&z(e.callee.object)===`db`}function O(e,t){let n=v(e,t.callee);return n&&/^(?:node:)?(?:https?|net|tls|fs)(?:\/|$)|^(?:undici|axios)(?:\/|$)/.test(n.source)?!0:t.callee.type===`Identifier`&&t.callee.name===`fetch`&&!B(e,t.callee)?.defs.length||t.callee.type===`MemberExpression`&&z(t.callee)===`fetch`&&t.callee.object.type===`Identifier`&&t.callee.object.name===`globalThis`&&!B(e,t.callee.object)?.defs.length}function k(e,t){if(t.type===`MemberExpression`){let n=v(e,t.object);return n?.name===`components`&&/_generated\/api/.test(n.source)?!0:k(e,t.object)}return t.type===`ObjectExpression`&&t.properties.some(t=>t.type===`Property`&&k(e,t.value))}function A(e){return e.type===`MemberExpression`?A(e.object):e}function j(e){return e.type===`Identifier`?[e.name]:e.type===`MemberExpression`?[...j(e.object),z(e)??``]:[]}function M(e){return e.type===`MemberExpression`?z(e)===`table`||M(e.object):e.type===`CallExpression`&&M(e.callee)}function N(e){return e.callee.type===`MemberExpression`&&[`insert`,`patch`,`replace`,`delete`].includes(z(e.callee)??``)&&e.callee.object.type===`MemberExpression`&&z(e.callee.object)===`db`}function P(e,t){return e.type===`CallExpression`?e.callee.type===`MemberExpression`&&z(e.callee)===t&&(t!==`query`||z(e.callee.object)===`db`)||P(e.callee,t):e.type===`MemberExpression`&&P(e.object,t)}function F(e,t){return{type:`problem`,docs:{description:e},schema:[],messages:t}}const I=/* @__PURE__ */ new WeakMap;function L(e,t){let i=I.get(e);if(i||(i=/* @__PURE__ */ new Map,I.set(e,i)),i.has(t))return i.get(t)??null;let a=s(e.cwd,p.parse(e.options[0]??{}).convexDir),o=l(a)?d(a):a,c=l(t)?d(t):s(t),u=p.parse(e.options[0]??{}).componentDirs.map(e=>s(o,e)),f=r(c,u)??n(c,o);return i.set(t,f),f}function R(e){return e?.type===`Literal`&&`value`in e&&String(e.value)===e.value?String(e.value):e?.type===`TemplateLiteral`&&e.expressions.length===0?e.quasis[0].value.cooked:null}function z(e){return e.type===`MemberExpression`?e.computed?R(e.property):e.property.name:null}function B(e,t){if(t.type!==`Identifier`)return null;let n=e.sourceCode.getScope(t);for(;n;){let e=n.set.get(t.name);if(e)return e;n=n.upper}return null}function V(e){let t=/* @__PURE__ */ new Set;for(let n of e.body)if(n.type===`ExportNamedDeclaration`&&!n.source)for(let e of n.specifiers)t.add(H(e.local)??``);else n.type===`ExportDefaultDeclaration`&&n.declaration.type===`Identifier`&&t.add(n.declaration.name);return t}function H(e){return e.type===`Identifier`?e.name:R(e)}function U(e){return e.type===`CallExpression`?!0:e.type===`AwaitExpression`?U(e.argument):e.type===`BlockStatement`&&e.body.length>0&&e.body.every(e=>e.type===`ReturnStatement`&&e.argument!==null&&U(e.argument)||e.type===`ExpressionStatement`&&U(e.expression))}function W(e,n){let r=K(e),i=t(r.resolver,e.filename,n.source),a=i&&m(e,i);if(!i||!a||!/^(?:domain\/.+\/schema\.ts|querying\.ts|foundation\.ts)$/.test(a)&&!(L(e,i)&&/(?:^|\/)(?:schema|table|foundation)\.ts$/.test(a))||!l(i))return null;let o=`${i}:${n.name}`;if(r.imports.has(o))return r.imports.get(o)??null;let s=G(e,i,n.name);return r.imports.set(o,s),s}function G(e,t,n){let r=K(e),i=r.files.get(t);if(i||(i=f(t,u(t,`utf8`)),r.files.set(t,i)),i.errors.length)return null;let a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map,c=/* @__PURE__ */ new Map;for(let e of i.program.body){if(e.type===`ImportDeclaration`&&e.importKind!==`type`)for(let t of e.specifiers)t.type===`ImportSpecifier`&&t.importKind!==`type`&&a.set(t.local.name,{source:e.source.value,name:t.imported.type===`Identifier`?t.imported.name:``}),t.type===`ImportNamespaceSpecifier`&&a.set(t.local.name,{source:e.source.value,name:`*`});let t=e.type===`ExportNamedDeclaration`?e.declaration:e;if(t?.type===`VariableDeclaration`&&t.kind===`const`){for(let n of t.declarations)if(n.init){if(n.id.type===`ObjectPattern`)for(let t of n.id.properties){if(t.type!==`Property`||t.value.type!==`Identifier`)continue;let r=t.computed?Z(t.key):t.key.type===`Identifier`?t.key.name:null;r&&(o.set(t.value.name,n.init),s.set(t.value.name,r),e.type===`ExportNamedDeclaration`&&c.set(t.value.name,t.value.name))}n.id.type===`Identifier`&&(o.set(n.id.name,n.init),e.type===`ExportNamedDeclaration`&&c.set(n.id.name,n.id.name))}}if(e.type===`ExportNamedDeclaration`&&!e.source&&e.exportKind!==`type`)for(let t of e.specifiers)t.exportKind!==`type`&&t.local.type===`Identifier`&&t.exported.type===`Identifier`&&c.set(t.exported.name,t.local.name)}let l=c.get(n);if(!l)return null;function d(e,t=/* @__PURE__ */ new Set){if(e.type===`Identifier`){if(t.has(e.name)||t.size>16)return null;let n=a.get(e.name);if(n)return n;let r=o.get(e.name);return r?d(r,new Set(t).add(e.name)):null}if(e.type===`MemberExpression`&&!e.computed&&e.property.type===`Identifier`){let n=d(e.object,t);if(n?.name===`*`)return{source:n.source,name:e.property.name}}return null}function p(e,t=/* @__PURE__ */ new Set){if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`||e.type===`ParenthesizedExpression`)return p(e.expression,t);if(e.type===`Identifier`){if(t.has(e.name)||t.size>16)return null;let n=o.get(e.name),r=n?p(n,new Set(t).add(e.name)):null;return s.has(e.name)?r===`foundation`&&s.get(e.name)===`Query`?`queryRegistry`:null:r}if(e.type===`MemberExpression`&&!e.computed&&e.property.type===`Identifier`)return p(e.object,t)===`foundation`&&e.property.name===`Query`?`queryRegistry`:null;if(e.type!==`CallExpression`&&e.type!==`NewExpression`)return null;let n=d(e.callee);return n&&Y(n)?`foundation`:n&&[`cvx-kit`,`cvx-kit/table`,`cvx-kit/tenancy`].includes(n.source)&&[`kTable`,`tenantTable`,`kVariantTable`].includes(n.name)?`table`:n&&[`cvx-kit`,`cvx-kit/querying`].includes(n.source)&&n.name===`createQueryEngine`?`engine`:null}let m=o.get(l),h=m?p(m):null;return s.has(l)?h===`foundation`&&s.get(l)===`Query`?`queryRegistry`:null:h}function K(t){let n=S.get(t);return n||(n={nodes:/* @__PURE__ */ new Map,files:/* @__PURE__ */ new Map,imports:/* @__PURE__ */ new Map,resolver:e()},S.set(t,n)),n}function*q(e,t){if(t.type===`AwaitExpression`)return yield t.argument;if(t.type===`TSAsExpression`||t.type===`TSSatisfiesExpression`||t.type===`TSNonNullExpression`)return yield t.expression;if(t.type===`Identifier`){if(B(e,t)?.references.some(e=>e.isWrite()&&!e.init))return null;let n=y(e,t);if(n)return yield n;let r=b(e,t);if(r){let e=yield r.expression;if(e===`context`&&r.name===`db`)return`db`;if(e===`page`&&r.name===`page`)return`bounded`;if(e===`table`&&r.name===`publicDto`)return`dtoSchema`;if(e===`foundation`&&r.name===`Query`)return`queryRegistry`}let i=B(e,t)?.defs[0];if(i?.type===`Parameter`&&(i.node.type===`ArrowFunctionExpression`||i.node.type===`FunctionExpression`)){let t=i.node.parent;if(t?.type===`CallExpression`&&t.arguments[0]===i.node&&i.node.params[0]===i.name&&(t.callee.type===`Identifier`||t.callee.type===`MemberExpression`)){let n=v(e,t.callee);if(n&&J(n))return`context`}if(t?.type===`CallExpression`&&t.callee.type===`MemberExpression`){let e=yield t.callee.object,n=z(t.callee);if(n===`handler`&&e===`queryOperation`&&t.arguments[0]===i.node&&i.node.params[1]===i.name)return`context`;if(i.node.params[0]!==i.name)return null;if((n===`execute`||n===`paginate`)&&t.arguments[1]===i.node&&(e===`stream`||e===`relationship`))return`bounded`;if(n===`then`&&t.arguments[0]===i.node&&(e===`bounded`||e===`page`))return e}let n=i.node.parent,r=n?.type===`Property`?n.parent:null,a=r?.type===`ObjectExpression`?r.parent:null,o=a?.type===`CallExpression`?v(e,a.callee):null;if(n?.type===`Property`&&(n.computed?R(n.key):H(n.key))===`operations`&&a?.type===`CallExpression`&&a.arguments[0]===r&&(yield a.callee)===`queryRegistry`&&r?.type===`ObjectExpression`&&i.node.params[0]?.type===`ObjectPattern`&&i.node.params[0].properties.some(e=>e.type===`Property`&&e.value===i.name&&(e.computed?R(e.key):H(e.key))===`query`)&&X(e,r))return`queryOperation`;if(n?.type===`Property`&&(n.computed?R(n.key):H(n.key))===`handler`&&a?.type===`CallExpression`&&a.arguments[0]===r&&i.node.params[1]===i.name&&(yield a.callee)===`queryOperation`||n?.type===`Property`&&(n.computed?R(n.key):H(n.key))===`handler`&&i.node.params[0]===i.name&&o&&(a?.type===`CallExpression`&&a.arguments[0]===r&&(a.callee.type===`Identifier`||a.callee.type===`MemberExpression`)&&J(o)||T(e,o.source)&&/^(?:auth|role|admin|system)(?:Query|Mutation)$/.test(o.name)))return`context`}let a=v(e,t);return a&&[`cvx-kit`,`cvx-kit/k`,`convex/values`].includes(a.source)&&[`k`,`v`,`*`,`default`].includes(a.name)?`validator`:a?W(e,a):null}if(t.type===`MemberExpression`){let n=v(e,t);if(n){let t=W(e,n);if(t)return t}let r=yield t.object,i=z(t);return r===`context`&&i===`db`?`db`:r===`foundation`&&i===`Query`?`queryRegistry`:r===`reader`?`stream`:r===`page`&&i===`page`?`bounded`:r===`table`&&[`publicDto`,`dto`].includes(i??``)?`dtoSchema`:r===`validator`?`validator`:null}if(t.type!==`CallExpression`&&t.type!==`NewExpression`)return null;let n=yield t.callee;if(n===`engine`)return`reader`;if(n===`include`&&t.arguments[0]&&(yield t.arguments[0])===`stream`)return`stream`;let r=v(e,t.callee);if(r&&Y(r))return`foundation`;if(r&&[`cvx-kit`,`cvx-kit/table`,`cvx-kit/tenancy`].includes(r.source)&&[`kTable`,`tenantTable`,`kVariantTable`].includes(r.name))return`table`;if(r&&[`cvx-kit`,`cvx-kit/querying`].includes(r.source)&&r.name===`createQueryEngine`)return`engine`;if(r&&[`cvx-kit`,`cvx-kit/auth`].includes(r.source)&&r.name===`createInclude`)return`include`;if(r?.source===`convex-helpers/server/stream`&&r.name===`stream`&&t.arguments[0]&&(yield t.arguments[0])===`db`)return`db`;if(t.callee.type!==`MemberExpression`)return null;let i=yield t.callee.object,a=z(t.callee);if(i===`table`&&a===`toPublicDto`)return`dto`;if(i===`table`&&[`select`,`dto`].includes(a??``))return`dtoSchema`;if(i===`dtoSchema`&&[`parse`,`parseAsync`].includes(a??``))return`dto`;if(i===`db`&&a===`query`)return`stream`;if(i===`stream`&&a===`relation`)return`relationship`;if(i===`context`&&a===`include`&&t.arguments[0]&&(yield t.arguments[0])===`stream`)return`stream`;if(i===`stream`||i===`relationship`){if([`take`,`execute`].includes(a??``))return`bounded`;if(a===`paginate`)return`page`;if([`withIndex`,`withSearchIndex`,`filter`,`filterWith`,`map`,`flatMap`,`distinct`,`order`,`matching`,`when`,`otherwise`,`fullTableScan`,`where`,`with`].includes(a??``))return i}return i===`bounded`&&a===`map`?`bounded`:i===`validator`?`validator`:null}function J(e){return/_generated\/server(?:\.[cm]?[jt]s)?$/.test(e.source)&&x.includes(e.name)||e.source===`convex/server`&&x.some(t=>e.name===`${t}Generic`)}function Y(e){return e.source===`cvx-kit`&&e.name===`createFoundation`||e.source===`cvx-kit/effect`&&e.name===`createEffectFoundation`||[`cvx-kit`,`cvx-kit/components/foundation`].includes(e.source)&&e.name===`Foundation`}function X(e,t){let n=t.properties.find(e=>e.type===`Property`&&(e.computed?R(e.key):H(e.key))===`context`);if(n?.type!==`Property`)return!1;let r=n.value;if(r.type!==`ArrowFunctionExpression`&&r.type!==`FunctionExpression`)return!1;let i=r.params[0];if(i?.type!==`Identifier`||B(e,i)?.references.some(e=>e.isWrite()&&!e.init))return!1;let a=r.body,o=a?.type===`BlockStatement`&&a.body.length===1&&a.body[0].type===`ReturnStatement`?a.body[0].argument:a;return o?.type===`Identifier`&&B(e,o)===B(e,i)}function Z(e){return e.type===`Literal`&&String(e.value)===e.value?String(e.value):e.type===`TemplateLiteral`&&e.expressions.length===0?e.quasis[0].value.cooked:null}export{h as K_SOURCES,g as TABLE_SOURCES,m as appFile,B as binding,L as componentRoot,p as consumerOptions,k as containsComponentReference,U as delegatingBody,H as exportName,V as exportedNames,P as hasCall,v as imported,D as isDbAccess,N as isDbWrite,O as isExternalCall,T as isFunctionsImport,M as isTableChain,_ as kFactory,b as localDestructured,y as localInitializer,j as memberPath,F as metadata,z as propertyName,C as readProvenance,A as rootMember,w as sourceVisitors,R as staticString,E as typeOnlySource};
2
2
  //# sourceMappingURL=ast.mjs.map
@@ -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","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,EAA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AChBI,EACLD,GAAM,OAAS,kBACfA,EAAK,KAAK,SAAW,GACrBA,EAAK,KAAK,EAAE,CAAC,OAAS,kBACnBA,EAAK,KAAK,EAAE,CAAC,SACbA,EACJ,OAAOC,GAAU,OAAS,cAAgBpF,EAAQrB,EAASyG,CAAQ,IAAMpF,EAAQrB,EAASsG,CAAI,CAC/F,CAEA,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"}
1
+ {"version":3,"file":"ast.mjs","names":["consumerOptions","k","appFile","context","requestedRoot","resolve","root","existsSync","realpathSync","file","relative","filename","sep","K_SOURCES","TABLE_SOURCES","kFactory","node","owner","imported","propertyName","active","name","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 { parseSync, type Node } from 'oxc-parser'\nimport { createResolver, resolveImport } from './architecture'\nimport { findComponentRoot, conventionalComponentRoot } from './components'\nimport { k } from '../k/index'\n\n/** Options every consumer-facing rule accepts; unknown keys are ignored. */\nexport const consumerOptions = k\n\t.object({\n\t\tconvexDir: k.string().min(1).default('convex'),\n\t\tcomponentDirs: k.array(k.string().min(1)).default([]),\n\t\tdomainPublicFiles: k.record(k.string(), k.array(k.string().min(1))).default({}),\n\t})\n\t.strip()\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\n/** Entries that export the `k` validator namespace. */\nexport const K_SOURCES: readonly string[] = ['cvx-kit', 'cvx-kit/k']\n\n/** Entries that export the table builders (`kTable`, `kVariantTable`, `tenantTable`, `createModule`). */\nexport const TABLE_SOURCES: readonly string[] = ['cvx-kit', 'cvx-kit/table']\n\n/** Factory name when `node` is a `k.<factory>(...)` call whose `k` comes from a kit entry. */\nexport function kFactory(context: Context, node: ESTree.CallExpression): string | null {\n\tif (node.callee.type !== 'MemberExpression') return null\n\tconst owner = imported(context, node.callee.object)\n\treturn owner?.name === 'k' && K_SOURCES.includes(owner.source) ? propertyName(node.callee) : null\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', 'k', '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', 'k', '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/table', 'cvx-kit/tenancy'].includes(factory.source) &&\n\t\t\t['kTable', 'tenantTable', 'kVariantTable'].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['cvx-kit', 'cvx-kit/k', 'convex/values'].includes(ref.source) &&\n\t\t\t['k', '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/table', 'cvx-kit/tenancy'].includes(ref.source) &&\n\t\t['kTable', 'tenantTable', 'kVariantTable'].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":"A,sXASA,MAAaA,EAAkBC,EAC7B,OAAO,CACP,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,CAAC,CACD,MAAM,EAER,SAAgB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A,EAAI,OAAS,YAErF,CAGA,SAAS8C,EAAyB,EAAkB,EAAiC,CACpF,IAAMxE,EAAWqE,EAAO,WAAW,KACjC,GACAE,EAAE,OAAS,aAAeA,EAAE,SAAWtE,EAAasE,EAAE,GAAG,EAAI1E,EAAW0E,EAAE,GAAG,KAAO,SACtF,EACA,GAAIvE,GAAU,OAAS,WAAY,MAAO,GAC1C,IAAM2E,EAAW3E,EAAS,MAC1B,GAAI2E,EAAS,OAAS,2BAA6BA,EAAS,OAAS,qBACpE,MAAO,GACR,IAAMC,EAAOD,EAAS,OAAO,GAC7B,GACCC,GAAM,OAAS,cACfjF,EAAQxB,EAASyG,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,cAAgBpF,EAAQxB,EAAS4G,CAAQ,IAAMpF,EAAQxB,EAASyG,CAAI,CAC/F,CAEA,SAASnB,EAAe,EAA2B,CAIlD,OAHIzE,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,C"}
@@ -1,6 +1,4 @@
1
- //#region src/oxlint/components.d.ts
2
1
  /** Locate standalone components as well as the conventional components/<name> layout. */
3
2
  export declare function findComponentRoot(filename: string, roots?: readonly string[]): string | null;
4
3
  export declare function conventionalComponentRoot(filename: string, root: string): string | null;
5
- //#endregion
6
4
  //# sourceMappingURL=components.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.mjs","names":["findComponentRoot","file","resolve","filename","directory","dirname","roots","definesComponent","conventionalComponentRoot","match","relative","root","sep","config","existsSync","parseSync","readFileSync","errors","names","namespaces","statement","program","specifier","declaration","expressions","item","expression","callee"],"sources":["../../src/oxlint/components.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs'\nimport { dirname, resolve, relative, sep } from 'node:path'\nimport { parseSync } from 'oxc-parser'\n\n/** Locate standalone components as well as the conventional components/<name> layout. */\nexport function findComponentRoot(filename: string, roots: readonly string[] = []) {\n\tconst file = resolve(filename)\n\tfor (let directory = dirname(file); ; directory = dirname(directory)) {\n\t\tif (roots.includes(directory) || definesComponent(directory)) return directory\n\t\tif (dirname(directory) === directory) return null\n\t}\n}\n\nexport function conventionalComponentRoot(filename: string, root: string) {\n\tconst match = relative(root, filename)\n\t\t.split(sep)\n\t\t.join('/')\n\t\t.match(/^components\\/([^/]+)(?:\\/|$)/)\n\treturn match ? resolve(root, 'components', match[1]) : null\n}\n\nfunction definesComponent(directory: string) {\n\tconst config = resolve(directory, 'convex.config.ts')\n\tif (!existsSync(config)) return false\n\tconst { program, errors } = parseSync(config, readFileSync(config, 'utf8'))\n\tif (errors.length) return false\n\tconst names = new Set<string>()\n\tconst namespaces = new Set<string>()\n\tfor (const statement of program.body) {\n\t\tif (statement.type !== 'ImportDeclaration' || statement.source.value !== 'convex/server')\n\t\t\tcontinue\n\t\tfor (const specifier of statement.specifiers) {\n\t\t\tif (specifier.type === 'ImportNamespaceSpecifier') namespaces.add(specifier.local.name)\n\t\t\tif (\n\t\t\t\tspecifier.type === 'ImportSpecifier' &&\n\t\t\t\t(specifier.imported.type === 'Identifier'\n\t\t\t\t\t? specifier.imported.name\n\t\t\t\t\t: specifier.imported.value) === 'defineComponent'\n\t\t\t)\n\t\t\t\tnames.add(specifier.local.name)\n\t\t}\n\t}\n\tfor (const statement of program.body) {\n\t\tconst declaration =\n\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement\n\t\tconst expressions =\n\t\t\tdeclaration?.type === 'VariableDeclaration'\n\t\t\t\t? declaration.declarations.map((item) => item.init)\n\t\t\t\t: statement.type === 'ExportDefaultDeclaration'\n\t\t\t\t\t? [statement.declaration]\n\t\t\t\t\t: []\n\t\tfor (const expression of expressions) {\n\t\t\tif (expression?.type !== 'CallExpression') continue\n\t\t\tconst callee = expression.callee\n\t\t\tif (callee.type === 'Identifier' && names.has(callee.name)) return true\n\t\t\tif (\n\t\t\t\tcallee.type === 'MemberExpression' &&\n\t\t\t\t!callee.computed &&\n\t\t\t\tcallee.property.type === 'Identifier' &&\n\t\t\t\tcallee.property.name === 'defineComponent' &&\n\t\t\t\tcallee.object.type === 'Identifier' &&\n\t\t\t\tnamespaces.has(callee.object.name)\n\t\t\t)\n\t\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n"],"mappings":"sKAKA,SAAgBA,EAAkB,EAAkB,EAA2B,CAAC,EAAG,CAClF,IAAMC,EAAOC,EAAQC,CAAQ,EAC7B,IAAK,IAAIC,EAAYC,EAAQJ,CAAI,GAAK,EAAYI,EAAQD,CAAS,EAAG,CACrE,GAAIE,EAAM,SAASF,CAAS,GAAKG,EAAiBH,CAAS,EAAG,OAAOA,EACrE,GAAIC,EAAQD,CAAS,IAAMA,EAAW,OAAO,IAC9C,CACD,CAEA,SAAgBI,EAA0B,EAAkB,EAAc,CACzE,IAAMC,EAAQC,EAASC,EAAMR,CAAQ,CAAC,CACpC,MAAMS,CAAG,CAAC,CACV,KAAK,GAAG,CAAC,CACT,MAAM,8BAA8B,EACtC,OAAOH,EAAQP,EAAQS,EAAM,aAAcF,EAAM,EAAE,EAAI,IACxD,CAEA,SAASF,EAAiB,EAAmB,CAC5C,IAAMM,EAASX,EAAQE,EAAW,kBAAkB,EACpD,GAAI,CAACU,EAAWD,CAAM,EAAG,MAAO,GAChC,GAAM,CAAE,UAAS,UAAWE,EAAUF,EAAQG,EAAaH,EAAQ,MAAM,CAAC,EAC1E,GAAII,EAAO,OAAQ,MAAO,GAC1B,IAAMC,kBAAQ,IAAI,IACZC,kBAAa,IAAI,IACvB,IAAK,IAAMC,KAAaC,EAAQ,KAC/B,GAAID,EAAU,OAAS,qBAAuBA,EAAU,OAAO,QAAU,gBAEzE,IAAK,IAAME,KAAaF,EAAU,WAC7BE,EAAU,OAAS,4BAA4BH,EAAW,IAAIG,EAAU,MAAM,IAAI,EAErFA,EAAU,OAAS,oBAClBA,EAAU,SAAS,OAAS,aAC1BA,EAAU,SAAS,KACnBA,EAAU,SAAS,SAAW,mBAEjCJ,EAAM,IAAII,EAAU,MAAM,IAAI,EAGjC,IAAK,IAAMF,KAAaC,EAAQ,KAAM,CACrC,IAAME,EACLH,EAAU,OAAS,yBAA2BA,EAAU,YAAcA,EACjEI,EACLD,GAAa,OAAS,sBACnBA,EAAY,aAAa,IAAK,GAASE,EAAK,IAAI,EAChDL,EAAU,OAAS,2BAClB,CAACA,EAAU,WAAW,EACtB,CAAC,EACN,IAAK,IAAMM,KAAcF,EAAa,CACrC,GAAIE,GAAY,OAAS,iBAAkB,SAC3C,IAAMC,EAASD,EAAW,OAE1B,GADIC,EAAO,OAAS,cAAgBT,EAAM,IAAIS,EAAO,IAAI,GAExDA,EAAO,OAAS,oBAChB,CAACA,EAAO,UACRA,EAAO,SAAS,OAAS,cACzBA,EAAO,SAAS,OAAS,mBACzBA,EAAO,OAAO,OAAS,cACvBR,EAAW,IAAIQ,EAAO,OAAO,IAAI,EAEjC,MAAO,EACT,CACD,CACA,MAAO,EACR"}
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":"A,sKAKA,SAAgBA,EAAkB,EAAkB,EAA2B,CAAC,EAAG,CAClF,IAAMC,EAAOC,EAAQC,CAAQ,EAC7B,IAAK,IAAIC,EAAYC,EAAQJ,CAAI,GAAK,EAAYI,EAAQD,CAAS,EAAG,CACrE,GAAIE,EAAM,SAASF,CAAS,GAAKG,EAAiBH,CAAS,EAAG,OAAOA,EACrE,GAAIC,EAAQD,CAAS,IAAMA,EAAW,OAAO,IAC9C,CACD,CAEA,SAAgBI,EAA0B,EAAkB,EAAc,CACzE,IAAMC,EAAQC,EAASC,EAAMR,CAAQ,CAAC,CACpC,MAAMS,CAAG,CAAC,CACV,KAAK,GAAG,CAAC,CACT,MAAM,8BAA8B,EACtC,OAAOH,EAAQP,EAAQS,EAAM,aAAcF,EAAM,EAAE,EAAI,IACxD,CAEA,SAASF,EAAiB,EAAmB,CAC5C,IAAMM,EAASX,EAAQE,EAAW,kBAAkB,EACpD,GAAI,CAACU,EAAWD,CAAM,EAAG,MAAO,GAChC,GAAM,CAAE,UAAS,UAAWE,EAAUF,EAAQG,EAAaH,EAAQ,MAAM,CAAC,EAC1E,GAAII,EAAO,OAAQ,MAAO,GAC1B,IAAMC,kBAAQ,IAAI,IACZC,kBAAa,IAAI,IACvB,IAAK,IAAMC,KAAaC,EAAQ,KAC/B,GAAID,EAAU,OAAS,qBAAuBA,EAAU,OAAO,QAAU,gBAEzE,IAAK,IAAME,KAAaF,EAAU,WAC7BE,EAAU,OAAS,4BAA4BH,EAAW,IAAIG,EAAU,MAAM,IAAI,EAErFA,EAAU,OAAS,oBAClBA,EAAU,SAAS,OAAS,aAC1BA,EAAU,SAAS,KACnBA,EAAU,SAAS,SAAW,mBAEjCJ,EAAM,IAAII,EAAU,MAAM,IAAI,EAGjC,IAAK,IAAMF,KAAaC,EAAQ,KAAM,CACrC,IAAME,EACLH,EAAU,OAAS,yBAA2BA,EAAU,YAAcA,EACjEI,EACLD,GAAa,OAAS,sBACnBA,EAAY,aAAa,IAAK,GAASE,EAAK,IAAI,EAChDL,EAAU,OAAS,2BAClB,CAACA,EAAU,WAAW,EACtB,CAAC,EACN,IAAK,IAAMM,KAAcF,EAAa,CACrC,GAAIE,GAAY,OAAS,iBAAkB,SAC3C,IAAMC,EAASD,EAAW,OAE1B,GADIC,EAAO,OAAS,cAAgBT,EAAM,IAAIS,EAAO,IAAI,GAExDA,EAAO,OAAS,oBAChB,CAACA,EAAO,UACRA,EAAO,SAAS,OAAS,cACzBA,EAAO,SAAS,OAAS,mBACzBA,EAAO,OAAO,OAAS,cACvBR,EAAW,IAAIQ,EAAO,OAAO,IAAI,EAEjC,MAAO,EACT,CACD,CACA,MAAO,EACR,C"}
@@ -1,5 +1,4 @@
1
1
  import { ESTree } from "@oxlint/plugins";
2
- //#region src/oxlint/ownership.d.ts
3
2
  export declare const ownershipRules: {
4
3
  'project-structure': {
5
4
  meta: import("@oxlint/plugins").RuleMeta;
@@ -57,5 +56,4 @@ export declare const ownershipRules: {
57
56
  };
58
57
  };
59
58
  export type OwnershipRuleName = keyof typeof ownershipRules;
60
- //#endregion
61
59
  //# sourceMappingURL=ownership.d.mts.map
@@ -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);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};
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,kFactory as g,memberPath as _,metadata as v,propertyName as y,rootMember as b,sourceVisitors as x,typeOnlySource as S}from"./ast.mjs";import{basename as C,resolve as w}from"node:path";import{existsSync as T,realpathSync as E}from"node:fs";const D={"project-structure":{meta:v(`Validate the application tree, colocated tests, and module cycles.`,{structure:`{{file}}: {{message}}`}),create(t){let r=s.parse(t.options[0]??{}),i=w(t.cwd,r.convexDir);return(T(t.filename)?E(t.filename):w(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:v(`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:v(`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=x(e,(t,s)=>{if(S(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),g(e,t)&&c(t)},MemberExpression(t){let r=_(t);if(r.length>=4&&r[1]===`domain`){let i=d(e,b(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:v(`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:v(`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=C(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),v=t(),b=null;function w(e){b??=e}let T=x(e,(t,n)=>{if(S(t))return;let a=r(v,e.filename,n),c=a&&i(e,a);s&&n!==`cvx-kit/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/k`,`cvx-kit/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/table`&&n.name===`createModule`||n?.source===`cvx-kit/table`&&n.name===`namespaceIndex`||w(t)}let n=t.callee.type===`MemberExpression`?y(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`&&y(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(y(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"(){b&&e.report({node:b,messageId:`ownership`})}}}}};export{D as ownershipRules};
2
2
  //# sourceMappingURL=ownership.mjs.map