better-supabase 0.58.3 → 0.60.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 (522) hide show
  1. package/dist/{account-parts-DxSyD4yi.d.ts → account-parts-D-cLYi0Y.d.ts} +1 -1
  2. package/dist/{adapter-base-BbnpIsy4.js → adapter-base-BHtxRoRg.js} +1 -1
  3. package/dist/{agents-CbsEgoLN.d.ts → agents-FJk0CNex.d.ts} +2 -2
  4. package/dist/{ai-schedules-D47O_Vlo.d.ts → ai-schedules-wlL3DKqu.d.ts} +1 -1
  5. package/dist/ai-sdk/agents/index.d.ts +1 -1
  6. package/dist/ai-sdk/workflow/index.d.ts +1 -1
  7. package/dist/{api-wRlj_7so.d.ts → api-CSx2F4zg.d.ts} +1 -1
  8. package/dist/{api-DsFkhsYI.js → api-Clu-XitC.js} +1 -1
  9. package/dist/{app-tables-IXL0Hzut.d.ts → app-tables-C_bRG0ek.d.ts} +1 -1
  10. package/dist/{approvals-Clg-7ghA.js → approvals-D7Xhpd52.js} +8 -6
  11. package/dist/{approvals-Bbxeiywy.d.ts → approvals-Dn_DM4Oi.d.ts} +6 -0
  12. package/dist/astro/index.d.ts +3 -3
  13. package/dist/astro/index.js +3 -3
  14. package/dist/{authorization-Dq47C4vf.d.ts → authorization-Cn_oEGoA.d.ts} +1 -1
  15. package/dist/better-result/index.d.ts +2 -2
  16. package/dist/{bind-BRkDWXXk.d.ts → bind-Dopmkg_T.d.ts} +4 -4
  17. package/dist/{block-env-I8juWoVO.d.ts → block-env-4tgXDIAX.d.ts} +4 -4
  18. package/dist/{block-tables-DmDyNlJf.d.ts → block-tables-KnVB7FH0.d.ts} +1 -1
  19. package/dist/blocks/access-requests/index.d.ts +1 -1
  20. package/dist/blocks/accounting/index.d.ts +1 -1
  21. package/dist/blocks/acknowledgements/index.d.ts +1 -1
  22. package/dist/blocks/activities/index.d.ts +2 -2
  23. package/dist/blocks/advisories/index.d.ts +1 -1
  24. package/dist/blocks/agent-checkout/index.d.ts +1 -1
  25. package/dist/blocks/agents/index.d.ts +1 -1
  26. package/dist/blocks/ai-cache/index.d.ts +1 -1
  27. package/dist/blocks/ai-chat/index.d.ts +1 -1
  28. package/dist/blocks/ai-evals/index.d.ts +1 -1
  29. package/dist/blocks/ai-files/index.d.ts +1 -1
  30. package/dist/blocks/ai-guardrails/index.d.ts +1 -1
  31. package/dist/blocks/ai-keys/index.d.ts +1 -1
  32. package/dist/blocks/ai-schedules/index.d.ts +2 -2
  33. package/dist/blocks/announcements/index.d.ts +4 -4
  34. package/dist/blocks/api-keys/index.d.ts +1 -1
  35. package/dist/blocks/appraisals/index.d.ts +1 -1
  36. package/dist/blocks/approvals/index.d.ts +2 -2
  37. package/dist/blocks/approvals/index.js +2 -2
  38. package/dist/blocks/assets/index.d.ts +2 -2
  39. package/dist/blocks/assignment/index.d.ts +1 -1
  40. package/dist/blocks/attachments/index.d.ts +5 -5
  41. package/dist/blocks/audit/index.d.ts +2 -2
  42. package/dist/blocks/automations/index.d.ts +4 -4
  43. package/dist/blocks/banking/index.d.ts +1 -1
  44. package/dist/blocks/billable-time/index.d.ts +1 -1
  45. package/dist/blocks/billing/index.d.ts +3 -3
  46. package/dist/blocks/bookings/index.d.ts +2 -2
  47. package/dist/blocks/bulk-actions/index.d.ts +2 -2
  48. package/dist/blocks/calendar/index.d.ts +3 -3
  49. package/dist/blocks/care/index.d.ts +27 -27
  50. package/dist/blocks/care/index.js +1 -1
  51. package/dist/blocks/care-plans/index.d.ts +3 -3
  52. package/dist/blocks/cases/index.d.ts +3 -3
  53. package/dist/blocks/catalog/index.d.ts +2 -2
  54. package/dist/blocks/channels/index.d.ts +1 -1
  55. package/dist/blocks/clinical-decision-support/index.d.ts +1 -1
  56. package/dist/blocks/cms/index.d.ts +5 -5
  57. package/dist/blocks/cms/index.js +1 -1
  58. package/dist/blocks/collaboration/index.d.ts +6 -6
  59. package/dist/blocks/collections/index.d.ts +1 -1
  60. package/dist/blocks/comments/index.d.ts +2 -2
  61. package/dist/blocks/commerce/index.d.ts +5 -5
  62. package/dist/blocks/commissions/index.d.ts +1 -1
  63. package/dist/blocks/compliance/index.d.ts +1 -1
  64. package/dist/blocks/connectors/index.d.ts +1 -1
  65. package/dist/blocks/consents/index.d.ts +2 -2
  66. package/dist/blocks/contacts/index.d.ts +2 -2
  67. package/dist/blocks/content/index.d.ts +2 -2
  68. package/dist/blocks/contracts/index.d.ts +1 -1
  69. package/dist/blocks/courses/index.d.ts +2 -2
  70. package/dist/blocks/created-by/index.d.ts +2 -2
  71. package/dist/blocks/crm/index.d.ts +17 -17
  72. package/dist/blocks/crm/index.js +2 -2
  73. package/dist/blocks/custom-fields/index.d.ts +1 -1
  74. package/dist/blocks/dam/index.d.ts +2 -2
  75. package/dist/blocks/data-lifecycle/index.d.ts +2 -2
  76. package/dist/blocks/deadlines/index.d.ts +1 -1
  77. package/dist/blocks/deals/index.d.ts +1 -1
  78. package/dist/blocks/dispatch/index.d.ts +2 -2
  79. package/dist/blocks/document-templates/index.d.ts +2 -2
  80. package/dist/blocks/documents/index.d.ts +1 -1
  81. package/dist/blocks/domains/index.d.ts +1 -1
  82. package/dist/blocks/donations/index.d.ts +1 -1
  83. package/dist/blocks/drive/index.d.ts +5 -5
  84. package/dist/blocks/e-prescribing/index.d.ts +1 -1
  85. package/dist/blocks/employees/index.d.ts +1 -1
  86. package/dist/blocks/enrichment/index.d.ts +1 -1
  87. package/dist/blocks/enrollments/index.d.ts +2 -2
  88. package/dist/blocks/entitlements/index.d.ts +3 -3
  89. package/dist/blocks/events/index.d.ts +3 -3
  90. package/dist/blocks/expenses/index.d.ts +1 -1
  91. package/dist/blocks/field-history/index.d.ts +1 -1
  92. package/dist/blocks/filespace/index.d.ts +8 -8
  93. package/dist/blocks/finance/index.d.ts +5 -5
  94. package/dist/blocks/finance/index.js +1 -1
  95. package/dist/blocks/flags/index.d.ts +1 -1
  96. package/dist/blocks/forecasts/index.d.ts +1 -1
  97. package/dist/blocks/forms/index.d.ts +3 -3
  98. package/dist/blocks/funding/index.d.ts +2 -2
  99. package/dist/blocks/goals/index.d.ts +1 -1
  100. package/dist/blocks/governance/index.d.ts +4 -4
  101. package/dist/blocks/guests/index.d.ts +1 -1
  102. package/dist/blocks/hiring/index.d.ts +1 -1
  103. package/dist/blocks/identities/index.d.ts +1 -1
  104. package/dist/blocks/imports/index.d.ts +2 -2
  105. package/dist/blocks/inbox/index.d.ts +6 -6
  106. package/dist/blocks/incidents/index.d.ts +1 -1
  107. package/dist/blocks/index.d.ts +5 -5
  108. package/dist/blocks/index.js +2 -2
  109. package/dist/blocks/inspections/index.d.ts +2 -2
  110. package/dist/blocks/inventory/index.d.ts +1 -1
  111. package/dist/blocks/invoices/index.d.ts +2 -2
  112. package/dist/blocks/invoices/index.js +1 -1
  113. package/dist/blocks/knowledge/index.d.ts +1 -1
  114. package/dist/blocks/lead-scoring/index.d.ts +2 -2
  115. package/dist/blocks/learning/index.d.ts +3 -3
  116. package/dist/blocks/leases/index.d.ts +1 -1
  117. package/dist/blocks/leave/index.d.ts +1 -1
  118. package/dist/blocks/ledger/index.d.ts +1 -1
  119. package/dist/blocks/legal-entities/index.d.ts +2 -2
  120. package/dist/blocks/lims/index.d.ts +2 -2
  121. package/dist/blocks/mail-sync/index.d.ts +3 -3
  122. package/dist/blocks/maintenance/index.d.ts +2 -2
  123. package/dist/blocks/manufacturing/index.d.ts +2 -2
  124. package/dist/blocks/medications/index.d.ts +1 -1
  125. package/dist/blocks/meetings/index.d.ts +3 -3
  126. package/dist/blocks/memberships/index.d.ts +2 -2
  127. package/dist/blocks/memory/index.d.ts +1 -1
  128. package/dist/blocks/messaging/index.d.ts +5 -5
  129. package/dist/blocks/metrics/index.d.ts +1 -1
  130. package/dist/blocks/mfa/index.d.ts +2 -2
  131. package/dist/blocks/moderation/index.d.ts +2 -2
  132. package/dist/blocks/notifications/index.d.ts +5 -5
  133. package/dist/blocks/numbering/index.d.ts +1 -1
  134. package/dist/blocks/oauth-server/index.d.ts +1 -1
  135. package/dist/blocks/observations/index.d.ts +2 -2
  136. package/dist/blocks/onboarding/index.d.ts +2 -2
  137. package/dist/blocks/option-sets/index.d.ts +2 -2
  138. package/dist/blocks/orders/index.d.ts +1 -1
  139. package/dist/blocks/organizations/index.d.ts +2 -2
  140. package/dist/blocks/outbox/index.d.ts +1 -1
  141. package/dist/blocks/passes/index.d.ts +2 -2
  142. package/dist/blocks/payroll-export/index.d.ts +2 -2
  143. package/dist/blocks/people/index.d.ts +7 -7
  144. package/dist/blocks/periods/index.d.ts +1 -1
  145. package/dist/blocks/permissions/index.d.ts +3 -3
  146. package/dist/blocks/pipelines/index.d.ts +2 -2
  147. package/dist/blocks/posts/index.d.ts +2 -2
  148. package/dist/blocks/procurement/index.d.ts +5 -5
  149. package/dist/blocks/procurement/index.js +1 -1
  150. package/dist/blocks/profiles/index.d.ts +1 -1
  151. package/dist/blocks/projects/index.d.ts +7 -7
  152. package/dist/blocks/projects/index.js +2 -2
  153. package/dist/blocks/promotions/index.d.ts +1 -1
  154. package/dist/blocks/prompts/index.d.ts +1 -1
  155. package/dist/blocks/push/index.d.ts +2 -2
  156. package/dist/blocks/qualifications/index.d.ts +2 -2
  157. package/dist/blocks/queue/index.d.ts +2 -2
  158. package/dist/blocks/quotes/index.d.ts +1 -1
  159. package/dist/blocks/rank/index.d.ts +1 -1
  160. package/dist/blocks/reactions/index.d.ts +4 -4
  161. package/dist/blocks/recruiting/index.d.ts +4 -4
  162. package/dist/blocks/referrals/index.d.ts +1 -1
  163. package/dist/blocks/relations/index.d.ts +1 -1
  164. package/dist/blocks/reminders/index.d.ts +1 -1
  165. package/dist/blocks/reviews/index.d.ts +1 -1
  166. package/dist/blocks/rfqs/index.d.ts +2 -2
  167. package/dist/blocks/risks/index.d.ts +2 -2
  168. package/dist/blocks/saas/index.d.ts +12 -12
  169. package/dist/blocks/sales/index.d.ts +1 -1
  170. package/dist/blocks/sales/index.js +1 -1
  171. package/dist/blocks/saved-views/index.d.ts +3 -3
  172. package/dist/blocks/scheduling/index.d.ts +4 -4
  173. package/dist/blocks/scores/index.d.ts +2 -2
  174. package/dist/blocks/search/index.d.ts +3 -3
  175. package/dist/blocks/security-events/index.d.ts +1 -1
  176. package/dist/blocks/segments/index.d.ts +2 -2
  177. package/dist/blocks/sequences/index.d.ts +3 -3
  178. package/dist/blocks/service/index.d.ts +7 -7
  179. package/dist/blocks/service-accounts/index.d.ts +1 -1
  180. package/dist/blocks/sessions/index.d.ts +2 -2
  181. package/dist/blocks/settings/index.d.ts +2 -2
  182. package/dist/blocks/share-links/index.d.ts +1 -1
  183. package/dist/blocks/shifts/index.d.ts +2 -2
  184. package/dist/blocks/shipments/index.d.ts +1 -1
  185. package/dist/blocks/signatures/index.d.ts +2 -2
  186. package/dist/blocks/signing-keys/index.d.ts +1 -1
  187. package/dist/blocks/sla/index.d.ts +1 -1
  188. package/dist/blocks/sso/index.d.ts +1 -1
  189. package/dist/blocks/state-machine/index.d.ts +1 -1
  190. package/dist/blocks/subjects/index.d.ts +2 -2
  191. package/dist/blocks/support/index.d.ts +5 -5
  192. package/dist/blocks/tags/index.d.ts +2 -2
  193. package/dist/blocks/tasks/index.d.ts +2 -2
  194. package/dist/blocks/tax/index.d.ts +2 -2
  195. package/dist/blocks/teams/index.d.ts +1 -1
  196. package/dist/blocks/templates/index.d.ts +1 -1
  197. package/dist/blocks/tills/index.d.ts +1 -1
  198. package/dist/blocks/time-entries/index.d.ts +2 -2
  199. package/dist/blocks/timeline/index.d.ts +1 -1
  200. package/dist/blocks/trash/index.d.ts +1 -1
  201. package/dist/blocks/undo/index.d.ts +2 -2
  202. package/dist/blocks/updated-at/index.d.ts +2 -2
  203. package/dist/blocks/usage/index.d.ts +2 -2
  204. package/dist/blocks/vercel-marketplace/index.d.ts +1 -1
  205. package/dist/blocks/versions/index.d.ts +1 -1
  206. package/dist/blocks/waitlist/index.d.ts +1 -1
  207. package/dist/blocks/warehouse/index.d.ts +1 -1
  208. package/dist/blocks/warranty/index.d.ts +1 -1
  209. package/dist/blocks/webhooks/index.d.ts +2 -2
  210. package/dist/blocks/workflow-editor/index.d.ts +4 -4
  211. package/dist/blocks/workflows/index.d.ts +4 -4
  212. package/dist/{blocks-RVd7m590.d.ts → blocks-sDhFO8-h.d.ts} +4 -4
  213. package/dist/{build-Cb9yLxtS.js → build-QM0GdQ2B.js} +1 -1
  214. package/dist/{cache-tags-BxpxsCtq.d.ts → cache-tags-FrJaMalu.d.ts} +1 -1
  215. package/dist/claims/index.d.ts +4 -4
  216. package/dist/{claims-source-CXAtLZ9_.d.ts → claims-source-CeefCyGV.d.ts} +1 -1
  217. package/dist/cli/add-BBZULhs3.js +1 -0
  218. package/dist/cli/{add-dbBQf6Vy.js → add-OllEkXon.js} +11 -11
  219. package/dist/cli/{add-BQZyQh4f.js → add-djLR310z.js} +2 -2
  220. package/dist/cli/{app-table-files-CITEmvRS.js → app-table-files-DnoDAkVJ.js} +4 -4
  221. package/dist/cli/{app-tables-BBqu3dow.js → app-tables-C4shCkBv.js} +2 -2
  222. package/dist/cli/{backfill-bBk3QjfK.js → backfill-_spwSvnn.js} +3 -3
  223. package/dist/cli/bin.js +1 -1
  224. package/dist/cli/{blocks-D-DV2aCE.js → blocks-Cvs0nhC2.js} +1 -1
  225. package/dist/cli/{blocks-CsQNweG8.js → blocks-DFkzCFQi.js} +1 -1
  226. package/dist/cli/{cache-sR8AQqSV.js → cache-B0JnXfiY.js} +1 -1
  227. package/dist/cli/{codemod-BkPcyPnF.js → codemod-D2Lnca97.js} +6 -6
  228. package/dist/cli/{codemod-naming-BLoVSmVF.js → codemod-naming-CHIeOTt5.js} +1 -1
  229. package/dist/cli/{column-renames-brM-D_th.js → column-renames-4OHEvCAj.js} +2 -2
  230. package/dist/cli/{config-NxPVkM-K.js → config-DD_MnPRL.js} +1 -0
  231. package/dist/cli/{config-BGh7rJwA.js → config-DkjilxeE.js} +1 -1
  232. package/dist/cli/{content-mapper-DMi2HOKi.js → content-mapper-DAYxPQ18.js} +1 -1
  233. package/dist/cli/{db-od92zIrO.js → db-CEUnv3hK.js} +2 -2
  234. package/dist/cli/{dev-ClH-7fB0.js → dev-Xw7pt3KG.js} +5 -5
  235. package/dist/cli/{doctor-C_BEuEGg.js → doctor-diSKQp-6.js} +724 -32
  236. package/dist/cli/{emit-CTzFdffA.js → emit-CICey-Za.js} +2 -2
  237. package/dist/cli/{gen-RKf7q3L5.js → gen-BVuNFeLB.js} +5 -5
  238. package/dist/cli/{gen-tasks-DmDvgVBV.js → gen-tasks-C2vwKKTc.js} +11 -11
  239. package/dist/cli/index.d.ts +1 -1
  240. package/dist/cli/index.js +8 -8
  241. package/dist/cli/{init-B_CCByIh.js → init-9BSoBkny.js} +9 -9
  242. package/dist/cli/{live-DjjMID3V.js → live-Ce8vdcCn.js} +2 -2
  243. package/dist/cli/{mcp-BYwrZHp1.js → mcp-UW-gEnP_.js} +2 -2
  244. package/dist/cli/{memo-backend-BIHqP1uE.js → memo-backend-BMdfsihK.js} +1 -1
  245. package/dist/cli/{metadata-DCtLUYqR.js → metadata-DqrbS0sS.js} +4 -4
  246. package/dist/cli/{migrate-Bq6CUPbE.js → migrate-Cn8L_0co.js} +1 -1
  247. package/dist/cli/{migration-safety-BvJ-JK5n.js → migration-safety-C1Ysrthi.js} +2 -2
  248. package/dist/cli/{module-migration-Dv6VV1om.js → module-migration-DXI95fqs.js} +1 -1
  249. package/dist/cli/{partition-C4g7WAwh.js → partition-CJCrIueu.js} +3 -3
  250. package/dist/cli/{powersync-1HMiZhFF.js → powersync-CB-7AksZ.js} +4 -4
  251. package/dist/cli/powersync-JTdU1Xpy.js +1 -0
  252. package/dist/cli/{print-D9biMrfv.js → print-AVVgXsLG.js} +2 -2
  253. package/dist/cli/{providers-C5fw9XC_.js → providers-B3FLmlud.js} +1 -1
  254. package/dist/cli/{prune-workflows-DxpPCevB.js → prune-workflows-CrLDmFf1.js} +3 -3
  255. package/dist/cli/{remove-CyhSdPkK.js → remove-00SZWfyi.js} +6 -6
  256. package/dist/cli/{render-DOz25g5T.js → render-3J7sk_CL.js} +5 -5
  257. package/dist/cli/{render-cache-CInSNFhV.js → render-cache-P4gQeivH.js} +1 -1
  258. package/dist/cli/round-trips-BHfeIu6I.js +238 -0
  259. package/dist/cli/{run-DVdkD1MI.js → run-CByEIEng.js} +35 -35
  260. package/dist/cli/{run-0bMsZ1VV.js → run-D_z9ULO7.js} +7 -7
  261. package/dist/cli/seed-CucH5loT.js +1 -0
  262. package/dist/cli/{seed-DVKgi-7l.js → seed-CvDA1ItH.js} +2 -2
  263. package/dist/cli/{shared-D2i8_u-U.js → shared-d021xfdn.js} +1 -1
  264. package/dist/cli/{source-BGVOuWXq.js → source-DdqeWoO4.js} +1 -1
  265. package/dist/cli/{source-args-B3Rowfv5.js → source-args-yU6N6JLm.js} +1 -1
  266. package/dist/cli/{spec-COotILIk.js → spec-ClfqDbVv.js} +2 -2
  267. package/dist/cli/{spec-C_JKo_dP.js → spec-Diudl7hC.js} +1 -1
  268. package/dist/cli/{sql-layout-D8dIzdy9.js → sql-layout-Bl3iOXMS.js} +4 -4
  269. package/dist/cli/{squash-xCseaSP1.js → squash-C07y7CsQ.js} +1 -1
  270. package/dist/cli/{sync-Ceqa-3R6.js → sync-Cw0ke-3h.js} +4 -4
  271. package/dist/cli/{upgrade-CUNKALDw.js → upgrade-niwEovfl.js} +5 -5
  272. package/dist/cli/{upgrade-DiMHauEU.js → upgrade-oc6s5Xoe.js} +5 -5
  273. package/dist/cli/{verify-BFLaU6w3.js → verify-CrFHs8Lr.js} +2 -2
  274. package/dist/cli/{version-C7imaHag.js → version-Bd3kCDzL.js} +1 -1
  275. package/dist/client/index.d.ts +5 -5
  276. package/dist/client/index.js +1 -1
  277. package/dist/client/native/index.d.ts +5 -5
  278. package/dist/client/native/index.js +2 -2
  279. package/dist/{codec-Cjquuv8M.js → codec-BI1mq95W.js} +1 -1
  280. package/dist/{composite-CL4zDLjs.d.ts → composite-BVEOyec_.d.ts} +3 -3
  281. package/dist/{composite-DYAp3Znr.js → composite-Tsm5QFS2.js} +1 -1
  282. package/dist/{composite-reads-BJeDe1yV.js → composite-reads-BJJBI4tL.js} +1 -1
  283. package/dist/{composite-reads-B9psRGqQ.d.ts → composite-reads-DvN7EgDO.d.ts} +1 -1
  284. package/dist/config/index.d.ts +4 -4
  285. package/dist/config/index.js +2 -2
  286. package/dist/{config-DzPViWQU.js → config-cisS43w5.js} +2 -1
  287. package/dist/{context-DMBXEzQa.d.ts → context-C_Rx1QaW.d.ts} +4 -3
  288. package/dist/contract/index.d.ts +4 -4
  289. package/dist/{controller-CaZv50cD.d.ts → controller-D9N4NKbM.d.ts} +1 -1
  290. package/dist/{conversion-D2key0v9.d.ts → conversion-CruLbcu8.d.ts} +1 -1
  291. package/dist/create/index.d.ts +4 -4
  292. package/dist/create/index.js +1 -1
  293. package/dist/create/lite/index.d.ts +3 -3
  294. package/dist/create/lite/index.js +3 -3
  295. package/dist/{db-blocks-Db3LVXco.d.ts → db-blocks-DB8Ct8Eu.d.ts} +11 -2
  296. package/dist/{define-block-kWv1wYf7.d.ts → define-block-Cd7dm2o6.d.ts} +7 -2
  297. package/dist/{define-runtime-Dv8OYnKW.js → define-runtime-Ca5NN0gu.js} +2 -2
  298. package/dist/{define-runtime-full-Bh5c_01f.js → define-runtime-full-DeuaXsV7.js} +45 -38
  299. package/dist/{delete-account-BHXzIUIq.d.ts → delete-account-DwGFiIYv.d.ts} +1 -1
  300. package/dist/{drive-Bm-up0KU.d.ts → drive-C6thwExa.d.ts} +2 -2
  301. package/dist/e-invoicing/index.d.ts +1 -1
  302. package/dist/edge/index.d.ts +5 -5
  303. package/dist/edge/index.js +4 -4
  304. package/dist/{entitlements-UGUF2RJv.d.ts → entitlements-CR5HRd3S.d.ts} +2 -2
  305. package/dist/eve/index.d.ts +1 -1
  306. package/dist/eve/index.js +1 -1
  307. package/dist/{executor-B0nTn-4Q.js → executor-Bot0tkvU.js} +2 -2
  308. package/dist/{executor-Dp4A_McY.d.ts → executor-CTuilcgE.d.ts} +2 -2
  309. package/dist/expo/index.d.ts +2 -2
  310. package/dist/expo/index.js +3 -3
  311. package/dist/{extract-Bs_b4ZIX.d.ts → extract-B2My7IhT.d.ts} +1 -1
  312. package/dist/{extras-C258FsPj.d.ts → extras-CKwPSpGL.d.ts} +1 -1
  313. package/dist/{field-errors-BKCtkPxS.d.ts → field-errors-CihTLojJ.d.ts} +6 -6
  314. package/dist/{former-permission-keys-hL23tm66.js → former-permission-keys-D8FbWktT.js} +4 -3
  315. package/dist/{framework-C9UiMaOq.js → framework-BYZ8c9_g.js} +1 -1
  316. package/dist/{framework-BUzOnlJN.d.ts → framework-giXStk8k.d.ts} +3 -3
  317. package/dist/generators/factories/index.d.ts +1 -1
  318. package/dist/generators/factories/index.js +1 -1
  319. package/dist/generators/index.d.ts +2 -2
  320. package/dist/generators/json-schema/index.d.ts +2 -2
  321. package/dist/generators/json-schema/index.js +1 -1
  322. package/dist/generators/nuqs/index.d.ts +1 -1
  323. package/dist/generators/nuqs/index.js +1 -1
  324. package/dist/generators/standard-schema/index.d.ts +1 -1
  325. package/dist/generators/standard-schema/index.js +1 -1
  326. package/dist/generators/valibot/index.d.ts +1 -1
  327. package/dist/generators/valibot/index.js +1 -1
  328. package/dist/generators/zod/index.d.ts +1 -1
  329. package/dist/generators/zod/index.js +1 -1
  330. package/dist/hono/index.d.ts +4 -4
  331. package/dist/hono/index.js +3 -3
  332. package/dist/{index-CDCyOPT7.d.ts → index-28PPT5w7.d.ts} +2 -2
  333. package/dist/{index-nsEUHz98.d.ts → index-69aFw9Id.d.ts} +2 -2
  334. package/dist/{index-BtuseUSW.d.ts → index-74TASXlD.d.ts} +1 -1
  335. package/dist/{index-DOBq5QFe.d.ts → index-B0dSXth6.d.ts} +1 -1
  336. package/dist/{index-Mq2z-GgJ.d.ts → index-BOuJSOaf.d.ts} +1 -1
  337. package/dist/{index-DLVuARYk.d.ts → index-BnY5lZtT.d.ts} +9 -9
  338. package/dist/{index-rFIDpwjh.d.ts → index-BqUY2MB-.d.ts} +1 -1
  339. package/dist/{index-BG-WQ0JH.d.ts → index-BrnGYShi.d.ts} +2 -2
  340. package/dist/{index-BMh8ACKR.d.ts → index-Bs6OCtxW.d.ts} +1 -1
  341. package/dist/{index-CIVA5x1i.d.ts → index-BszN5nLs.d.ts} +2 -2
  342. package/dist/{index-CjeQqQzW.d.ts → index-Bv2kSYet.d.ts} +4 -4
  343. package/dist/{index-R_k3Nh4y.d.ts → index-BvRseRob.d.ts} +3 -3
  344. package/dist/{index-DIK12ZTb.d.ts → index-BvZ3uvj9.d.ts} +2 -2
  345. package/dist/{index-ClysJ8O-.d.ts → index-C1na2fiY.d.ts} +3 -3
  346. package/dist/{index-DgiSwhKf.d.ts → index-C59gKJBx.d.ts} +1 -1
  347. package/dist/{index-DcdC0Qll.d.ts → index-CGAcXNod.d.ts} +1 -1
  348. package/dist/{index-DWxio8F_.d.ts → index-CMyUugyW.d.ts} +8 -8
  349. package/dist/{index-BYx-ObF-.d.ts → index-CdoTvK2W.d.ts} +1 -1
  350. package/dist/{index-CkCuMFVG.d.ts → index-CiCmlbtu.d.ts} +1 -1
  351. package/dist/{index-B67YUNow.d.ts → index-CiLb3DTI.d.ts} +3 -3
  352. package/dist/{index-CzNRwKGG.d.ts → index-Cnc4wyTo.d.ts} +2 -2
  353. package/dist/{index-CDrLyU72.d.ts → index-Cpj79WyM.d.ts} +1 -1
  354. package/dist/{index-B6i7w-iS.d.ts → index-D50ulqMJ.d.ts} +1 -1
  355. package/dist/{index-48l12mNt.d.ts → index-D6px-XTD.d.ts} +2 -2
  356. package/dist/{index-DRKAMZV3.d.ts → index-DMHxmit5.d.ts} +4 -4
  357. package/dist/{index-BBf3nn7Y.d.ts → index-DflyfGR8.d.ts} +2 -2
  358. package/dist/{index-DebFs8qq.d.ts → index-DibtbiIW.d.ts} +1 -1
  359. package/dist/{index-B64DT6Io.d.ts → index-DpXMVE12.d.ts} +1 -1
  360. package/dist/{index-GamVr8VZ.d.ts → index-DsLMqyB5.d.ts} +1 -1
  361. package/dist/{index-C_DCvnW0.d.ts → index-DzUnwtxa.d.ts} +1 -1
  362. package/dist/{index-BZdSOt51.d.ts → index-Hzbfht3Z.d.ts} +1 -1
  363. package/dist/{index-bkm44ycq.d.ts → index-Sl13L6VB.d.ts} +4 -4
  364. package/dist/{index-DskEpSgl.d.ts → index-UQOB8v1I.d.ts} +1 -1
  365. package/dist/{index-CDxfstYD.d.ts → index-_No9Jb9O.d.ts} +1 -1
  366. package/dist/{index-icogJj2C.d.ts → index-cgHbN_EA.d.ts} +4 -4
  367. package/dist/{index-D2aht6Cz.d.ts → index-pry9PXpK.d.ts} +2 -2
  368. package/dist/{index-BJ1Mv0TK.d.ts → index-wc3-R_cK.d.ts} +1 -1
  369. package/dist/index.d.ts +2 -2
  370. package/dist/index.js +2 -2
  371. package/dist/{invoices-CWp9jcI2.d.ts → invoices-BXwG7Jwp.d.ts} +5 -0
  372. package/dist/{json-schema-CgwH39-G.js → json-schema-BveJfXoz.js} +1 -1
  373. package/dist/list/export/index.d.ts +1 -1
  374. package/dist/list/index.d.ts +1 -1
  375. package/dist/list/order/index.d.ts +2 -2
  376. package/dist/{list-query-qCpvTDGH.d.ts → list-query-CBjzZmjx.d.ts} +1 -1
  377. package/dist/{manifest-CD_ZA69x.d.ts → manifest-2JeNUq8t.d.ts} +1 -1
  378. package/dist/{manifest-9TRpR9P-.d.ts → manifest-3e0zfaQt.d.ts} +1 -1
  379. package/dist/{manifest-BXatXuLx.d.ts → manifest-3or1oZTo.d.ts} +1 -1
  380. package/dist/{manifest-mCn7RdZs.d.ts → manifest-AS4QwWdu.d.ts} +1 -1
  381. package/dist/{manifest-D02pP9Nl.d.ts → manifest-B1lYVfIp.d.ts} +1 -1
  382. package/dist/{manifest-dSiPcx5l.d.ts → manifest-B7xyFqWo.d.ts} +1 -1
  383. package/dist/{manifest-DF6GzdBC.d.ts → manifest-B9m_UaiY.d.ts} +1 -1
  384. package/dist/{manifest-BmGsyaxx.d.ts → manifest-B9qFGJ_A.d.ts} +1 -1
  385. package/dist/{manifest-CTEURHfF.d.ts → manifest-BSjzLeb-.d.ts} +1 -1
  386. package/dist/{manifest-BG2_hkzB.d.ts → manifest-BVn2Xglt.d.ts} +1 -1
  387. package/dist/{manifest-C1TwYhyr.d.ts → manifest-BWKFNoxP.d.ts} +1 -1
  388. package/dist/{manifest-DGrcTY4n.d.ts → manifest-BXWhDMFt.d.ts} +1 -1
  389. package/dist/{manifest-Cfrflbtt.d.ts → manifest-Bi44m1V3.d.ts} +1 -1
  390. package/dist/{manifest-Bsrn5gfq.d.ts → manifest-Bluupj7R.d.ts} +1 -1
  391. package/dist/{manifest-D32p1K-g.d.ts → manifest-Bo0SCigB.d.ts} +1 -1
  392. package/dist/{manifest-C3FjJnQT.d.ts → manifest-ByRLUGaJ.d.ts} +3 -3
  393. package/dist/{manifest-Cx_UVMlT.d.ts → manifest-C1--UMCz.d.ts} +1 -1
  394. package/dist/{manifest-BizfO8zf.d.ts → manifest-C20SXAzp.d.ts} +1 -1
  395. package/dist/{manifest-BKY6WHm6.d.ts → manifest-C40ISJVj.d.ts} +1 -1
  396. package/dist/{manifest-DBptC4dz.d.ts → manifest-C7KPtGTu.d.ts} +2 -2
  397. package/dist/{manifest-ChKRtAF6.d.ts → manifest-C82tY_RD.d.ts} +1 -1
  398. package/dist/{manifest-LAVlQXiw.d.ts → manifest-C94eugvl.d.ts} +1 -1
  399. package/dist/{manifest-tjlvcP1t.d.ts → manifest-CBdMkxZD.d.ts} +1 -1
  400. package/dist/{manifest-CxUI9ZXn.d.ts → manifest-CCPioFQl.d.ts} +1 -1
  401. package/dist/{manifest-BdV9GNAF.d.ts → manifest-CD5D0OWo.d.ts} +1 -1
  402. package/dist/{manifest-B91B3Yvk.d.ts → manifest-CGnN_2Yx.d.ts} +1 -1
  403. package/dist/{manifest-CpMVJWDU.d.ts → manifest-CH1MFzXN.d.ts} +1 -1
  404. package/dist/{manifest-BkJdR1D-.d.ts → manifest-CJRob2Ms.d.ts} +1 -1
  405. package/dist/{manifest-BdBaGzfE.d.ts → manifest-CgljOcHt.d.ts} +1 -1
  406. package/dist/{manifest-BSrdiUHP.d.ts → manifest-Ci7NEusH.d.ts} +1 -1
  407. package/dist/{manifest-gS-wx2yB.d.ts → manifest-CiXl1kUg.d.ts} +1 -1
  408. package/dist/{manifest-BNIvrs6_.d.ts → manifest-CjzIpyBP.d.ts} +2 -2
  409. package/dist/{manifest-B-wg2F2L.d.ts → manifest-ClDcyCPP.d.ts} +3 -3
  410. package/dist/{manifest-CIa0-uCj.d.ts → manifest-Co0CBReD.d.ts} +1 -1
  411. package/dist/{manifest-CPlmHPRY.d.ts → manifest-CpmJIEt7.d.ts} +1 -1
  412. package/dist/{manifest-DAv6iO-q.d.ts → manifest-Cqv6c1KN.d.ts} +1 -1
  413. package/dist/{manifest-BOxu_JMd.d.ts → manifest-CtUKrkx1.d.ts} +1 -1
  414. package/dist/{manifest-C7bh84U0.d.ts → manifest-D1FPczc-.d.ts} +1 -1
  415. package/dist/{manifest-VjVVI7bV.d.ts → manifest-D43yma-v.d.ts} +1 -1
  416. package/dist/{manifest-B7IYj4OA.d.ts → manifest-DAF4J0gk.d.ts} +1 -1
  417. package/dist/{manifest-BSSoVDlI.d.ts → manifest-DGoI006V.d.ts} +1 -1
  418. package/dist/{manifest-Ce_JDK4r.d.ts → manifest-DHN6WiIJ.d.ts} +1 -1
  419. package/dist/{manifest-C7CtYgWC.d.ts → manifest-DIl_cNua.d.ts} +1 -1
  420. package/dist/{manifest-BWE_47qq.d.ts → manifest-DJhjOnvk.d.ts} +1 -1
  421. package/dist/{manifest-Cn85_kP6.d.ts → manifest-DMhuQgOx.d.ts} +1 -1
  422. package/dist/{manifest-1P6OEAwH.d.ts → manifest-DQkz9UVy.d.ts} +1 -1
  423. package/dist/{manifest-Cz8poTZ2.d.ts → manifest-DUZUtWBi.d.ts} +1 -1
  424. package/dist/{manifest-BVwoT7GU.d.ts → manifest-DY2KtVcD.d.ts} +1 -1
  425. package/dist/{manifest-Dc_FWIrg.d.ts → manifest-DaB1w2xo.d.ts} +1 -1
  426. package/dist/{manifest-DZc_37YJ.d.ts → manifest-DpXgCZEd.d.ts} +1 -1
  427. package/dist/{manifest-BcqqAgm9.d.ts → manifest-Dqf2Uw17.d.ts} +1 -1
  428. package/dist/{manifest-D5aZyD1b.js → manifest-OxHBbWrs.js} +1 -1
  429. package/dist/{manifest-khfEDzX4.d.ts → manifest-Utivc7Qa.d.ts} +1 -1
  430. package/dist/{manifest-t9v09kRa.d.ts → manifest-WJ-UHuEx.d.ts} +1 -1
  431. package/dist/{manifest-BNCX3M2Y.d.ts → manifest-WpIMAJCT.d.ts} +1 -1
  432. package/dist/{manifest-Cle7S3sn.d.ts → manifest-at0NS8cT.d.ts} +1 -1
  433. package/dist/{manifest-D4iEPtlb.d.ts → manifest-d7vR6coE.d.ts} +2 -2
  434. package/dist/{manifest-BN2J8Zo7.d.ts → manifest-gl856Z9G.d.ts} +1 -1
  435. package/dist/{manifest-DcnVXlH7.d.ts → manifest-iGmnzfGD.d.ts} +1 -1
  436. package/dist/{manifest-BWFemJ6Q.d.ts → manifest-j4_V-qhA.d.ts} +1 -1
  437. package/dist/{manifest-blSYzmEZ.d.ts → manifest-mAxLRfeu.d.ts} +1 -1
  438. package/dist/{manifest-zEA2Tw_l.d.ts → manifest-mBKFNynL.d.ts} +1 -1
  439. package/dist/{manifest-SoNChfLL.d.ts → manifest-wPIH-Oo7.d.ts} +1 -1
  440. package/dist/{manifest-Djy3wcSo.js → manifest-waO9DHVc.js} +1 -0
  441. package/dist/mapper/bin.js +6 -6
  442. package/dist/mcp/index.d.ts +2 -2
  443. package/dist/mcp/index.js +1 -1
  444. package/dist/mcp/sdk/index.d.ts +2 -2
  445. package/dist/mcp/sdk/index.js +1 -1
  446. package/dist/{mcp-CoJbu0Hk.js → mcp-mSD-ic9W.js} +3 -3
  447. package/dist/next/index.d.ts +12 -12
  448. package/dist/next/index.js +10 -5
  449. package/dist/next/proxy/index.d.ts +3 -3
  450. package/dist/{operations-nnC3pvwn.d.ts → operations-dIOdHqYz.d.ts} +1 -1
  451. package/dist/orpc/index.d.ts +4 -4
  452. package/dist/orpc/index.js +2 -2
  453. package/dist/otel/index.js +5 -5
  454. package/dist/{permissions-Ccvec0MR.d.ts → permissions-DG0t2lrA.d.ts} +1 -1
  455. package/dist/{ports-CfVACwW_.d.ts → ports-CfiOCL2r.d.ts} +1 -1
  456. package/dist/{ports-DfDzwMCR.js → ports-DR88RF0N.js} +2 -2
  457. package/dist/powersync/index.d.ts +3 -3
  458. package/dist/powersync/index.js +1 -1
  459. package/dist/preset/index.d.ts +4 -4
  460. package/dist/{preview-CR1nZ6-E.d.ts → preview-3nes4WG4.d.ts} +2 -2
  461. package/dist/{project-CxoixIpG.js → project-CXcoauzs.js} +2 -2
  462. package/dist/{push-token-Rv1CxW_N.d.ts → push-token-CRBieazN.d.ts} +1 -1
  463. package/dist/query/index.d.ts +1 -1
  464. package/dist/react/index.d.ts +5 -5
  465. package/dist/react/native/index.d.ts +1 -1
  466. package/dist/react/server.d.ts +6 -6
  467. package/dist/react-router/index.d.ts +3 -3
  468. package/dist/react-router/index.js +3 -3
  469. package/dist/{read-set-BptYceHc.js → read-set-DfScfSsf.js} +3 -2
  470. package/dist/realtime/index.d.ts +3 -3
  471. package/dist/{record-form-mpamIVq3.d.ts → record-form-BggNAKZA.d.ts} +1 -1
  472. package/dist/records/index.d.ts +7 -7
  473. package/dist/{resource-execute-Bb-zKYUc.d.ts → resource-execute-BIqAzA57.d.ts} +1 -1
  474. package/dist/{resource-types-C8kdoZ-J.d.ts → resource-types-DcEe07vC.d.ts} +1 -1
  475. package/dist/{resources-B9dfA1jH.d.ts → resources-Bb_JRadM.d.ts} +1 -1
  476. package/dist/{sales-D_yZoFUU.js → sales-CIe7dE4J.js} +1 -1
  477. package/dist/server/account/index.d.ts +2 -2
  478. package/dist/server/accounts/index.d.ts +1 -1
  479. package/dist/server/index.d.ts +12 -12
  480. package/dist/server/index.js +4 -4
  481. package/dist/{server-CqRpnOo0.js → server-DA5SRGHQ.js} +2 -2
  482. package/dist/{server-types-C8zErBy9.d.ts → server-types-Cp2en4rP.d.ts} +2 -2
  483. package/dist/{session-DRn_URq0.d.ts → session-Bro3jmnu.d.ts} +1 -1
  484. package/dist/{sign-in-CMEBFv36.d.ts → sign-in-Cj7Y0mSU.d.ts} +11 -11
  485. package/dist/solid/index.d.ts +6 -6
  486. package/dist/solid-start/index.d.ts +3 -3
  487. package/dist/solid-start/index.js +3 -3
  488. package/dist/spec/index.d.ts +1 -1
  489. package/dist/spec/index.js +2 -2
  490. package/dist/sql/index.d.ts +5 -5
  491. package/dist/sql/index.js +1 -1
  492. package/dist/{sql-ZLYXNvXw.js → sql-BwfPwN8v.js} +304 -95
  493. package/dist/sqlite/index.d.ts +1 -1
  494. package/dist/sqlite/index.js +1 -1
  495. package/dist/ssr/index.d.ts +1 -1
  496. package/dist/svelte/index.d.ts +6 -6
  497. package/dist/sveltekit/index.d.ts +4 -4
  498. package/dist/sveltekit/index.js +3 -3
  499. package/dist/{tags-Bh4zXrnl.d.ts → tags-C7NyJTdU.d.ts} +1 -1
  500. package/dist/tanstack-db/index.d.ts +1 -1
  501. package/dist/tanstack-start/index.d.ts +3 -3
  502. package/dist/tanstack-start/index.js +3 -3
  503. package/dist/{tenant-DpJTJr1c.d.ts → tenant-BFABaxQ5.d.ts} +1 -1
  504. package/dist/testing/index.d.ts +9 -9
  505. package/dist/testing/index.js +4 -4
  506. package/dist/{timeline-CGjiciIY.d.ts → timeline-0a7kclhg.d.ts} +3 -3
  507. package/dist/{topic-R7kIJ_xI.d.ts → topic-BH4L7H8n.d.ts} +2 -2
  508. package/dist/{types-BidEA6pZ.d.ts → types-BMLgTFzf.d.ts} +2 -2
  509. package/dist/{verify-BfcOHiUP.d.ts → verify-tK2F49Gn.d.ts} +1 -1
  510. package/dist/{version-DRVVrk-u.js → version-BHgdHcZN.js} +1 -1
  511. package/dist/vue/index.d.ts +6 -6
  512. package/dist/{watch-topic-D18gT7-K.d.ts → watch-topic-BYfSlldk.d.ts} +1 -1
  513. package/dist/webmcp/index.d.ts +1 -1
  514. package/dist/webmcp/index.js +1 -1
  515. package/dist/yjs/index.d.ts +1 -1
  516. package/package.json +1 -1
  517. package/schemas/config-v1.json +3 -0
  518. package/schemas/doctor-report-v1.json +2 -0
  519. package/dist/cli/add-DHvo6zQZ.js +0 -1
  520. package/dist/cli/powersync-DLUNuNl4.js +0 -1
  521. package/dist/cli/round-trips-D2KD5Hpq.js +0 -56
  522. package/dist/cli/seed-Dlm5jjPn.js +0 -1
@@ -1,5 +1,5 @@
1
- import { d as subjectFromTag, l as stdinDatabaseUrl, n as databaseUrl, u as withTableTags } from "./config-NxPVkM-K.js";
2
- import { a as hasContentMapper, c as supportsContentMappers, i as contentMapperSetup$1, n as TSCONFIG_SNIPPET, o as needsRunExternalCode, t as RUN_EXTERNAL_CODE } from "./content-mapper-DMi2HOKi.js";
1
+ import { d as subjectFromTag, l as stdinDatabaseUrl, n as databaseUrl, u as withTableTags } from "./config-DD_MnPRL.js";
2
+ import { a as hasContentMapper, c as supportsContentMappers, i as contentMapperSetup$1, n as TSCONFIG_SNIPPET, o as needsRunExternalCode, t as RUN_EXTERNAL_CODE } from "./content-mapper-DAYxPQ18.js";
3
3
  import { i as isLocalDatabaseUrl, r as databaseHost } from "./agent-BlYLJPzM.js";
4
4
  import { a as list, m as commandMeta, r as defineCliCommand } from "./command-fqvJ0TdG.js";
5
5
  import { n as CliError, r as errorText } from "./errors-B7i-VGxk.js";
@@ -7,37 +7,37 @@ import { c as insideRoot, i as changeLines, r as applyPlan } from "./files-NnXna
7
7
  import { a as sameText, t as display } from "./io-CngfGyMA.js";
8
8
  import { t as connect } from "./db-B_xr3ZvK.js";
9
9
  import { t as byCodePoint } from "./compare-yl4sSwVn.js";
10
- import { C as dataFiles, D as sourceFiles, E as seedFiles, H as installedVersion, O as sqlFiles, S as ENV_FILES, T as readText, U as peerVersions, W as satisfies, _ as liteDriverOf, a as moduleLayoutFor, d as loadSnapshot, f as managementTarget, g as snapshotFile, i as migrationsDir, j as MetadataRejectedError, p as openSource, r as blockDeclaredTables, u as writtenByBlocks, v as isSqliteLiteDriver, w as functionFiles } from "./sql-layout-D8dIzdy9.js";
11
- import { i as request } from "./source-BGVOuWXq.js";
10
+ import { C as dataFiles, D as sourceFiles, E as seedFiles, H as installedVersion, O as sqlFiles, S as ENV_FILES, T as readText, U as peerVersions, W as satisfies, _ as liteDriverOf, a as moduleLayoutFor, d as loadSnapshot, f as managementTarget, g as snapshotFile, i as migrationsDir, j as MetadataRejectedError, p as openSource, r as blockDeclaredTables, u as writtenByBlocks, v as isSqliteLiteDriver, w as functionFiles } from "./sql-layout-Bl3iOXMS.js";
11
+ import { i as request } from "./source-DdqeWoO4.js";
12
12
  import { a as findRepoRoot, c as httpHooks, d as readSupabaseToml, h as tomlGet, i as diffEngine, l as migrationCommand, n as declarativeSchemasDir, p as sqlWorkflow, u as pgFunctionHooks } from "./supabase-toml-B6-eEV5p.js";
13
13
  import { r as supabaseCli } from "./exec-DBgtTCHK.js";
14
14
  import { t as CACHE_DIR } from "./store-DP-nmqBt.js";
15
- import { _ as BLOCK_PREFIX, a as METADATA_GAPS_TEXT, b as splinterTables, c as entitlementsModule, d as appliesTo, f as escape$7, g as withoutStrings, h as policyHelpers, l as COMMANDS$2, m as functionObject, p as functionBody, s as AUTHORIZATION_RULES, u as RLS_RULES, v as blockTargets, y as advisorRule } from "./run-0bMsZ1VV.js";
16
- import { r as renderFiles } from "./render-DOz25g5T.js";
17
- import { l as schemaModulePath, m as configFor, p as notNullTag } from "./emit-CTzFdffA.js";
15
+ import { _ as BLOCK_PREFIX, a as METADATA_GAPS_TEXT, b as splinterTables, c as entitlementsModule, d as appliesTo, f as escape$7, g as withoutStrings, h as policyHelpers, l as COMMANDS$2, m as functionObject, p as functionBody, s as AUTHORIZATION_RULES, u as RLS_RULES, v as blockTargets, y as advisorRule } from "./run-D_z9ULO7.js";
16
+ import { r as renderFiles } from "./render-3J7sk_CL.js";
17
+ import { l as schemaModulePath, m as configFor, p as notNullTag } from "./emit-CICey-Za.js";
18
18
  import { t as orphanedBlockFiles } from "./orphans-ByB0gKOp.js";
19
- import { a as renameArguments, s as tenantEntries, t as NAMING_RENAMES } from "./codemod-naming-BLoVSmVF.js";
19
+ import { a as renameArguments, s as tenantEntries, t as NAMING_RENAMES } from "./codemod-naming-CHIeOTt5.js";
20
20
  import { t as isRecord$1 } from "./guards-DxwRG0Uv.js";
21
- import { i as appViewsOf, n as adoptionContext, r as appTablesOf, t as accessModule } from "./app-tables-BBqu3dow.js";
22
- import { i as migrationHolds, o as migrationModules, r as latestMigration, t as MODULES_SUFFIX } from "./module-migration-Dv6VV1om.js";
23
- import { n as renderBlocksCached } from "./render-cache-CInSNFhV.js";
24
- import { a as lineOf, c as qualified, i as exposedSchemas, l as tableObject, n as deniesAll, o as permissionCatalogKeys, r as exposed, s as policyObject, t as catalogOf, u as workflowOf } from "./shared-D2i8_u-U.js";
25
- import { n as staleRenameKeys, t as shadowedBlockColumns } from "./column-renames-brM-D_th.js";
26
- import { a as reservedRoles, i as statementsView, n as ident$1, r as literal$1, t as LIVE_RULES } from "./live-DjjMID3V.js";
21
+ import { i as appViewsOf, n as adoptionContext, r as appTablesOf, t as accessModule } from "./app-tables-C4shCkBv.js";
22
+ import { i as migrationHolds, o as migrationModules, r as latestMigration, t as MODULES_SUFFIX } from "./module-migration-DXI95fqs.js";
23
+ import { n as renderBlocksCached } from "./render-cache-P4gQeivH.js";
24
+ import { a as lineOf, c as qualified, i as exposedSchemas, l as tableObject, n as deniesAll, o as permissionCatalogKeys, r as exposed, s as policyObject, t as catalogOf, u as workflowOf } from "./shared-d021xfdn.js";
25
+ import { n as staleRenameKeys, t as shadowedBlockColumns } from "./column-renames-4OHEvCAj.js";
26
+ import { a as reservedRoles, i as statementsView, n as ident$1, r as literal$1, t as LIVE_RULES } from "./live-Ce8vdcCn.js";
27
27
  import { t as projectionsOf } from "./projection-DlVB5YL-.js";
28
28
  import { s as providerLabel } from "./authorization-CNWhpdKb.js";
29
- import { t as VERSION$1 } from "./version-C7imaHag.js";
29
+ import { t as VERSION$1 } from "./version-Bd3kCDzL.js";
30
30
  import { t as PROCESS_ENV } from "./env-CQ831uY0.js";
31
31
  import { a as stackEnvValues, i as redactValue, o as staleVariables, t as PREFIX_NAMES } from "./stack-env-CtkfVXsR.js";
32
32
  import { n as readStackStatus } from "./stack-status-rNPCacin.js";
33
- import { o as wiringFor, r as configInstances, t as MIGRATION_SAFETY_RULES } from "./migration-safety-BvJ-JK5n.js";
33
+ import { o as wiringFor, r as configInstances, t as MIGRATION_SAFETY_RULES } from "./migration-safety-C1Ysrthi.js";
34
+ import { a as OPEN, c as functionsIn, i as CLOSE, l as statementEnd, n as ROUND_TRIP_RULES, o as closeOf, s as codeOnly, u as targetKeys } from "./round-trips-BHfeIu6I.js";
34
35
  import { n as PLATFORM_SCHEMAS } from "./in-stack-diff-3e1LT1bn.js";
35
- import { n as ROUND_TRIP_RULES } from "./round-trips-D2KD5Hpq.js";
36
36
  import { a as readSharedMemory, n as listStacks, t as branchName } from "./stacks-Eu6d45F8.js";
37
37
  import { i as plain$2 } from "./style-B5-nByxb.js";
38
- import { i as refuseWithMetadata, r as readMetadataSnapshot } from "./metadata-DCtLUYqR.js";
38
+ import { i as refuseWithMetadata, r as readMetadataSnapshot } from "./metadata-DqrbS0sS.js";
39
39
  import { t as compiledReadSets } from "./read-sets-77o7SxpK.js";
40
- import { a as sourceFlags, n as SOURCE_ARGS } from "./source-args-B3Rowfv5.js";
40
+ import { a as sourceFlags, n as SOURCE_ARGS } from "./source-args-yU6N6JLm.js";
41
41
  import { existsSync } from "node:fs";
42
42
  import { dirname, join, posix, relative, resolve } from "node:path";
43
43
  import { mkdir, readFile, writeFile } from "node:fs/promises";
@@ -1212,7 +1212,7 @@ const AUTH_USER_RULES = [{
1212
1212
  })))
1213
1213
  }];
1214
1214
  // src/cli/doctor/projections.ts
1215
- const HELPER_CALL = new RegExp(String.raw`\b(${[
1215
+ const HELPER_CALL$1 = new RegExp(String.raw`\b(${[
1216
1216
  "createNativeClient",
1217
1217
  "powersyncEngine",
1218
1218
  "attachmentQueueRoute",
@@ -1273,7 +1273,7 @@ const PROJECTION_RULES = [{
1273
1273
  check(context) {
1274
1274
  const projections = projectedBlockTables(context);
1275
1275
  if (projections.length === 0) return [];
1276
- return context.sources.flatMap((file) => [...file.text.matchAll(HELPER_CALL)].flatMap((call) => {
1276
+ return context.sources.flatMap((file) => [...file.text.matchAll(HELPER_CALL$1)].flatMap((call) => {
1277
1277
  const args = argumentsOf(file.text, call.index + call[0].length - 1);
1278
1278
  return projections.flatMap(({ base, view }) => {
1279
1279
  const name = base.slice(base.indexOf(".") + 1);
@@ -1369,7 +1369,7 @@ function writtenTable(owned, schema, name) {
1369
1369
  function blockClientKeys(context) {
1370
1370
  return new Set(context.config.blockNames.flatMap((name) => [name, name.replaceAll(/-([a-z0-9])/g, (_, char) => char.toUpperCase())]));
1371
1371
  }
1372
- function writesIn(text, owned, clients) {
1372
+ function writesIn$1(text, owned, clients) {
1373
1373
  const direct = [...text.matchAll(DIRECT_WRITE)].flatMap((match) => {
1374
1374
  const [, schema, name = "", method = ""] = match;
1375
1375
  const entry = writtenTable(owned, schema, name);
@@ -1401,7 +1401,7 @@ function directBlockWrites(context) {
1401
1401
  const owned = ownedTables(context);
1402
1402
  if (owned.qualified.size === 0) return [];
1403
1403
  const clients = blockClientKeys(context);
1404
- return context.sources.flatMap((file) => writesIn(file.text, owned, clients).map(({ index, method, entry }) => {
1404
+ return context.sources.flatMap((file) => writesIn$1(file.text, owned, clients).map(({ index, method, entry }) => {
1405
1405
  const line = lineAt$1(file.text, index);
1406
1406
  return {
1407
1407
  message: `${file.path}:${String(line)} calls .${method}() on ${entry.view === void 0 ? "" : `${entry.view}, the app's view over `}${entry.table.table}, the ${entry.logical} table of blocks.${entry.block}. A direct write skips the block's functions, so its events, hooks and checks don't run. Write it through the ${entry.block} API that createBlocks returns.`,
@@ -2501,7 +2501,7 @@ const IMPORT_GUARD_RULES = [{
2501
2501
  }
2502
2502
  }];
2503
2503
  // src/cli/doctor/lite.ts
2504
- const RPC_CALL = /(?:\.|\$)rpc\s*\(|\brpcTransport\s*\(/;
2504
+ const RPC_CALL$1 = /(?:\.|\$)rpc\s*\(|\brpcTransport\s*\(/;
2505
2505
  const MISSING_FEATURES = [{
2506
2506
  feature: "Realtime",
2507
2507
  pattern: /from\s+["']better-supabase\/realtime["']|\.channel\s*\(|\.removeChannel\s*\(/
@@ -2524,7 +2524,7 @@ function rpcOnSqlite(context) {
2524
2524
  const driver = liteDriver(context);
2525
2525
  if (driver === void 0 || !isSqliteLiteDriver(driver)) return [];
2526
2526
  return context.sources.flatMap((file) => {
2527
- const line = lineOf(file.text, RPC_CALL);
2527
+ const line = lineOf(file.text, RPC_CALL$1);
2528
2528
  if (line === void 0) return [];
2529
2529
  return [{
2530
2530
  message: `${file.path} calls a Postgres function, but Supabase Lite's ${driver} driver has no rpc(), so the call returns an unsupported error. Switch [db] driver to "pglite" or "postgres" in supabase/config.toml, or replace the function with table queries.`,
@@ -2734,7 +2734,7 @@ const OLD_NAMES = NAMING_RENAMES.filter((rename) => SOURCE_KINDS.has(rename.kind
2734
2734
  pattern: new RegExp(rename.kind === "subpath" ? `better-supabase/${escaped(rename.from)}(?![\\w-])` : `(?<![A-Za-z0-9_])${escaped(rename.from)}(?![A-Za-z0-9_])`)
2735
2735
  }));
2736
2736
  const isRecord = (value) => typeof value === "object" && value !== null;
2737
- const camel$1 = (name) => name.replaceAll(/[_-]+([a-z0-9])/g, (_, letter) => letter.toUpperCase());
2737
+ const camel$2 = (name) => name.replaceAll(/[_-]+([a-z0-9])/g, (_, letter) => letter.toUpperCase());
2738
2738
  /**
2739
2739
  * The argument names of verbs on an entity the config renamed: an app whose
2740
2740
  * `names.<entity>.name` is `work_item` keeps `workItemId` and `workItemIds`.
@@ -2742,7 +2742,7 @@ const camel$1 = (name) => name.replaceAll(/[_-]+([a-z0-9])/g, (_, letter) => let
2742
2742
  function renamedEntityArguments(blocks) {
2743
2743
  const kept = /* @__PURE__ */ new Set();
2744
2744
  const keep = (name) => {
2745
- if (typeof name === "string") kept.add(`${camel$1(name)}Id`).add(`${camel$1(name)}Ids`);
2745
+ if (typeof name === "string") kept.add(`${camel$2(name)}Id`).add(`${camel$2(name)}Ids`);
2746
2746
  };
2747
2747
  for (const block of Object.values(blocks)) {
2748
2748
  if (!isRecord(block)) continue;
@@ -3829,6 +3829,669 @@ function aal2WithoutMfa(context) {
3829
3829
  }
3830
3830
  }];
3831
3831
  }
3832
+ // src/cli/doctor/n-plus-one.ts
3833
+ /**
3834
+ * A receiver that names the better-supabase client: `db`, `ctx.db`, `tx`,
3835
+ * `bsb.db()`.
3836
+ */
3837
+ const DB = String.raw`(?<![\w$])(?:db|[a-z][\w$]*Db|tx|trx)(?:\(\))?`;
3838
+ const REPOSITORY_READ = new RegExp(String.raw`${DB}\s*\.\s*([A-Za-z_][\w$]*)\s*\.\s*(get|list|page|count|counted|aggregate|first|find[A-Z]?[\w$]*)\s*\(`, "g");
3839
+ const BLOCK_CALL = new RegExp(String.raw`(?:${DB}\s*\.\s*\$blocks|(?<![\w$])blocks)\s*\.\s*[\w$]+\s*\.\s*([\w$]+)\s*\(`, "g");
3840
+ const RPC_CALL = /\.\s*\$(?:rpc|search|run|many)\s*\(|(?<![\w$])[\w$]*supabase[\w$]*\s*\.\s*rpc\s*\(/gi;
3841
+ const FROM_SELECT = /\.\s*from\s*\(([\w$.\s]*)\)\s*\.\s*select\s*\(/g;
3842
+ const SERVICE_READ = /(?<![\w$])([\w$]+)\s*\.\s*((?:get|list|load|find|fetch|count|read|search)[A-Z][\w$]*)\s*\(/g;
3843
+ const SERVICE_WRITE = /(?<![\w$])([\w$]+)\s*\.\s*([a-z][\w$]*)\s*\(/g;
3844
+ const SERVICE_NAME = /(?:services?|repositor(?:y|ies)|repos?|queries|readers?)$/i;
3845
+ const SERVICE_FACTORY = /(?:const|let)\s+(\{[^}]*\}|[\w$]+)\s*=\s*(?:await\s+)?create[\w$]*(?:Services?|Repositor(?:y|ies)|Repos?)\s*\(/g;
3846
+ /** A block method or a local function whose name says it writes. */
3847
+ const WRITE_NAME = /^(?:create|insert|update|upsert|delete|remove|set|add|save|send|enqueue|record|mark|approve|reject|cancel|archive|restore|move|assign|unassign|post|submit|publish|attach|detach|link|unlink|invite|revoke|grant|start|stop|complete|close|open|lock|unlock|apply|import|sync|refresh|recompute|merge|reorder|rename|toggle|track|emit|notify|write|put|patch|claim|release|issue|void|pay|charge|refund|transfer|book|confirm|accept|decline|resolve|reopen|pin|unpin|join|leave|subscribe|unsubscribe|upload|clear|reset|seed|ensure|process|run|execute|handle|dispatch|schedule|retry|replace|increment|decrement|bump|touch|finalize|commit|enable|disable|activate|deactivate|generate|log|accrue|decide|escalate|expire|deliver|broadcast|transition|advance|convert|clone|duplicate|copy|share|sign|invalidate|revalidate)(?:[A-Z_\d]|$)/;
3848
+ const REPOSITORY_WRITE = new RegExp(String.raw`${DB}\s*\.\s*[A-Za-z_][\w$]*\s*\.\s*(?:create|update|upsert|delete)\s*\(|\.\s*from\s*\([\w$.\s]*\)\s*\.\s*(?:insert|update|upsert|delete)\s*\(`);
3849
+ /**
3850
+ * A call whose name says it has a side effect, such as `notifyAgendaUpdated(`
3851
+ * or `events.publish(`: a loop that makes one per item is not a read pattern.
3852
+ */
3853
+ const SIDE_EFFECT_CALL = /(?<![\w$])(?:notify|publish|send|emit|enqueue|dispatch|broadcast|deliver|revalidate)(?:[A-Z_][\w$]*)?\s*\(/g;
3854
+ /** A parameter or field typed as a service: `customers: CustomersService`. */
3855
+ const SERVICE_TYPED = /(?<![\w$.])([\w$]+)\s*\??\s*:\s*(?:Readonly<\s*)?[\w$.]*(?:Services?|Repositor(?:y|ies)|Repos?|Queries)\b(?!\s*[<[.])/g;
3856
+ /**
3857
+ * A helper that runs a callback per item: `mapInChunks(ids, 20, async (id) =>
3858
+ * ...)`, `pMap(ids, (id) => ...)`.
3859
+ */
3860
+ const HELPER_CALL = /(?<![\w$.])(?<!new\s+)([A-Za-z_$][\w$]*)\s*(?:<[^>()]*>)?\s*\(/g;
3861
+ const HELPER_NAME = /map|each|chunk|batch|concurren|parallel|limit/i;
3862
+ /** Filters an `in` list can't batch: text search and JSON containment. */
3863
+ const SEARCH_FILTER = /(?<![\w$])(contains|containedBy|ilike|iLike|like|startsWith|endsWith|search|q|query|textSearch|match|fts)\s*([:(])/g;
3864
+ const LOCAL_FUNCTION = /(?:function\s*\*?\s*([\w$]+)\s*(?:<[^>]*>)?\s*\(|(?:const|let)\s+([\w$]+)\s*(?::[^=]+)?=\s*(?:async\s+)?(?:function\b[^(]*\(|\(|[\w$]+\s*=>))/g;
3865
+ const WAVE = /\bPromise\.all\s*\(\s*\[/g;
3866
+ const LOOP = /(?<![\w$.])for\s*(?:await\s*)?\(/g;
3867
+ const CALLBACK = /\.\s*(?:map|flatMap|forEach)\s*\(/g;
3868
+ const DECLARATION = /(?<![\w$.])(?:const|let|var)\s+([\w$]+|\{[^=;]*?\}|\[[^=;]*?\])\s*(?::[^=;]+)?=(?!=|>)/g;
3869
+ /**
3870
+ * Loop variables that are already batches, or retries of one read: `for (const
3871
+ * chunk of chunks)`, `for (const attempt of attempts)`. `chunk.map((id) =>
3872
+ * ...)` still runs once per item.
3873
+ */
3874
+ const BATCHES = /chunk|batch|attempt|retr/i;
3875
+ /** Iterables of batches or retries, whatever the loop variable is called. */
3876
+ const BATCH_ITEMS = /(?:chunks|batches)\b|chunked|attempt|retr/i;
3877
+ /** The names a binding pattern declares: `x`, `{ a, b: c }`, `[d, ...e]`. */
3878
+ function boundNames(pattern) {
3879
+ const trimmed = pattern.trim();
3880
+ if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) return /^[\w$]+$/.test(trimmed) ? [trimmed] : [];
3881
+ return [...trimmed.matchAll(/[A-Za-z_$][\w$]*(?!\s*:)/g)].filter((match) => trimmed.charAt(match.index - 1) !== ".").map((match) => match[0]);
3882
+ }
3883
+ /** The bound names of a parameter list, without types and defaults. */
3884
+ function parameterNames(list) {
3885
+ const names = [];
3886
+ let depth = 0;
3887
+ let start = 0;
3888
+ const take = (part) => {
3889
+ let inner = 0;
3890
+ let end = part.length;
3891
+ for (let index = 0; index < part.length; index += 1) {
3892
+ const char = part.charAt(index);
3893
+ inner += OPEN.has(char) ? 1 : CLOSE.has(char) ? -1 : 0;
3894
+ if (inner === 0 && (char === ":" || char === "=")) {
3895
+ end = index;
3896
+ break;
3897
+ }
3898
+ }
3899
+ names.push(...boundNames(part.slice(0, end).replace(/^\s*\.\.\./, "")));
3900
+ };
3901
+ for (let index = 0; index < list.length; index += 1) {
3902
+ const char = list.charAt(index);
3903
+ depth += OPEN.has(char) ? 1 : CLOSE.has(char) ? -1 : 0;
3904
+ if (char === "," && depth === 0) {
3905
+ take(list.slice(start, index));
3906
+ start = index + 1;
3907
+ }
3908
+ }
3909
+ take(list.slice(start));
3910
+ return names;
3911
+ }
3912
+ /** Whether `text` uses `name` as a value, not as a key or a property. */
3913
+ function mentions(text, name) {
3914
+ const escaped = name.replaceAll("$", String.raw`\$`);
3915
+ return new RegExp(String.raw`(?<![\w$.])${escaped}(?![\w$])(?!\s*:(?!:))`).test(text);
3916
+ }
3917
+ const camel$1 = (name) => name.replaceAll(/_([a-z\d])/g, (_, char) => char.toUpperCase());
3918
+ const compact = (text) => text.replaceAll(/\s+/g, " ").replaceAll(/\s*\.\s*/g, ".").replaceAll(/([([])\s+|\s+(?=[)\]])/g, "$1").trim();
3919
+ /** `customer_assets` and `customerAssets` compare equal. */
3920
+ const tableKey$1 = (name) => name.toLowerCase().replaceAll("_", "");
3921
+ const rpcName = (text, open) => /^\s*["'`]([\w.]+)/.exec(text.slice(open + 1))?.[1]?.split(".").at(-1);
3922
+ /**
3923
+ * Offsets of calls that write: repository and supabase-js writes, RPCs, block
3924
+ * methods and service methods named for a write (`services.agenda.assignTask`
3925
+ * too), and calls named for a side effect such as `notify...` or `publish...`.
3926
+ */
3927
+ function writesIn(text, code, services) {
3928
+ const writes = [...code.matchAll(new RegExp(REPOSITORY_WRITE, "g"))].map((match) => match.index);
3929
+ for (const match of code.matchAll(RPC_CALL)) {
3930
+ const name = rpcName(text, match.index + match[0].length - 1);
3931
+ if (name !== void 0 && WRITE_NAME.test(camel$1(name))) writes.push(match.index);
3932
+ }
3933
+ for (const match of code.matchAll(BLOCK_CALL)) if (WRITE_NAME.test(match[1])) writes.push(match.index);
3934
+ for (const match of code.matchAll(SERVICE_WRITE)) {
3935
+ const owner = /([\w$]+)\s*\.\s*$/.exec(code.slice(Math.max(0, match.index - 200), match.index))?.[1];
3936
+ if ((isService(match[1], services) || owner !== void 0 && isService(owner, services)) && WRITE_NAME.test(match[2])) writes.push(match.index);
3937
+ }
3938
+ for (const match of code.matchAll(SIDE_EFFECT_CALL)) writes.push(match.index);
3939
+ return writes;
3940
+ }
3941
+ /** Reads by the database client itself, before following local functions. */
3942
+ function directReads(text, code) {
3943
+ const reads = [];
3944
+ const add = (match, kind, table, method) => {
3945
+ const open = match.index + match[0].length - 1;
3946
+ let call = compact(text.slice(match.index, open));
3947
+ if (kind === "rpc") {
3948
+ const name = rpcName(text, open);
3949
+ if (name !== void 0 && WRITE_NAME.test(camel$1(name))) return;
3950
+ call = name === void 0 ? call : `${call}("${name}")`;
3951
+ }
3952
+ let close = closeOf(code, open);
3953
+ if (kind === "table" && method === void 0) for (let next = /^\s*\.\s*[\w$]+\s*\(/.exec(code.slice(close + 1)); next; next = /^\s*\.\s*[\w$]+\s*\(/.exec(code.slice(close + 1))) close = closeOf(code, close + next[0].length);
3954
+ reads.push({
3955
+ start: match.index,
3956
+ open,
3957
+ close,
3958
+ call,
3959
+ callee: call,
3960
+ kind,
3961
+ ...table === void 0 ? {} : { table },
3962
+ ...method === void 0 ? {} : { method }
3963
+ });
3964
+ };
3965
+ for (const match of code.matchAll(REPOSITORY_READ)) add(match, "table", match[1], match[2]);
3966
+ for (const match of code.matchAll(BLOCK_CALL)) if (!WRITE_NAME.test(match[1])) add(match, "other");
3967
+ for (const match of code.matchAll(RPC_CALL)) add(match, "rpc");
3968
+ for (const match of code.matchAll(FROM_SELECT)) {
3969
+ const from = match.index + match[0].indexOf("(");
3970
+ const table = /["'`]([\w.]+)["'`]/.exec(text.slice(from, from + match[1].length + 2))?.[1];
3971
+ add(match, "table", table?.split(".").at(-1));
3972
+ }
3973
+ return reads;
3974
+ }
3975
+ /**
3976
+ * Local functions that read and never write, followed through each other within
3977
+ * the file, mapped to the read they make.
3978
+ */
3979
+ function readerFunctions(code, direct) {
3980
+ const bodies = /* @__PURE__ */ new Map();
3981
+ for (const match of code.matchAll(LOCAL_FUNCTION)) {
3982
+ const name = match[1] ?? match[2];
3983
+ const params = match.index + match[0].length - 1;
3984
+ const afterParams = code.charAt(params) === "(" ? closeOf(code, params) + 1 : params;
3985
+ const arrow = code.indexOf("=>", afterParams);
3986
+ const brace = code.indexOf("{", afterParams);
3987
+ const start = arrow !== -1 && (brace === -1 || arrow < brace) ? arrow + 2 : brace;
3988
+ if (start === -1 || WRITE_NAME.test(name)) continue;
3989
+ const open = /^\s*\{/.test(code.slice(start)) ? code.indexOf("{", start) : -1;
3990
+ const end = open === -1 ? statementEnd(code, start) : closeOf(code, open);
3991
+ bodies.set(name, {
3992
+ start,
3993
+ end
3994
+ });
3995
+ }
3996
+ const readers = /* @__PURE__ */ new Map();
3997
+ for (const [name, body] of bodies) {
3998
+ const slice = code.slice(body.start, body.end);
3999
+ const read = direct.find((candidate) => candidate.start > body.start && candidate.start < body.end);
4000
+ if (read !== void 0 && !REPOSITORY_WRITE.test(slice)) readers.set(name, read);
4001
+ }
4002
+ let grew = true;
4003
+ while (grew) {
4004
+ grew = false;
4005
+ for (const [name, body] of bodies) {
4006
+ if (readers.has(name)) continue;
4007
+ const slice = code.slice(body.start, body.end);
4008
+ if (REPOSITORY_WRITE.test(slice)) continue;
4009
+ for (const [reader, read] of readers) if (reader !== name && callsOf(slice, reader).length > 0) {
4010
+ readers.set(name, read);
4011
+ grew = true;
4012
+ break;
4013
+ }
4014
+ }
4015
+ }
4016
+ return readers;
4017
+ }
4018
+ /** Offsets of `name(` calls that aren't a property, a definition or a method. */
4019
+ function callsOf(code, name) {
4020
+ const escaped = name.replaceAll("$", String.raw`\$`);
4021
+ return [...code.matchAll(new RegExp(String.raw`(?<![\w$.])${escaped}\s*\(`, "g"))].filter((match) => !/(?:function\s*\*?\s*|async\s+)$/.test(code.slice(0, match.index))).map((match) => match.index);
4022
+ }
4023
+ /** Names bound to the result of a `create...Service(...)` factory. */
4024
+ function serviceNames(code) {
4025
+ const services = /* @__PURE__ */ new Set();
4026
+ for (const match of code.matchAll(SERVICE_FACTORY)) for (const name of boundNames(match[1])) services.add(name);
4027
+ for (const match of code.matchAll(SERVICE_TYPED)) services.add(match[1]);
4028
+ return services;
4029
+ }
4030
+ const isService = (receiver, services) => services.has(receiver) || SERVICE_NAME.test(receiver);
4031
+ /** Every read in the file, including calls to readers and service reads. */
4032
+ function readsIn(text, code, services) {
4033
+ const direct = directReads(text, code);
4034
+ const reads = [...direct];
4035
+ for (const [name, read] of readerFunctions(code, direct)) for (const start of callsOf(code, name)) {
4036
+ const open = code.indexOf("(", start);
4037
+ reads.push({
4038
+ start,
4039
+ open,
4040
+ close: closeOf(code, open),
4041
+ call: `${name} (which calls ${read.call})`,
4042
+ callee: name,
4043
+ kind: "other"
4044
+ });
4045
+ }
4046
+ for (const match of code.matchAll(SERVICE_READ)) {
4047
+ const receiver = match[1];
4048
+ if (!isService(receiver, services)) continue;
4049
+ const open = match.index + match[0].length - 1;
4050
+ reads.push({
4051
+ start: match.index,
4052
+ open,
4053
+ close: closeOf(code, open),
4054
+ call: `${receiver}.${match[2]}`,
4055
+ callee: `${receiver}.${match[2]}`,
4056
+ kind: "other"
4057
+ });
4058
+ }
4059
+ return reads.toSorted((a, b) => a.start - b.start);
4060
+ }
4061
+ /** The expression before `.map(` that starts at `end`, such as `page.ids`. */
4062
+ function receiverBefore(code, end) {
4063
+ let start = end;
4064
+ while (start > 0) {
4065
+ const char = code.charAt(start - 1);
4066
+ if (char === ")" || char === "]") {
4067
+ let depth = 0;
4068
+ for (start -= 1; start >= 0; start -= 1) {
4069
+ const inner = code.charAt(start);
4070
+ depth += CLOSE.has(inner) ? 1 : OPEN.has(inner) ? -1 : 0;
4071
+ if (depth === 0) break;
4072
+ }
4073
+ } else if (/[\w$.?!]/.test(char) || /\s/.test(char) && /^\??\./.test(code.slice(start).trimStart())) start -= 1;
4074
+ else break;
4075
+ }
4076
+ return code.slice(start, end).trim().replace(/^\.\.\./, "");
4077
+ }
4078
+ /** `for (... of ...)` bodies and `.map/.flatMap/.forEach` callbacks. */
4079
+ function scopesIn(code) {
4080
+ const scopes = [];
4081
+ for (const match of code.matchAll(LOOP)) {
4082
+ const open = match.index + match[0].length - 1;
4083
+ const close = closeOf(code, open);
4084
+ const header = /^\s*(?:const|let|var)\s+([\s\S]+?)\s+of\s+([\s\S]+)$/.exec(code.slice(open + 1, close));
4085
+ if (!header) continue;
4086
+ const bodyStart = close + 1;
4087
+ const end = /^\s*\{/.test(code.slice(bodyStart)) ? closeOf(code, code.indexOf("{", bodyStart)) : statementEnd(code, bodyStart);
4088
+ scopes.push({
4089
+ start: bodyStart,
4090
+ end,
4091
+ items: compact(header[2]),
4092
+ names: boundNames(header[1])
4093
+ });
4094
+ }
4095
+ for (const match of code.matchAll(CALLBACK)) {
4096
+ const open = match.index + match[0].length - 1;
4097
+ const close = closeOf(code, open);
4098
+ const callback = callbackAt(code, open + 1, close);
4099
+ if (callback) scopes.push({
4100
+ ...callback,
4101
+ items: compact(receiverBefore(code, match.index))
4102
+ });
4103
+ }
4104
+ for (const match of code.matchAll(HELPER_CALL)) {
4105
+ const name = match[1];
4106
+ if (!HELPER_NAME.test(name) || /^(?:Map|WeakMap|function)$/.test(name) || /(?:function\s*\*?\s*|async\s+)$/.test(code.slice(Math.max(0, match.index - 40), match.index))) continue;
4107
+ const open = match.index + match[0].length - 1;
4108
+ const close = closeOf(code, open);
4109
+ const args = splitTop(code.slice(open + 1, close));
4110
+ let from = open + 1 + args[0].length + 1;
4111
+ for (const arg of args.slice(1)) {
4112
+ const callback = callbackAt(code, from, from + arg.length);
4113
+ if (callback) {
4114
+ scopes.push({
4115
+ ...callback,
4116
+ items: compact(args[0])
4117
+ });
4118
+ break;
4119
+ }
4120
+ from += arg.length + 1;
4121
+ }
4122
+ }
4123
+ return scopes.toSorted((a, b) => a.end - a.start - (b.end - b.start));
4124
+ }
4125
+ /**
4126
+ * The parameters and body of a function written at `from` (`async (a, b) =>
4127
+ * ...`, `x => ...`, `function (x) {...}`), ending at `end`.
4128
+ */
4129
+ function callbackAt(code, from, end) {
4130
+ const callback = /^\s*(?:async\s+)?(?:function\s*[\w$]*\s*\(|\(|([\w$]+)\s*=>)/.exec(code.slice(from, end));
4131
+ if (!callback) return;
4132
+ if (callback[1] !== void 0) return {
4133
+ start: from + callback[0].length,
4134
+ end,
4135
+ names: [callback[1]]
4136
+ };
4137
+ const params = from + callback[0].length - 1;
4138
+ const paramsEnd = closeOf(code, params);
4139
+ if (!callback[0].includes("function") && !/^\s*(?::[^=;{]+)?=>/.test(code.slice(paramsEnd + 1, end))) return;
4140
+ return {
4141
+ start: paramsEnd + 1,
4142
+ end,
4143
+ names: parameterNames(code.slice(params + 1, paramsEnd))
4144
+ };
4145
+ }
4146
+ /** Names in `scope` that hold the loop variable, or something derived from it. */
4147
+ function scopeNames(code, scope) {
4148
+ const names = [...scope.names];
4149
+ const body = code.slice(scope.start, scope.end);
4150
+ for (const match of body.matchAll(DECLARATION)) {
4151
+ const from = match.index + match[0].length;
4152
+ const init = body.slice(from, statementEnd(body, from));
4153
+ if (names.some((name) => mentions(init, name))) names.push(...boundNames(match[1]));
4154
+ }
4155
+ return names;
4156
+ }
4157
+ /** The innermost `{` before `at` that is still open there, and its close. */
4158
+ function enclosingEnd(code, at) {
4159
+ let depth = 0;
4160
+ for (let index = at; index < code.length; index += 1) {
4161
+ const char = code.charAt(index);
4162
+ if (OPEN.has(char)) depth += 1;
4163
+ else if (CLOSE.has(char)) {
4164
+ depth -= 1;
4165
+ if (depth < 0) return index;
4166
+ }
4167
+ }
4168
+ return code.length;
4169
+ }
4170
+ /** Variables that hold rows of an earlier awaited table read, and their scope. */
4171
+ function originsIn(text, code, reads) {
4172
+ const origins = [];
4173
+ const lineAt = lines$1(text);
4174
+ for (const match of code.matchAll(DECLARATION)) {
4175
+ const from = match.index + match[0].length;
4176
+ const end = statementEnd(code, from);
4177
+ const init = code.slice(from, end);
4178
+ const names = boundNames(match[1]);
4179
+ const scope = {
4180
+ from: end,
4181
+ to: enclosingEnd(code, match.index)
4182
+ };
4183
+ const inside = reads.filter((read) => read.start >= from && read.start < end);
4184
+ if (/^\s*await\b/.test(init) && inside.length > 0) {
4185
+ const all = /^\s*await\s+Promise\.all\s*\(\s*\[/.exec(init);
4186
+ const pattern = match[1].trim();
4187
+ if (all && pattern.startsWith("[")) {
4188
+ const entries = splitTop(code.slice(from + all[0].length, closeOf(code, from + all[0].length - 1)));
4189
+ let offset = from + all[0].length;
4190
+ for (const [index, entry] of entries.entries()) {
4191
+ const [low, high] = [offset, offset + entry.length];
4192
+ const read = inside.find((candidate) => candidate.start >= low && candidate.start < high);
4193
+ const name = boundNames(`[${splitTop(pattern.slice(1, -1))[index] ?? ""}]`)[0];
4194
+ offset += entry.length + 1;
4195
+ if (read?.table !== void 0 && name !== void 0) origins.push({
4196
+ name,
4197
+ table: read.table,
4198
+ call: read.call,
4199
+ line: lineAt(read.start),
4200
+ ...scope
4201
+ });
4202
+ }
4203
+ continue;
4204
+ }
4205
+ const read = inside[0];
4206
+ if (read.table !== void 0) for (const name of names) origins.push({
4207
+ name,
4208
+ table: read.table,
4209
+ call: read.call,
4210
+ line: lineAt(read.start),
4211
+ ...scope
4212
+ });
4213
+ continue;
4214
+ }
4215
+ const source = origins.findLast((origin) => match.index >= origin.from && match.index < origin.to && mentions(init, origin.name));
4216
+ if (source) for (const name of names) origins.push({
4217
+ ...source,
4218
+ name,
4219
+ ...scope
4220
+ });
4221
+ }
4222
+ return origins;
4223
+ }
4224
+ /** Parts of `list` split at top-level commas. */
4225
+ function splitTop(list) {
4226
+ const parts = [];
4227
+ let depth = 0;
4228
+ let start = 0;
4229
+ for (let index = 0; index < list.length; index += 1) {
4230
+ const char = list.charAt(index);
4231
+ depth += OPEN.has(char) ? 1 : CLOSE.has(char) ? -1 : 0;
4232
+ if (char === "," && depth === 0) {
4233
+ parts.push(list.slice(start, index));
4234
+ start = index + 1;
4235
+ }
4236
+ }
4237
+ parts.push(list.slice(start));
4238
+ return parts;
4239
+ }
4240
+ function lines$1(text) {
4241
+ const starts = [0];
4242
+ for (let index = 0; index < text.length; index += 1) if (text.charAt(index) === "\n") starts.push(index + 1);
4243
+ return (index) => {
4244
+ let low = 0;
4245
+ let high = starts.length - 1;
4246
+ while (low < high) {
4247
+ const mid = Math.ceil((low + high) / 2);
4248
+ if (starts[mid] <= index) low = mid;
4249
+ else high = mid - 1;
4250
+ }
4251
+ return low + 1;
4252
+ };
4253
+ }
4254
+ /**
4255
+ * The include on `outer` that loads the `inner` rows `args` asks for, from the
4256
+ * snapshot's foreign keys: `customer` when `outer` holds the key and `args`
4257
+ * filters on the column it references, `notes` when `inner` holds the key and
4258
+ * `args` filters on it.
4259
+ */
4260
+ function relationTo(snapshot, outer, inner, args, via) {
4261
+ const table = inner.table;
4262
+ if (table === void 0 || tableKey$1(outer) === tableKey$1(table)) return;
4263
+ const camelCase = /[A-Z]/.test(outer + table);
4264
+ const name = (raw) => camelCase ? camel$1(raw) : raw;
4265
+ const filters = (column) => column !== void 0 && new RegExp(String.raw`(?<![\w$])(?:${column}|${camel$1(column)})\s*:|["'\`]${column}["'\`]\s*,`).test(args);
4266
+ const candidates = [];
4267
+ const named = (column) => new RegExp(String.raw`(?<![\w$])(?:${column}|${camel$1(column)})(?![\w$])`).test(args);
4268
+ for (const relation of snapshot.generator.relationships) {
4269
+ const from = tableKey$1(relation.relation);
4270
+ const to = tableKey$1(relation.referenced_relation);
4271
+ const [column] = relation.columns;
4272
+ if (column === void 0) continue;
4273
+ if (from === tableKey$1(outer) && to === tableKey$1(table) && (inner.method === "get" || filters(relation.referenced_columns[0]))) {
4274
+ const found = {
4275
+ name: name(column.replace(/_id$/, "")),
4276
+ many: false
4277
+ };
4278
+ if (named(column)) return found;
4279
+ candidates.push(found);
4280
+ }
4281
+ if (from === tableKey$1(table) && to === tableKey$1(outer) && filters(column)) candidates.push({
4282
+ name: name(relation.relation),
4283
+ many: true
4284
+ });
4285
+ }
4286
+ if (candidates.length > 0 || via === void 0) return candidates[0];
4287
+ return throughRelation(snapshot, outer, table, args, via, name);
4288
+ }
4289
+ /**
4290
+ * Two tables that both reference a third, such as `quote_tasks` and
4291
+ * `invoice_tasks` through `tasks`, when the inner read filters its key column
4292
+ * by the outer rows (`taskId: { in: taskIds }`): `include: { task: { include: {
4293
+ * invoiceTasks: true } } }` on the outer read.
4294
+ */
4295
+ function throughRelation(snapshot, outer, inner, args, via, name) {
4296
+ const relationships = snapshot.generator.relationships;
4297
+ const shared = new Set(relationships.flatMap((relation) => relation.columns.slice(1)));
4298
+ for (const hop of relationships) {
4299
+ const [hopColumn] = hop.columns;
4300
+ const middle = tableKey$1(hop.referenced_relation);
4301
+ if (hopColumn === void 0 || shared.has(hopColumn) || hop.referenced_schema !== hop.schema || tableKey$1(hop.relation) !== tableKey$1(outer) || middle === tableKey$1(inner) || middle === tableKey$1(outer)) continue;
4302
+ for (const back of relationships) {
4303
+ const [column] = back.columns;
4304
+ if (column !== void 0 && back.schema === hop.schema && back.referenced_schema === hop.schema && tableKey$1(back.relation) === tableKey$1(inner) && tableKey$1(back.referenced_relation) === middle && back.referenced_columns[0] === hop.referenced_columns[0] && filterMentions(args, column, via)) return {
4305
+ name: name(back.relation),
4306
+ many: true,
4307
+ through: name(hopColumn.replace(/_id$/, ""))
4308
+ };
4309
+ }
4310
+ }
4311
+ }
4312
+ /** Whether the filter on `column` (`taskId: { in: taskIds }`) uses `name`. */
4313
+ function filterMentions(args, column, name) {
4314
+ const key = new RegExp(String.raw`(?<![\w$])(?:${column}|${camel$1(column)})\s*:`, "g");
4315
+ for (const match of args.matchAll(key)) {
4316
+ const from = match.index + match[0].length;
4317
+ if (mentions(args.slice(from, statementEnd(args, from)), name)) return true;
4318
+ }
4319
+ return false;
4320
+ }
4321
+ /** `include: { quote: true }`, or `_count` for a count of related rows. */
4322
+ function includeOf(relation, read) {
4323
+ const inner = relation.many && read.method === "count" ? `include: { _count: { ${relation.name}: true } }` : `include: { ${relation.name}: true }`;
4324
+ return relation.through === void 0 ? inner : `include: { ${relation.through}: { ${inner} } }`;
4325
+ }
4326
+ /**
4327
+ * How the read matches the loop variable when an `in` list can't: a text search
4328
+ * (`contains: term`, `q: term`, `.ilike(...)`) or JSON containment (`contains:
4329
+ * { nodes: [{ id }] }`).
4330
+ */
4331
+ function searchMatch(args, names) {
4332
+ for (const match of args.matchAll(SEARCH_FILTER)) {
4333
+ const from = match.index + match[0].length;
4334
+ const value = match[2] === "(" ? args.slice(from, closeOf(args, from - 1)) : args.slice(from, statementEnd(args, from));
4335
+ const name = names.find((candidate) => mentions(value, candidate));
4336
+ if (name !== void 0) return {
4337
+ kind: match[1].startsWith("contain") && /^\s*[[{]/.test(value) ? "json" : "search",
4338
+ name
4339
+ };
4340
+ }
4341
+ }
4342
+ function searchHint(match) {
4343
+ return match.kind === "json" ? `The read matches \`${match.name}\` inside a JSON column with \`contains\`, which an \`in\` filter can't do. Fold the values into one read with an \`OR\` of the \`contains\` conditions, or call an RPC that takes them as an array and matches with \`@> any (...)\`. When neither fits, accept the finding in the baseline.` : `\`${match.name}\` is a search term, and an \`in\` filter only matches whole values. Fold the terms into one read with an \`OR\` of the conditions (\`where: { OR: terms.map((term) => ({ name: { contains: term } })) }\`), or call an RPC that takes the terms as \`text[]\` and matches with \`ilike any (...)\`. When each term needs its own limit or ranking, no batched form applies: accept the finding in the baseline.`;
4344
+ }
4345
+ function batchHint(read) {
4346
+ switch (read.kind) {
4347
+ case "table": return `Read them in one request with an \`in\` filter, such as \`${read.call.replace(/\.(?:get|first|find\w*)$/, ".list")}({ where: { id: { in: ids } } })\`, and group the rows by key.`;
4348
+ case "rpc": return "Give the function an array parameter (`uuid[]`) and call it once for every id, or add it to a read set.";
4349
+ case "other": return "Add a batched variant that takes every id and reads them with one `in` filter, then call it once outside the loop.";
4350
+ default: return read.kind;
4351
+ }
4352
+ }
4353
+ /** `in: ids` or `in: [...ids]`: the read is already batched over `name`. */
4354
+ const batchedOver = (args, name) => new RegExp(String.raw`\bin\s*:\s*(?:\[\s*\.\.\.)?${name.replaceAll("$", String.raw`\$`)}\b`).test(args);
4355
+ /**
4356
+ * A scope that iterates a literal array (`for (const kind of ["a", "b"])`) runs
4357
+ * a fixed number of times; a batch, a retry or a loop that writes per item is
4358
+ * not a read pattern to fold into one request.
4359
+ */
4360
+ function skipScope(scope, writes) {
4361
+ return scope.names.some((name) => BATCHES.test(name)) || BATCH_ITEMS.test(scope.items) || scope.items.startsWith("[") && !scope.items.includes("...") || writes.some((at) => at >= scope.start && at < scope.end);
4362
+ }
4363
+ /** Both checks share one pass over each file. */
4364
+ function analyze(file, snapshot) {
4365
+ const perItem = [];
4366
+ const waterfalls = [];
4367
+ if (!/\bdb\b|\$rpc|supabase|Db\b|blocks|Service/.test(file.text)) return {
4368
+ perItem,
4369
+ waterfalls
4370
+ };
4371
+ const code = codeOnly(file.text);
4372
+ const services = serviceNames(code);
4373
+ const reads = readsIn(file.text, code, services);
4374
+ if (reads.length === 0) return {
4375
+ perItem,
4376
+ waterfalls
4377
+ };
4378
+ const writes = writesIn(file.text, code, services);
4379
+ const rawArgs = (read) => file.text.slice(read.open + 1, read.close);
4380
+ const lineAt = lines$1(file.text);
4381
+ const origins = originsIn(file.text, code, reads);
4382
+ const reported = /* @__PURE__ */ new Set();
4383
+ let keys;
4384
+ const targetOf = (read) => {
4385
+ keys ??= targetKeys(file.path, functionsIn(code), reads);
4386
+ return keys.get(read.start);
4387
+ };
4388
+ for (const scope of scopesIn(code)) {
4389
+ if (skipScope(scope, writes)) continue;
4390
+ const names = scopeNames(code, scope);
4391
+ for (const read of reads) {
4392
+ const args = code.slice(read.open + 1, read.close);
4393
+ if (read.start < scope.start || read.start >= scope.end || reported.has(read.start) || read.method === "page" || !names.some((name) => mentions(args, name)) || names.some((name) => batchedOver(args, name))) continue;
4394
+ reported.add(read.start);
4395
+ const line = lineAt(read.start);
4396
+ const root = /^[\w$]+/.exec(scope.items)?.[0];
4397
+ const outer = origins.findLast((origin) => origin.name === root && scope.start >= origin.from && scope.start < origin.to);
4398
+ const relation = outer ? relationTo(snapshot, outer.table, read, rawArgs(read)) : void 0;
4399
+ const search = searchMatch(args, names);
4400
+ const hint = outer && relation ? `${outer.table} and ${read.table} are related: add \`${includeOf(relation, read)}\` to ${outer.call} at line ${String(outer.line)} and drop this read.` : search ? searchHint(search) : batchHint(read);
4401
+ perItem.push({
4402
+ message: `${file.path}:${String(line)} calls ${read.call} once per item of \`${scope.items}\`, so n items make n requests (N+1). ${hint}`,
4403
+ target: targetOf(read),
4404
+ location: {
4405
+ file: file.path,
4406
+ line
4407
+ }
4408
+ });
4409
+ }
4410
+ }
4411
+ const waves = [...code.matchAll(WAVE)].map((match) => {
4412
+ const open = match.index + match[0].length - 1;
4413
+ return [open, closeOf(code, open)];
4414
+ });
4415
+ for (const read of reads) {
4416
+ if (read.table === void 0 || reported.has(read.start)) continue;
4417
+ const args = code.slice(read.open + 1, read.close);
4418
+ const origin = origins.findLast((candidate) => read.start >= candidate.from && read.start < candidate.to && mentions(args, candidate.name));
4419
+ const relation = origin ? relationTo(snapshot, origin.table, read, rawArgs(read), origin.name) : void 0;
4420
+ if (!origin || !relation) continue;
4421
+ const line = lineAt(read.start);
4422
+ const include = `\`${includeOf(relation, read)}\``;
4423
+ const wave = waves.find(([open, close]) => read.start > open && read.start < close);
4424
+ const sameWave = wave !== void 0 && reads.some((other) => other !== read && other.start > wave[0] && other.start < wave[1] && (other.start > read.close || other.close < read.start) && mentions(code.slice(other.open + 1, other.close), origin.name));
4425
+ waterfalls.push({
4426
+ message: sameWave ? `${file.path}:${String(line)} reads ${read.call} filtered by the rows of ${origin.call} at line ${String(origin.line)} (\`${origin.name}\`), in one Promise.all with other reads that wait for the same rows. An include saves a request, not a wait: add ${include} to the first read to drop this one.` : `${file.path}:${String(line)} waits for ${origin.call} at line ${String(origin.line)}, then reads ${read.call} filtered by its rows (\`${origin.name}\`). The tables are related: add ${include} to the first read so one request returns both.`,
4427
+ target: targetOf(read),
4428
+ location: {
4429
+ file: file.path,
4430
+ line
4431
+ },
4432
+ ...sameWave ? { severity: "info" } : {}
4433
+ });
4434
+ }
4435
+ const byLine = (a, b) => (a.location?.line ?? 0) - (b.location?.line ?? 0);
4436
+ return {
4437
+ perItem: perItem.toSorted(byLine),
4438
+ waterfalls
4439
+ };
4440
+ }
4441
+ const analyses = /* @__PURE__ */ new WeakMap();
4442
+ function analyzeAll(context) {
4443
+ let result = analyses.get(context.sources);
4444
+ if (!result) {
4445
+ result = context.sources.map((file) => analyze(file, context.snapshot));
4446
+ analyses.set(context.sources, result);
4447
+ }
4448
+ return result;
4449
+ }
4450
+ /**
4451
+ * Checks that read only source files. Without a database or a snapshot they
4452
+ * still run; BS634 and BS635 then lack the foreign keys that name includes.
4453
+ */
4454
+ const SOURCE_ONLY_CODES = /* @__PURE__ */ new Set([
4455
+ "BS609",
4456
+ "BS634",
4457
+ "BS635"
4458
+ ]);
4459
+ /** The snapshot of a run that could not read one: no tables, no foreign keys. */
4460
+ const NO_SNAPSHOT = {
4461
+ version: 2,
4462
+ schemas: [],
4463
+ generator: {
4464
+ version: 1,
4465
+ schemas: [],
4466
+ tables: [],
4467
+ foreignTables: [],
4468
+ views: [],
4469
+ materializedViews: [],
4470
+ columns: [],
4471
+ primaryKeys: [],
4472
+ relationships: [],
4473
+ functions: [],
4474
+ types: []
4475
+ },
4476
+ extras: {
4477
+ tables: [],
4478
+ buckets: [],
4479
+ realtime: []
4480
+ }
4481
+ };
4482
+ const N_PLUS_ONE_RULES = [{
4483
+ code: "BS634",
4484
+ severity: "warning",
4485
+ title: "Database read once per item (N+1)",
4486
+ description: "A repository read, block call, RPC or supabase-js select inside a `for ... of` loop or a `map`/`flatMap`/`forEach` callback, filtered by the loop variable, makes one request per item. Load the rows with an `include` on the outer read when the tables are related, or with one `in` read outside the loop.",
4487
+ check: (context) => analyzeAll(context).flatMap((file) => file.perItem)
4488
+ }, {
4489
+ code: "BS635",
4490
+ severity: "warning",
4491
+ title: "Dependent read of a related table (waterfall)",
4492
+ description: "An awaited read whose filter uses the rows of an earlier awaited read in the same function, when the two tables have a foreign key between them. The second request waits for the first; an `include` on the first read returns both in one request.",
4493
+ check: (context) => analyzeAll(context).flatMap((file) => file.waterfalls)
4494
+ }];
3832
4495
  // src/cli/doctor/client-barrels.ts
3833
4496
  /** A `"use client"` directive as the first statement, after comments. */
3834
4497
  const USE_CLIENT$1 = /^\s*(?:(?:\/\/[^\n]*|\/\*[\s\S]*?\*\/)\s*)*["']use client["']/;
@@ -6999,6 +7662,7 @@ const RULES = [
6999
7662
  ...COOKIE_RULES,
7000
7663
  ...NEXT_CACHE_RULES,
7001
7664
  ...ROUND_TRIP_RULES,
7665
+ ...N_PLUS_ONE_RULES,
7002
7666
  ...CLAIM_RULES,
7003
7667
  ...MIGRATION_RULES,
7004
7668
  ...AUTHORIZATION_RULES,
@@ -7054,6 +7718,18 @@ async function runRules(context, rules = RULES) {
7054
7718
  // src/cli/doctor/baseline.ts
7055
7719
  const targetOf = (finding) => finding.target ?? finding.title;
7056
7720
  const keyOf = (code, target) => `${code}\u0000${target}`;
7721
+ /**
7722
+ * The `file:line` target BS634 and BS635 wrote before their targets named the
7723
+ * function and the callee; an entry with it still matches the finding.
7724
+ */
7725
+ const legacyKeyOf = (finding) => finding.location === void 0 ? void 0 : keyOf(finding.code, `${finding.location.file}:${String(finding.location.line)}`);
7726
+ /** The listed key that accepts `finding`: its target, or its old line target. */
7727
+ function listedKey(finding, listed) {
7728
+ const key = keyOf(finding.code, targetOf(finding));
7729
+ if (listed.has(key)) return key;
7730
+ const legacy = legacyKeyOf(finding);
7731
+ return legacy !== void 0 && listed.has(legacy) ? legacy : void 0;
7732
+ }
7057
7733
  const text$1 = (value) => typeof value === "string";
7058
7734
  /**
7059
7735
  * Parses a baseline file, `[{ code, target, reason }]`. Throws a `TypeError`
@@ -7098,9 +7774,9 @@ function applyBaseline(findings, entries, ran, context, path) {
7098
7774
  const matched = /* @__PURE__ */ new Set();
7099
7775
  const kept = [];
7100
7776
  for (const finding of findings) {
7101
- const key = keyOf(finding.code, targetOf(finding));
7102
- if (listed.has(key)) matched.add(key);
7103
- else kept.push(finding);
7777
+ const key = listedKey(finding, listed);
7778
+ if (key === void 0) kept.push(finding);
7779
+ else matched.add(key);
7104
7780
  }
7105
7781
  const stale = entries.filter((entry) => !matched.has(keyOf(entry.code, entry.target)) && judged(entry.code, ran, context));
7106
7782
  return {
@@ -7126,14 +7802,16 @@ function updatedBaseline(findings, entries, ran, context) {
7126
7802
  const byCode = /* @__PURE__ */ new Map();
7127
7803
  for (const entry of entries) if (entry.reason !== "" && !byCode.has(entry.code)) byCode.set(entry.code, entry.reason);
7128
7804
  const next = /* @__PURE__ */ new Map();
7805
+ const known = new Set(reasons.keys());
7129
7806
  for (const finding of findings) {
7130
7807
  if (finding.severity === "info") continue;
7131
7808
  const target = targetOf(finding);
7132
7809
  const key = keyOf(finding.code, target);
7810
+ const listed = listedKey(finding, known);
7133
7811
  next.set(key, {
7134
7812
  code: finding.code,
7135
7813
  target,
7136
- reason: reasons.get(key) ?? byCode.get(finding.code) ?? ""
7814
+ reason: (listed === void 0 ? void 0 : reasons.get(listed)) ?? byCode.get(finding.code) ?? ""
7137
7815
  });
7138
7816
  }
7139
7817
  for (const entry of entries) {
@@ -7598,9 +8276,15 @@ async function runDoctor(config, args, env, options = {}) {
7598
8276
  ...options.advisors === void 0 ? {} : { advisors: options.advisors },
7599
8277
  ...options.database === void 0 ? {} : { database: options.database }
7600
8278
  };
8279
+ const sourceOnly = rules.length > 0 && rules.every((rule) => SOURCE_ONLY_CODES.has(rule.code));
8280
+ let noSnapshot;
7601
8281
  const vercel = VERCEL_FILES.some((path) => existsSync(resolve(config.root, path)));
7602
8282
  const [snapshot, envFiles, [configToml, sql], gitignore, sources, readSets, peers, contentMapper, stackEnv, localStacks, nextConfig, install] = await Promise.all([
7603
- options.snapshot ?? loadSnapshot(config, env, source, pg, opened.open),
8283
+ options.snapshot ?? loadSnapshot(config, env, source, pg, opened.open).catch((cause) => {
8284
+ if (!sourceOnly) throw cause;
8285
+ noSnapshot = errorText(cause);
8286
+ return NO_SNAPSHOT;
8287
+ }),
7604
8288
  Promise.all(ENV_FILES.map((path) => readText(config.root, path))).then((files) => files.filter((file) => file !== void 0)),
7605
8289
  readSupabaseToml(config.root).then(async (toml) => [toml, await sqlFiles(config.root, toml, sqlWorkflow(config, toml))]),
7606
8290
  readText(config.root, ".gitignore"),
@@ -7662,6 +8346,14 @@ async function runDoctor(config, args, env, options = {}) {
7662
8346
  let ran;
7663
8347
  try {
7664
8348
  ran = await runRules(context, rules);
8349
+ const schemaRule = rules.find((rule) => rule.code === "BS635") ?? rules.find((rule) => rule.code === "BS634");
8350
+ if (noSnapshot !== void 0 && schemaRule !== void 0) ran.push({
8351
+ code: schemaRule.code,
8352
+ severity: "info",
8353
+ title: schemaRule.title,
8354
+ help: `${DOCS_URL}#${schemaRule.code.toLowerCase()}`,
8355
+ message: `Ran without the schema (${noSnapshot}), so the findings name no include and BS635 finds no waterfall. Pass --snapshot, or set $DATABASE_URL, to use the foreign keys.`
8356
+ });
7665
8357
  if (args.yes === true) {
7666
8358
  const count = ran.filter((finding) => finding.fix !== void 0).length;
7667
8359
  ({left: ran} = await applyFixes(ran, context.database, async () => {