better-supabase 0.58.3 → 0.59.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 (442) hide show
  1. package/dist/{adapter-base-BbnpIsy4.js → adapter-base-BAjra5Eb.js} +1 -1
  2. package/dist/{ai-schedules-D47O_Vlo.d.ts → ai-schedules-BxBsTpji.d.ts} +1 -1
  3. package/dist/{api-DsFkhsYI.js → api-DAJJ7N_0.js} +1 -1
  4. package/dist/{app-tables-IXL0Hzut.d.ts → app-tables-DBmFqdFN.d.ts} +1 -1
  5. package/dist/astro/index.js +3 -3
  6. package/dist/{bind-BRkDWXXk.d.ts → bind-Bx0H1vAc.d.ts} +2 -2
  7. package/dist/{block-env-I8juWoVO.d.ts → block-env-DUn5reXc.d.ts} +2 -2
  8. package/dist/{block-tables-DmDyNlJf.d.ts → block-tables-BaLXCQha.d.ts} +1 -1
  9. package/dist/blocks/access-requests/index.d.ts +1 -1
  10. package/dist/blocks/accounting/index.d.ts +1 -1
  11. package/dist/blocks/acknowledgements/index.d.ts +1 -1
  12. package/dist/blocks/activities/index.d.ts +2 -2
  13. package/dist/blocks/advisories/index.d.ts +1 -1
  14. package/dist/blocks/agent-checkout/index.d.ts +1 -1
  15. package/dist/blocks/agents/index.d.ts +1 -1
  16. package/dist/blocks/ai-cache/index.d.ts +1 -1
  17. package/dist/blocks/ai-chat/index.d.ts +1 -1
  18. package/dist/blocks/ai-evals/index.d.ts +1 -1
  19. package/dist/blocks/ai-files/index.d.ts +1 -1
  20. package/dist/blocks/ai-guardrails/index.d.ts +1 -1
  21. package/dist/blocks/ai-keys/index.d.ts +1 -1
  22. package/dist/blocks/ai-schedules/index.d.ts +2 -2
  23. package/dist/blocks/announcements/index.d.ts +2 -2
  24. package/dist/blocks/api-keys/index.d.ts +1 -1
  25. package/dist/blocks/appraisals/index.d.ts +1 -1
  26. package/dist/blocks/approvals/index.d.ts +1 -1
  27. package/dist/blocks/assets/index.d.ts +1 -1
  28. package/dist/blocks/assignment/index.d.ts +1 -1
  29. package/dist/blocks/attachments/index.d.ts +3 -3
  30. package/dist/blocks/audit/index.d.ts +2 -2
  31. package/dist/blocks/automations/index.d.ts +3 -3
  32. package/dist/blocks/banking/index.d.ts +1 -1
  33. package/dist/blocks/billable-time/index.d.ts +1 -1
  34. package/dist/blocks/billing/index.d.ts +2 -2
  35. package/dist/blocks/bookings/index.d.ts +2 -2
  36. package/dist/blocks/bulk-actions/index.d.ts +2 -2
  37. package/dist/blocks/calendar/index.d.ts +3 -3
  38. package/dist/blocks/care/index.d.ts +27 -27
  39. package/dist/blocks/care-plans/index.d.ts +2 -2
  40. package/dist/blocks/cases/index.d.ts +2 -2
  41. package/dist/blocks/catalog/index.d.ts +2 -2
  42. package/dist/blocks/channels/index.d.ts +1 -1
  43. package/dist/blocks/clinical-decision-support/index.d.ts +1 -1
  44. package/dist/blocks/cms/index.d.ts +5 -5
  45. package/dist/blocks/collaboration/index.d.ts +6 -6
  46. package/dist/blocks/collections/index.d.ts +1 -1
  47. package/dist/blocks/comments/index.d.ts +1 -1
  48. package/dist/blocks/commerce/index.d.ts +5 -5
  49. package/dist/blocks/commissions/index.d.ts +1 -1
  50. package/dist/blocks/compliance/index.d.ts +1 -1
  51. package/dist/blocks/connectors/index.d.ts +1 -1
  52. package/dist/blocks/consents/index.d.ts +2 -2
  53. package/dist/blocks/contacts/index.d.ts +2 -2
  54. package/dist/blocks/content/index.d.ts +1 -1
  55. package/dist/blocks/contracts/index.d.ts +1 -1
  56. package/dist/blocks/courses/index.d.ts +2 -2
  57. package/dist/blocks/created-by/index.d.ts +1 -1
  58. package/dist/blocks/crm/index.d.ts +16 -16
  59. package/dist/blocks/custom-fields/index.d.ts +1 -1
  60. package/dist/blocks/dam/index.d.ts +2 -2
  61. package/dist/blocks/data-lifecycle/index.d.ts +2 -2
  62. package/dist/blocks/deadlines/index.d.ts +1 -1
  63. package/dist/blocks/deals/index.d.ts +1 -1
  64. package/dist/blocks/dispatch/index.d.ts +1 -1
  65. package/dist/blocks/document-templates/index.d.ts +1 -1
  66. package/dist/blocks/documents/index.d.ts +1 -1
  67. package/dist/blocks/domains/index.d.ts +1 -1
  68. package/dist/blocks/donations/index.d.ts +1 -1
  69. package/dist/blocks/drive/index.d.ts +5 -5
  70. package/dist/blocks/e-prescribing/index.d.ts +1 -1
  71. package/dist/blocks/employees/index.d.ts +1 -1
  72. package/dist/blocks/enrichment/index.d.ts +1 -1
  73. package/dist/blocks/enrollments/index.d.ts +1 -1
  74. package/dist/blocks/entitlements/index.d.ts +3 -3
  75. package/dist/blocks/events/index.d.ts +3 -3
  76. package/dist/blocks/expenses/index.d.ts +1 -1
  77. package/dist/blocks/field-history/index.d.ts +1 -1
  78. package/dist/blocks/filespace/index.d.ts +8 -8
  79. package/dist/blocks/finance/index.d.ts +5 -5
  80. package/dist/blocks/flags/index.d.ts +1 -1
  81. package/dist/blocks/forecasts/index.d.ts +1 -1
  82. package/dist/blocks/forms/index.d.ts +3 -3
  83. package/dist/blocks/funding/index.d.ts +2 -2
  84. package/dist/blocks/goals/index.d.ts +1 -1
  85. package/dist/blocks/governance/index.d.ts +4 -4
  86. package/dist/blocks/guests/index.d.ts +1 -1
  87. package/dist/blocks/hiring/index.d.ts +1 -1
  88. package/dist/blocks/identities/index.d.ts +1 -1
  89. package/dist/blocks/imports/index.d.ts +1 -1
  90. package/dist/blocks/inbox/index.d.ts +3 -3
  91. package/dist/blocks/incidents/index.d.ts +1 -1
  92. package/dist/blocks/index.d.ts +2 -2
  93. package/dist/blocks/inspections/index.d.ts +1 -1
  94. package/dist/blocks/inventory/index.d.ts +1 -1
  95. package/dist/blocks/invoices/index.d.ts +1 -1
  96. package/dist/blocks/knowledge/index.d.ts +1 -1
  97. package/dist/blocks/lead-scoring/index.d.ts +1 -1
  98. package/dist/blocks/learning/index.d.ts +3 -3
  99. package/dist/blocks/leases/index.d.ts +1 -1
  100. package/dist/blocks/leave/index.d.ts +1 -1
  101. package/dist/blocks/ledger/index.d.ts +1 -1
  102. package/dist/blocks/legal-entities/index.d.ts +1 -1
  103. package/dist/blocks/lims/index.d.ts +1 -1
  104. package/dist/blocks/mail-sync/index.d.ts +2 -2
  105. package/dist/blocks/maintenance/index.d.ts +2 -2
  106. package/dist/blocks/manufacturing/index.d.ts +1 -1
  107. package/dist/blocks/medications/index.d.ts +1 -1
  108. package/dist/blocks/meetings/index.d.ts +2 -2
  109. package/dist/blocks/memberships/index.d.ts +1 -1
  110. package/dist/blocks/memory/index.d.ts +1 -1
  111. package/dist/blocks/messaging/index.d.ts +2 -2
  112. package/dist/blocks/metrics/index.d.ts +1 -1
  113. package/dist/blocks/mfa/index.d.ts +2 -2
  114. package/dist/blocks/moderation/index.d.ts +1 -1
  115. package/dist/blocks/notifications/index.d.ts +3 -3
  116. package/dist/blocks/numbering/index.d.ts +1 -1
  117. package/dist/blocks/oauth-server/index.d.ts +1 -1
  118. package/dist/blocks/observations/index.d.ts +2 -2
  119. package/dist/blocks/onboarding/index.d.ts +2 -2
  120. package/dist/blocks/option-sets/index.d.ts +2 -2
  121. package/dist/blocks/orders/index.d.ts +1 -1
  122. package/dist/blocks/organizations/index.d.ts +1 -1
  123. package/dist/blocks/outbox/index.d.ts +1 -1
  124. package/dist/blocks/passes/index.d.ts +1 -1
  125. package/dist/blocks/payroll-export/index.d.ts +2 -2
  126. package/dist/blocks/people/index.d.ts +7 -7
  127. package/dist/blocks/periods/index.d.ts +1 -1
  128. package/dist/blocks/permissions/index.d.ts +3 -3
  129. package/dist/blocks/pipelines/index.d.ts +2 -2
  130. package/dist/blocks/posts/index.d.ts +1 -1
  131. package/dist/blocks/procurement/index.d.ts +5 -5
  132. package/dist/blocks/profiles/index.d.ts +1 -1
  133. package/dist/blocks/projects/index.d.ts +7 -7
  134. package/dist/blocks/promotions/index.d.ts +1 -1
  135. package/dist/blocks/prompts/index.d.ts +1 -1
  136. package/dist/blocks/push/index.d.ts +1 -1
  137. package/dist/blocks/qualifications/index.d.ts +2 -2
  138. package/dist/blocks/queue/index.d.ts +2 -2
  139. package/dist/blocks/quotes/index.d.ts +1 -1
  140. package/dist/blocks/rank/index.d.ts +1 -1
  141. package/dist/blocks/reactions/index.d.ts +2 -2
  142. package/dist/blocks/recruiting/index.d.ts +4 -4
  143. package/dist/blocks/referrals/index.d.ts +1 -1
  144. package/dist/blocks/relations/index.d.ts +1 -1
  145. package/dist/blocks/reminders/index.d.ts +1 -1
  146. package/dist/blocks/reviews/index.d.ts +1 -1
  147. package/dist/blocks/rfqs/index.d.ts +2 -2
  148. package/dist/blocks/risks/index.d.ts +1 -1
  149. package/dist/blocks/saas/index.d.ts +12 -12
  150. package/dist/blocks/sales/index.d.ts +1 -1
  151. package/dist/blocks/saved-views/index.d.ts +2 -2
  152. package/dist/blocks/scheduling/index.d.ts +4 -4
  153. package/dist/blocks/scores/index.d.ts +1 -1
  154. package/dist/blocks/search/index.d.ts +2 -2
  155. package/dist/blocks/security-events/index.d.ts +1 -1
  156. package/dist/blocks/segments/index.d.ts +1 -1
  157. package/dist/blocks/sequences/index.d.ts +2 -2
  158. package/dist/blocks/service/index.d.ts +7 -7
  159. package/dist/blocks/service-accounts/index.d.ts +1 -1
  160. package/dist/blocks/sessions/index.d.ts +2 -2
  161. package/dist/blocks/settings/index.d.ts +2 -2
  162. package/dist/blocks/share-links/index.d.ts +1 -1
  163. package/dist/blocks/shifts/index.d.ts +2 -2
  164. package/dist/blocks/shipments/index.d.ts +1 -1
  165. package/dist/blocks/signatures/index.d.ts +1 -1
  166. package/dist/blocks/signing-keys/index.d.ts +1 -1
  167. package/dist/blocks/sla/index.d.ts +1 -1
  168. package/dist/blocks/sso/index.d.ts +1 -1
  169. package/dist/blocks/state-machine/index.d.ts +1 -1
  170. package/dist/blocks/subjects/index.d.ts +2 -2
  171. package/dist/blocks/support/index.d.ts +5 -5
  172. package/dist/blocks/tags/index.d.ts +2 -2
  173. package/dist/blocks/tasks/index.d.ts +2 -2
  174. package/dist/blocks/tax/index.d.ts +2 -2
  175. package/dist/blocks/teams/index.d.ts +1 -1
  176. package/dist/blocks/templates/index.d.ts +1 -1
  177. package/dist/blocks/tills/index.d.ts +1 -1
  178. package/dist/blocks/time-entries/index.d.ts +2 -2
  179. package/dist/blocks/timeline/index.d.ts +1 -1
  180. package/dist/blocks/trash/index.d.ts +1 -1
  181. package/dist/blocks/undo/index.d.ts +2 -2
  182. package/dist/blocks/updated-at/index.d.ts +1 -1
  183. package/dist/blocks/usage/index.d.ts +2 -2
  184. package/dist/blocks/vercel-marketplace/index.d.ts +1 -1
  185. package/dist/blocks/versions/index.d.ts +1 -1
  186. package/dist/blocks/waitlist/index.d.ts +1 -1
  187. package/dist/blocks/warehouse/index.d.ts +1 -1
  188. package/dist/blocks/warranty/index.d.ts +1 -1
  189. package/dist/blocks/webhooks/index.d.ts +1 -1
  190. package/dist/blocks/workflow-editor/index.d.ts +2 -2
  191. package/dist/blocks/workflows/index.d.ts +2 -2
  192. package/dist/{build-Cb9yLxtS.js → build-Rz89mkdS.js} +1 -1
  193. package/dist/claims/index.d.ts +4 -4
  194. package/dist/{claims-source-CXAtLZ9_.d.ts → claims-source-BEVTXHQx.d.ts} +1 -1
  195. package/dist/cli/{add-BQZyQh4f.js → add-BJNTq7Ti.js} +2 -2
  196. package/dist/cli/add-C04PIE9H.js +1 -0
  197. package/dist/cli/{add-dbBQf6Vy.js → add-CnCt2QoB.js} +11 -11
  198. package/dist/cli/{app-table-files-CITEmvRS.js → app-table-files-CfB0_NuX.js} +4 -4
  199. package/dist/cli/{app-tables-BBqu3dow.js → app-tables-oieRU_sP.js} +2 -2
  200. package/dist/cli/{backfill-bBk3QjfK.js → backfill-Cr5jgVi1.js} +3 -3
  201. package/dist/cli/bin.js +1 -1
  202. package/dist/cli/{blocks-D-DV2aCE.js → blocks-B-ANsRnH.js} +1 -1
  203. package/dist/cli/{blocks-CsQNweG8.js → blocks-DLMVaOFG.js} +1 -1
  204. package/dist/cli/{cache-sR8AQqSV.js → cache-Ba26VW2N.js} +1 -1
  205. package/dist/cli/{codemod-naming-BLoVSmVF.js → codemod-naming-CZhndoO7.js} +1 -1
  206. package/dist/cli/{codemod-BkPcyPnF.js → codemod-x1I7Mjr3.js} +6 -6
  207. package/dist/cli/{column-renames-brM-D_th.js → column-renames-BEEDF6P6.js} +2 -2
  208. package/dist/cli/{config-NxPVkM-K.js → config-DD_MnPRL.js} +1 -0
  209. package/dist/cli/{config-BGh7rJwA.js → config-DkjilxeE.js} +1 -1
  210. package/dist/cli/{content-mapper-DMi2HOKi.js → content-mapper-z7CrnE1s.js} +1 -1
  211. package/dist/cli/{db-od92zIrO.js → db-CEUnv3hK.js} +2 -2
  212. package/dist/cli/{dev-ClH-7fB0.js → dev-D9nn9Gzt.js} +5 -5
  213. package/dist/cli/{doctor-C_BEuEGg.js → doctor-DCorhlir.js} +584 -25
  214. package/dist/cli/{emit-CTzFdffA.js → emit-qQdWBc9e.js} +2 -2
  215. package/dist/cli/{gen-RKf7q3L5.js → gen-Bf1ujcTm.js} +5 -5
  216. package/dist/cli/{gen-tasks-DmDvgVBV.js → gen-tasks-q9JJSJ6r.js} +11 -11
  217. package/dist/cli/index.d.ts +1 -1
  218. package/dist/cli/index.js +8 -8
  219. package/dist/cli/{init-B_CCByIh.js → init-DLLfL1uL.js} +9 -9
  220. package/dist/cli/{live-DjjMID3V.js → live-D4giSEyd.js} +2 -2
  221. package/dist/cli/{mcp-BYwrZHp1.js → mcp-DwjeMbmV.js} +2 -2
  222. package/dist/cli/{memo-backend-BIHqP1uE.js → memo-backend-DPGMyJvH.js} +1 -1
  223. package/dist/cli/{metadata-DCtLUYqR.js → metadata-Cft3CW1M.js} +4 -4
  224. package/dist/cli/{migrate-Bq6CUPbE.js → migrate-Ci_UUuPv.js} +1 -1
  225. package/dist/cli/{migration-safety-BvJ-JK5n.js → migration-safety-D3raBuJx.js} +2 -2
  226. package/dist/cli/{module-migration-Dv6VV1om.js → module-migration-DZtxNO8A.js} +1 -1
  227. package/dist/cli/{partition-C4g7WAwh.js → partition-DWJ6icQ5.js} +3 -3
  228. package/dist/cli/{powersync-1HMiZhFF.js → powersync-BAyDVR-N.js} +4 -4
  229. package/dist/cli/powersync-DnKUA1tu.js +1 -0
  230. package/dist/cli/{print-D9biMrfv.js → print-BSy5c62C.js} +2 -2
  231. package/dist/cli/{providers-C5fw9XC_.js → providers-BbFKOale.js} +1 -1
  232. package/dist/cli/{prune-workflows-DxpPCevB.js → prune-workflows-VY7C9vhb.js} +3 -3
  233. package/dist/cli/{remove-CyhSdPkK.js → remove-CcBoTjEO.js} +6 -6
  234. package/dist/cli/{render-DOz25g5T.js → render-CIrcdge6.js} +5 -5
  235. package/dist/cli/{render-cache-CInSNFhV.js → render-cache-bbL2UdJ6.js} +1 -1
  236. package/dist/cli/{round-trips-D2KD5Hpq.js → round-trips-n_Dk1iUI.js} +1 -3
  237. package/dist/cli/{run-0bMsZ1VV.js → run-D_p_WkPh.js} +7 -7
  238. package/dist/cli/{run-DVdkD1MI.js → run-qCtE--0z.js} +35 -35
  239. package/dist/cli/seed-CucH5loT.js +1 -0
  240. package/dist/cli/{seed-DVKgi-7l.js → seed-CvDA1ItH.js} +2 -2
  241. package/dist/cli/{shared-D2i8_u-U.js → shared-CkqZm0Bz.js} +1 -1
  242. package/dist/cli/{source-args-B3Rowfv5.js → source-args-yU6N6JLm.js} +1 -1
  243. package/dist/cli/{source-BGVOuWXq.js → source-io7b1UpH.js} +1 -1
  244. package/dist/cli/{spec-C_JKo_dP.js → spec-QGOfTJvS.js} +1 -1
  245. package/dist/cli/{spec-COotILIk.js → spec-djAAvGKU.js} +2 -2
  246. package/dist/cli/{sql-layout-D8dIzdy9.js → sql-layout-1ASqdR4g.js} +3 -3
  247. package/dist/cli/{squash-xCseaSP1.js → squash-DEmB47YZ.js} +1 -1
  248. package/dist/cli/{sync-Ceqa-3R6.js → sync-CUcxtnwa.js} +4 -4
  249. package/dist/cli/{upgrade-CUNKALDw.js → upgrade-DV9mKpAp.js} +5 -5
  250. package/dist/cli/{upgrade-DiMHauEU.js → upgrade-FWW6hKCv.js} +5 -5
  251. package/dist/cli/{verify-BFLaU6w3.js → verify-CrFHs8Lr.js} +2 -2
  252. package/dist/cli/{version-C7imaHag.js → version-CSdXYnhG.js} +1 -1
  253. package/dist/client/index.d.ts +3 -3
  254. package/dist/client/native/index.d.ts +1 -1
  255. package/dist/client/native/index.js +1 -1
  256. package/dist/{composite-DYAp3Znr.js → composite-WUO6K2Hu.js} +1 -1
  257. package/dist/config/index.d.ts +2 -2
  258. package/dist/config/index.js +2 -2
  259. package/dist/{config-DzPViWQU.js → config-C3yry9U5.js} +2 -1
  260. package/dist/{context-DMBXEzQa.d.ts → context-DMTfze4z.d.ts} +2 -1
  261. package/dist/contract/index.d.ts +1 -1
  262. package/dist/{controller-CaZv50cD.d.ts → controller-l9h4TtKg.d.ts} +1 -1
  263. package/dist/{conversion-D2key0v9.d.ts → conversion-D70FELty.d.ts} +1 -1
  264. package/dist/create/index.d.ts +4 -4
  265. package/dist/create/index.js +1 -1
  266. package/dist/create/lite/index.d.ts +2 -2
  267. package/dist/create/lite/index.js +3 -3
  268. package/dist/{define-block-kWv1wYf7.d.ts → define-block-D-Z8xB6y.d.ts} +5 -0
  269. package/dist/{define-runtime-full-Bh5c_01f.js → define-runtime-full-C4eTtJAx.js} +42 -35
  270. package/dist/{drive-Bm-up0KU.d.ts → drive-DrD94tWF.d.ts} +1 -1
  271. package/dist/edge/index.js +4 -4
  272. package/dist/{entitlements-UGUF2RJv.d.ts → entitlements-B6q7TIMP.d.ts} +2 -2
  273. package/dist/{executor-B0nTn-4Q.js → executor-BmcRcw83.js} +1 -1
  274. package/dist/expo/index.js +3 -3
  275. package/dist/{extract-Bs_b4ZIX.d.ts → extract-D4QPFB_M.d.ts} +1 -1
  276. package/dist/{extras-C258FsPj.d.ts → extras-C0cnpjDP.d.ts} +1 -1
  277. package/dist/{field-errors-BKCtkPxS.d.ts → field-errors-Br3wwgbu.d.ts} +2 -2
  278. package/dist/{former-permission-keys-hL23tm66.js → former-permission-keys-BwJW5uc6.js} +2 -1
  279. package/dist/{framework-C9UiMaOq.js → framework-CbjS8M33.js} +1 -1
  280. package/dist/generators/factories/index.d.ts +1 -1
  281. package/dist/generators/factories/index.js +1 -1
  282. package/dist/generators/index.d.ts +2 -2
  283. package/dist/generators/json-schema/index.d.ts +2 -2
  284. package/dist/generators/json-schema/index.js +1 -1
  285. package/dist/generators/nuqs/index.d.ts +1 -1
  286. package/dist/generators/nuqs/index.js +1 -1
  287. package/dist/generators/standard-schema/index.d.ts +1 -1
  288. package/dist/generators/standard-schema/index.js +1 -1
  289. package/dist/generators/valibot/index.d.ts +1 -1
  290. package/dist/generators/valibot/index.js +1 -1
  291. package/dist/generators/zod/index.d.ts +1 -1
  292. package/dist/generators/zod/index.js +1 -1
  293. package/dist/hono/index.js +3 -3
  294. package/dist/{index-BZdSOt51.d.ts → index-B4uPo3Sr.d.ts} +1 -1
  295. package/dist/{index-CIVA5x1i.d.ts → index-B6h9m3ml.d.ts} +2 -2
  296. package/dist/{index-DebFs8qq.d.ts → index-BFvj-fNS.d.ts} +1 -1
  297. package/dist/{index-icogJj2C.d.ts → index-BWxcC8ll.d.ts} +2 -2
  298. package/dist/{index-BG-WQ0JH.d.ts → index-BZHDwHGW.d.ts} +1 -1
  299. package/dist/{index-DWxio8F_.d.ts → index-BbpacfC0.d.ts} +7 -7
  300. package/dist/{index-DRKAMZV3.d.ts → index-BfoKErj3.d.ts} +1 -1
  301. package/dist/{index-BMh8ACKR.d.ts → index-BquYRGtV.d.ts} +1 -1
  302. package/dist/{index-48l12mNt.d.ts → index-C7Tcervm.d.ts} +2 -2
  303. package/dist/{index-DLVuARYk.d.ts → index-C9p3wiWn.d.ts} +6 -6
  304. package/dist/{index-R_k3Nh4y.d.ts → index-CHOeFZUB.d.ts} +3 -3
  305. package/dist/{index-CjeQqQzW.d.ts → index-Cg0lDbXs.d.ts} +2 -2
  306. package/dist/{index-B64DT6Io.d.ts → index-CnTxcNyl.d.ts} +1 -1
  307. package/dist/{index-DgiSwhKf.d.ts → index-D3d7m03L.d.ts} +1 -1
  308. package/dist/{index-CkCuMFVG.d.ts → index-DG187JM_.d.ts} +1 -1
  309. package/dist/{index-C_DCvnW0.d.ts → index-DGszLnec.d.ts} +1 -1
  310. package/dist/{index-D2aht6Cz.d.ts → index-DHjZvZWC.d.ts} +2 -2
  311. package/dist/{index-Mq2z-GgJ.d.ts → index-DK0Hj3pi.d.ts} +1 -1
  312. package/dist/{index-CDCyOPT7.d.ts → index-DKuOnwh6.d.ts} +2 -2
  313. package/dist/{index-CDrLyU72.d.ts → index-DLlAc0wg.d.ts} +1 -1
  314. package/dist/{index-GamVr8VZ.d.ts → index-DMyMrXPW.d.ts} +1 -1
  315. package/dist/{index-DskEpSgl.d.ts → index-DU_gZYuh.d.ts} +1 -1
  316. package/dist/{index-CDxfstYD.d.ts → index-DYX_uL5t.d.ts} +1 -1
  317. package/dist/{index-BJ1Mv0TK.d.ts → index-D_xJSanv.d.ts} +1 -1
  318. package/dist/{index-DOBq5QFe.d.ts → index-Dg4lbDzI.d.ts} +1 -1
  319. package/dist/{index-BYx-ObF-.d.ts → index-DkALeCTq.d.ts} +1 -1
  320. package/dist/{index-DIK12ZTb.d.ts → index-DtVZnjKf.d.ts} +2 -2
  321. package/dist/{index-BBf3nn7Y.d.ts → index-Dyns9a8l.d.ts} +1 -1
  322. package/dist/{index-B6i7w-iS.d.ts → index-NNox0BqF.d.ts} +1 -1
  323. package/dist/{index-CzNRwKGG.d.ts → index-WuUhLgMp.d.ts} +2 -2
  324. package/dist/{index-DcdC0Qll.d.ts → index-X-ihJBuJ.d.ts} +1 -1
  325. package/dist/{index-rFIDpwjh.d.ts → index-jCKNxp8C.d.ts} +1 -1
  326. package/dist/{index-BtuseUSW.d.ts → index-o2y0w9lX.d.ts} +1 -1
  327. package/dist/{index-nsEUHz98.d.ts → index-ouiV6zqH.d.ts} +2 -2
  328. package/dist/{index-B67YUNow.d.ts → index-qzFFTwel.d.ts} +1 -1
  329. package/dist/{json-schema-CgwH39-G.js → json-schema-B8f7HdoX.js} +1 -1
  330. package/dist/{manifest-DcnVXlH7.d.ts → manifest--_00y416.d.ts} +1 -1
  331. package/dist/{manifest-CxUI9ZXn.d.ts → manifest-B7lSTuVC.d.ts} +1 -1
  332. package/dist/{manifest-Cz8poTZ2.d.ts → manifest-BA-urVob.d.ts} +1 -1
  333. package/dist/{manifest-ChKRtAF6.d.ts → manifest-BAn3lTr4.d.ts} +1 -1
  334. package/dist/{manifest-tjlvcP1t.d.ts → manifest-BESrR9Xp.d.ts} +1 -1
  335. package/dist/{manifest-BkJdR1D-.d.ts → manifest-BEw6nEKW.d.ts} +1 -1
  336. package/dist/{manifest-C7bh84U0.d.ts → manifest-BGmmK9bZ.d.ts} +1 -1
  337. package/dist/{manifest-B7IYj4OA.d.ts → manifest-BMcuCUre.d.ts} +1 -1
  338. package/dist/{manifest-BG2_hkzB.d.ts → manifest-BS8p47JO.d.ts} +1 -1
  339. package/dist/{manifest-C7CtYgWC.d.ts → manifest-BYv5BqtY.d.ts} +1 -1
  340. package/dist/{manifest-9TRpR9P-.d.ts → manifest-B_2lEGUS.d.ts} +1 -1
  341. package/dist/{manifest-BSSoVDlI.d.ts → manifest-BgmY9fuz.d.ts} +1 -1
  342. package/dist/{manifest-C1TwYhyr.d.ts → manifest-BoUGzBpS.d.ts} +1 -1
  343. package/dist/{manifest-D02pP9Nl.d.ts → manifest-BvzmDxod.d.ts} +1 -1
  344. package/dist/{manifest-Ce_JDK4r.d.ts → manifest-ByNpLQWh.d.ts} +1 -1
  345. package/dist/{manifest-CpMVJWDU.d.ts → manifest-ByV81mLa.d.ts} +1 -1
  346. package/dist/{manifest-DBptC4dz.d.ts → manifest-C-pVDUC6.d.ts} +1 -1
  347. package/dist/{manifest-Cx_UVMlT.d.ts → manifest-C0v6IEWk.d.ts} +1 -1
  348. package/dist/{manifest-DAv6iO-q.d.ts → manifest-C5LxShda.d.ts} +1 -1
  349. package/dist/{manifest-DZc_37YJ.d.ts → manifest-C8PUzse6.d.ts} +1 -1
  350. package/dist/{manifest-BdV9GNAF.d.ts → manifest-CCKfdYiH.d.ts} +1 -1
  351. package/dist/{manifest-BNCX3M2Y.d.ts → manifest-CIVhJzKF.d.ts} +1 -1
  352. package/dist/{manifest-BmGsyaxx.d.ts → manifest-CKCaFg8y.d.ts} +1 -1
  353. package/dist/{manifest-BXatXuLx.d.ts → manifest-CKDaQT_5.d.ts} +1 -1
  354. package/dist/{manifest-blSYzmEZ.d.ts → manifest-CLukD6aB.d.ts} +1 -1
  355. package/dist/{manifest-BSrdiUHP.d.ts → manifest-CNLJLsHB.d.ts} +1 -1
  356. package/dist/{manifest-t9v09kRa.d.ts → manifest-CWwdLMT0.d.ts} +1 -1
  357. package/dist/{manifest-Dc_FWIrg.d.ts → manifest-CXYg8gzt.d.ts} +1 -1
  358. package/dist/{manifest-BOxu_JMd.d.ts → manifest-CZoRtSvn.d.ts} +1 -1
  359. package/dist/{manifest-Cle7S3sn.d.ts → manifest-Ch08RUKa.d.ts} +1 -1
  360. package/dist/{manifest-BWE_47qq.d.ts → manifest-CjzlsilW.d.ts} +1 -1
  361. package/dist/{manifest-CD_ZA69x.d.ts → manifest-Clzy2rSU.d.ts} +1 -1
  362. package/dist/{manifest-B91B3Yvk.d.ts → manifest-Co41j70r.d.ts} +1 -1
  363. package/dist/{manifest-Cn85_kP6.d.ts → manifest-CvncELVO.d.ts} +1 -1
  364. package/dist/{manifest-BKY6WHm6.d.ts → manifest-CxgOFWlh.d.ts} +1 -1
  365. package/dist/{manifest-BizfO8zf.d.ts → manifest-CyaHDD_i.d.ts} +1 -1
  366. package/dist/{manifest-DGrcTY4n.d.ts → manifest-D0eItVsP.d.ts} +1 -1
  367. package/dist/{manifest-BdBaGzfE.d.ts → manifest-D80LSWzZ.d.ts} +1 -1
  368. package/dist/{manifest-LAVlQXiw.d.ts → manifest-DBfQe19Z.d.ts} +1 -1
  369. package/dist/{manifest-C3FjJnQT.d.ts → manifest-DCkeNzPW.d.ts} +1 -1
  370. package/dist/{manifest-Bsrn5gfq.d.ts → manifest-DHTVfgX9.d.ts} +1 -1
  371. package/dist/{manifest-gS-wx2yB.d.ts → manifest-DHulRwzL.d.ts} +1 -1
  372. package/dist/{manifest-CIa0-uCj.d.ts → manifest-DKnWcgse.d.ts} +1 -1
  373. package/dist/{manifest-CTEURHfF.d.ts → manifest-DLSzZMXM.d.ts} +1 -1
  374. package/dist/{manifest-dSiPcx5l.d.ts → manifest-DVZmJvrE.d.ts} +1 -1
  375. package/dist/{manifest-BWFemJ6Q.d.ts → manifest-D_wBteR5.d.ts} +1 -1
  376. package/dist/{manifest-Cfrflbtt.d.ts → manifest-DlLxdk7P.d.ts} +1 -1
  377. package/dist/{manifest-zEA2Tw_l.d.ts → manifest-DofXV9lE.d.ts} +1 -1
  378. package/dist/{manifest-BVwoT7GU.d.ts → manifest-Dp92U_iP.d.ts} +1 -1
  379. package/dist/{manifest-DF6GzdBC.d.ts → manifest-Dpad_5Lw.d.ts} +1 -1
  380. package/dist/{manifest-D4iEPtlb.d.ts → manifest-Dvm2mwFy.d.ts} +1 -1
  381. package/dist/{manifest-1P6OEAwH.d.ts → manifest-Fapf4NdA.d.ts} +1 -1
  382. package/dist/{manifest-CPlmHPRY.d.ts → manifest-QmYmc98q.d.ts} +1 -1
  383. package/dist/{manifest-VjVVI7bV.d.ts → manifest-RitquXSE.d.ts} +1 -1
  384. package/dist/{manifest-BN2J8Zo7.d.ts → manifest-TvLJWs_L.d.ts} +1 -1
  385. package/dist/{manifest-D32p1K-g.d.ts → manifest-V0QSCEfx.d.ts} +1 -1
  386. package/dist/{manifest-BNIvrs6_.d.ts → manifest-VCJSqffq.d.ts} +2 -2
  387. package/dist/{manifest-B-wg2F2L.d.ts → manifest-eUUJnoB5.d.ts} +1 -1
  388. package/dist/{manifest-mCn7RdZs.d.ts → manifest-qvMWfrZ-.d.ts} +1 -1
  389. package/dist/{manifest-khfEDzX4.d.ts → manifest-r6DHrB4Q.d.ts} +1 -1
  390. package/dist/{manifest-BcqqAgm9.d.ts → manifest-ra7MSo-3.d.ts} +1 -1
  391. package/dist/{manifest-SoNChfLL.d.ts → manifest-wbs2VkcB.d.ts} +1 -1
  392. package/dist/mapper/bin.js +6 -6
  393. package/dist/mcp/index.js +1 -1
  394. package/dist/mcp/sdk/index.js +1 -1
  395. package/dist/{mcp-CoJbu0Hk.js → mcp-aMq1fkoe.js} +3 -3
  396. package/dist/next/index.d.ts +4 -4
  397. package/dist/next/index.js +2 -2
  398. package/dist/next/proxy/index.d.ts +2 -2
  399. package/dist/orpc/index.js +2 -2
  400. package/dist/otel/index.js +5 -5
  401. package/dist/{permissions-Ccvec0MR.d.ts → permissions-ZLtxCurD.d.ts} +1 -1
  402. package/dist/powersync/index.d.ts +1 -1
  403. package/dist/powersync/index.js +1 -1
  404. package/dist/preset/index.d.ts +4 -4
  405. package/dist/{preview-CR1nZ6-E.d.ts → preview-BoJkQw2E.d.ts} +2 -2
  406. package/dist/{project-CxoixIpG.js → project-DI09JnXz.js} +2 -2
  407. package/dist/query/index.d.ts +1 -1
  408. package/dist/react/index.d.ts +4 -4
  409. package/dist/react/native/index.d.ts +1 -1
  410. package/dist/react/server.d.ts +4 -4
  411. package/dist/react-router/index.js +3 -3
  412. package/dist/{record-form-mpamIVq3.d.ts → record-form-BHUYs5ju.d.ts} +1 -1
  413. package/dist/records/index.d.ts +5 -5
  414. package/dist/server/index.d.ts +3 -3
  415. package/dist/server/index.js +4 -4
  416. package/dist/{server-CqRpnOo0.js → server-Bgugpk3A.js} +1 -1
  417. package/dist/{sign-in-CMEBFv36.d.ts → sign-in-Dp-X2YXo.d.ts} +3 -3
  418. package/dist/solid/index.d.ts +4 -4
  419. package/dist/solid-start/index.js +3 -3
  420. package/dist/spec/index.js +2 -2
  421. package/dist/sql/index.d.ts +4 -4
  422. package/dist/sql/index.js +1 -1
  423. package/dist/{sql-ZLYXNvXw.js → sql-BqOBYRvI.js} +2 -2
  424. package/dist/sqlite/index.js +1 -1
  425. package/dist/ssr/index.d.ts +1 -1
  426. package/dist/svelte/index.d.ts +4 -4
  427. package/dist/sveltekit/index.js +3 -3
  428. package/dist/tanstack-start/index.js +3 -3
  429. package/dist/{tenant-DpJTJr1c.d.ts → tenant-BQaG8Hma.d.ts} +1 -1
  430. package/dist/testing/index.d.ts +5 -5
  431. package/dist/testing/index.js +3 -3
  432. package/dist/{timeline-CGjiciIY.d.ts → timeline-D7T-qrKN.d.ts} +2 -2
  433. package/dist/{types-BidEA6pZ.d.ts → types-BE6BvLv2.d.ts} +2 -2
  434. package/dist/{version-DRVVrk-u.js → version-CkYT3KbT.js} +1 -1
  435. package/dist/vue/index.d.ts +4 -4
  436. package/dist/webmcp/index.js +1 -1
  437. package/package.json +1 -1
  438. package/schemas/config-v1.json +3 -0
  439. package/schemas/doctor-report-v1.json +2 -0
  440. package/dist/cli/add-DHvo6zQZ.js +0 -1
  441. package/dist/cli/powersync-DLUNuNl4.js +0 -1
  442. 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-z7CrnE1s.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,38 @@ 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-1ASqdR4g.js";
11
+ import { i as request } from "./source-io7b1UpH.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_p_WkPh.js";
16
+ import { r as renderFiles } from "./render-CIrcdge6.js";
17
+ import { l as schemaModulePath, m as configFor, p as notNullTag } from "./emit-qQdWBc9e.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-CZhndoO7.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-oieRU_sP.js";
22
+ import { i as migrationHolds, o as migrationModules, r as latestMigration, t as MODULES_SUFFIX } from "./module-migration-DZtxNO8A.js";
23
+ import { n as renderBlocksCached } from "./render-cache-bbL2UdJ6.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-CkqZm0Bz.js";
25
+ import { n as staleRenameKeys, t as shadowedBlockColumns } from "./column-renames-BEEDF6P6.js";
26
+ import { a as reservedRoles, i as statementsView, n as ident$1, r as literal$1, t as LIVE_RULES } from "./live-D4giSEyd.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-CSdXYnhG.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-D3raBuJx.js";
34
+ import { t as codeRanges } from "./code-ranges-uTOKmIXC.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
+ import { n as ROUND_TRIP_RULES } from "./round-trips-n_Dk1iUI.js";
36
37
  import { a as readSharedMemory, n as listStacks, t as branchName } from "./stacks-Eu6d45F8.js";
37
38
  import { i as plain$2 } from "./style-B5-nByxb.js";
38
- import { i as refuseWithMetadata, r as readMetadataSnapshot } from "./metadata-DCtLUYqR.js";
39
+ import { i as refuseWithMetadata, r as readMetadataSnapshot } from "./metadata-Cft3CW1M.js";
39
40
  import { t as compiledReadSets } from "./read-sets-77o7SxpK.js";
40
- import { a as sourceFlags, n as SOURCE_ARGS } from "./source-args-B3Rowfv5.js";
41
+ import { a as sourceFlags, n as SOURCE_ARGS } from "./source-args-yU6N6JLm.js";
41
42
  import { existsSync } from "node:fs";
42
43
  import { dirname, join, posix, relative, resolve } from "node:path";
43
44
  import { mkdir, readFile, writeFile } from "node:fs/promises";
@@ -1369,7 +1370,7 @@ function writtenTable(owned, schema, name) {
1369
1370
  function blockClientKeys(context) {
1370
1371
  return new Set(context.config.blockNames.flatMap((name) => [name, name.replaceAll(/-([a-z0-9])/g, (_, char) => char.toUpperCase())]));
1371
1372
  }
1372
- function writesIn(text, owned, clients) {
1373
+ function writesIn$1(text, owned, clients) {
1373
1374
  const direct = [...text.matchAll(DIRECT_WRITE)].flatMap((match) => {
1374
1375
  const [, schema, name = "", method = ""] = match;
1375
1376
  const entry = writtenTable(owned, schema, name);
@@ -1401,7 +1402,7 @@ function directBlockWrites(context) {
1401
1402
  const owned = ownedTables(context);
1402
1403
  if (owned.qualified.size === 0) return [];
1403
1404
  const clients = blockClientKeys(context);
1404
- return context.sources.flatMap((file) => writesIn(file.text, owned, clients).map(({ index, method, entry }) => {
1405
+ return context.sources.flatMap((file) => writesIn$1(file.text, owned, clients).map(({ index, method, entry }) => {
1405
1406
  const line = lineAt$1(file.text, index);
1406
1407
  return {
1407
1408
  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 +2502,7 @@ const IMPORT_GUARD_RULES = [{
2501
2502
  }
2502
2503
  }];
2503
2504
  // src/cli/doctor/lite.ts
2504
- const RPC_CALL = /(?:\.|\$)rpc\s*\(|\brpcTransport\s*\(/;
2505
+ const RPC_CALL$1 = /(?:\.|\$)rpc\s*\(|\brpcTransport\s*\(/;
2505
2506
  const MISSING_FEATURES = [{
2506
2507
  feature: "Realtime",
2507
2508
  pattern: /from\s+["']better-supabase\/realtime["']|\.channel\s*\(|\.removeChannel\s*\(/
@@ -2524,7 +2525,7 @@ function rpcOnSqlite(context) {
2524
2525
  const driver = liteDriver(context);
2525
2526
  if (driver === void 0 || !isSqliteLiteDriver(driver)) return [];
2526
2527
  return context.sources.flatMap((file) => {
2527
- const line = lineOf(file.text, RPC_CALL);
2528
+ const line = lineOf(file.text, RPC_CALL$1);
2528
2529
  if (line === void 0) return [];
2529
2530
  return [{
2530
2531
  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 +2735,7 @@ const OLD_NAMES = NAMING_RENAMES.filter((rename) => SOURCE_KINDS.has(rename.kind
2734
2735
  pattern: new RegExp(rename.kind === "subpath" ? `better-supabase/${escaped(rename.from)}(?![\\w-])` : `(?<![A-Za-z0-9_])${escaped(rename.from)}(?![A-Za-z0-9_])`)
2735
2736
  }));
2736
2737
  const isRecord = (value) => typeof value === "object" && value !== null;
2737
- const camel$1 = (name) => name.replaceAll(/[_-]+([a-z0-9])/g, (_, letter) => letter.toUpperCase());
2738
+ const camel$2 = (name) => name.replaceAll(/[_-]+([a-z0-9])/g, (_, letter) => letter.toUpperCase());
2738
2739
  /**
2739
2740
  * The argument names of verbs on an entity the config renamed: an app whose
2740
2741
  * `names.<entity>.name` is `work_item` keeps `workItemId` and `workItemIds`.
@@ -2742,7 +2743,7 @@ const camel$1 = (name) => name.replaceAll(/[_-]+([a-z0-9])/g, (_, letter) => let
2742
2743
  function renamedEntityArguments(blocks) {
2743
2744
  const kept = /* @__PURE__ */ new Set();
2744
2745
  const keep = (name) => {
2745
- if (typeof name === "string") kept.add(`${camel$1(name)}Id`).add(`${camel$1(name)}Ids`);
2746
+ if (typeof name === "string") kept.add(`${camel$2(name)}Id`).add(`${camel$2(name)}Ids`);
2746
2747
  };
2747
2748
  for (const block of Object.values(blocks)) {
2748
2749
  if (!isRecord(block)) continue;
@@ -3829,6 +3830,563 @@ function aal2WithoutMfa(context) {
3829
3830
  }
3830
3831
  }];
3831
3832
  }
3833
+ // src/cli/doctor/n-plus-one.ts
3834
+ /**
3835
+ * A receiver that names the better-supabase client: `db`, `ctx.db`, `tx`,
3836
+ * `bsb.db()`.
3837
+ */
3838
+ const DB = String.raw`(?<![\w$])(?:db|[a-z][\w$]*Db|tx|trx)(?:\(\))?`;
3839
+ 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");
3840
+ const BLOCK_CALL = new RegExp(String.raw`(?:${DB}\s*\.\s*\$blocks|(?<![\w$])blocks)\s*\.\s*[\w$]+\s*\.\s*([\w$]+)\s*\(`, "g");
3841
+ const RPC_CALL = /\.\s*\$(?:rpc|search|run|many)\s*\(|(?<![\w$])[\w$]*supabase[\w$]*\s*\.\s*rpc\s*\(/gi;
3842
+ const FROM_SELECT = /\.\s*from\s*\(([\w$.\s]*)\)\s*\.\s*select\s*\(/g;
3843
+ const SERVICE_READ = /(?<![\w$])([\w$]+)\s*\.\s*((?:get|list|load|find|fetch|count|read|search)[A-Z][\w$]*)\s*\(/g;
3844
+ const SERVICE_WRITE = /(?<![\w$])([\w$]+)\s*\.\s*([a-z][\w$]*)\s*\(/g;
3845
+ const SERVICE_NAME = /(?:services?|repositor(?:y|ies)|repos?|queries|readers?)$/i;
3846
+ const SERVICE_FACTORY = /(?:const|let)\s+(\{[^}]*\}|[\w$]+)\s*=\s*(?:await\s+)?create[\w$]*(?:Services?|Repositor(?:y|ies)|Repos?)\s*\(/g;
3847
+ /** A block method or a local function whose name says it writes. */
3848
+ 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)(?:[A-Z_\d]|$)/;
3849
+ 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*\(`);
3850
+ const LOCAL_FUNCTION = /(?:function\s*\*?\s*([\w$]+)\s*(?:<[^>]*>)?\s*\(|(?:const|let)\s+([\w$]+)\s*(?::[^=]+)?=\s*(?:async\s+)?(?:function\b[^(]*\(|\(|[\w$]+\s*=>))/g;
3851
+ const LOOP = /(?<![\w$.])for\s*(?:await\s*)?\(/g;
3852
+ const CALLBACK = /\.\s*(?:map|flatMap|forEach)\s*\(/g;
3853
+ const DECLARATION = /(?<![\w$.])(?:const|let|var)\s+([\w$]+|\{[^=;]*?\}|\[[^=;]*?\])\s*(?::[^=;]+)?=(?!=|>)/g;
3854
+ /**
3855
+ * Iterables that are already batches, or retries of one read: `for (const chunk
3856
+ * of chunks)`, `for (const attempt of attempts)`.
3857
+ */
3858
+ const BATCHES = /chunk|batch|attempt|retr/i;
3859
+ const OPEN = /* @__PURE__ */ new Set([
3860
+ "(",
3861
+ "[",
3862
+ "{"
3863
+ ]);
3864
+ const CLOSE = /* @__PURE__ */ new Set([
3865
+ ")",
3866
+ "]",
3867
+ "}"
3868
+ ]);
3869
+ /** `text` with strings, template literals and comments blanked, offsets kept. */
3870
+ function codeOnly(text) {
3871
+ let out = "";
3872
+ let last = 0;
3873
+ const blank = (part) => part.replaceAll(/[^\n]/g, " ");
3874
+ for (const [start, end] of codeRanges(text)) {
3875
+ out += blank(text.slice(last, start)) + text.slice(start, end);
3876
+ last = end;
3877
+ }
3878
+ return out + blank(text.slice(last));
3879
+ }
3880
+ /** The index of the bracket that closes the one at `open`. */
3881
+ function closeOf(code, open) {
3882
+ let depth = 0;
3883
+ for (let index = open; index < code.length; index += 1) {
3884
+ const char = code.charAt(index);
3885
+ if (OPEN.has(char)) depth += 1;
3886
+ else if (CLOSE.has(char)) {
3887
+ depth -= 1;
3888
+ if (depth === 0) return index;
3889
+ }
3890
+ }
3891
+ return code.length;
3892
+ }
3893
+ /** The end of the statement or expression that starts at `from`. */
3894
+ function statementEnd(code, from) {
3895
+ let depth = 0;
3896
+ for (let index = from; index < code.length; index += 1) {
3897
+ const char = code.charAt(index);
3898
+ if (OPEN.has(char)) depth += 1;
3899
+ else if (CLOSE.has(char)) {
3900
+ if (depth === 0) return index;
3901
+ depth -= 1;
3902
+ } else if ((char === ";" || char === ",") && depth === 0) return index;
3903
+ }
3904
+ return code.length;
3905
+ }
3906
+ /** The names a binding pattern declares: `x`, `{ a, b: c }`, `[d, ...e]`. */
3907
+ function boundNames(pattern) {
3908
+ const trimmed = pattern.trim();
3909
+ if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) return /^[\w$]+$/.test(trimmed) ? [trimmed] : [];
3910
+ return [...trimmed.matchAll(/[A-Za-z_$][\w$]*(?!\s*:)/g)].filter((match) => trimmed.charAt(match.index - 1) !== ".").map((match) => match[0]);
3911
+ }
3912
+ /** The bound names of a parameter list, without types and defaults. */
3913
+ function parameterNames(list) {
3914
+ const names = [];
3915
+ let depth = 0;
3916
+ let start = 0;
3917
+ const take = (part) => {
3918
+ let inner = 0;
3919
+ let end = part.length;
3920
+ for (let index = 0; index < part.length; index += 1) {
3921
+ const char = part.charAt(index);
3922
+ inner += OPEN.has(char) ? 1 : CLOSE.has(char) ? -1 : 0;
3923
+ if (inner === 0 && (char === ":" || char === "=")) {
3924
+ end = index;
3925
+ break;
3926
+ }
3927
+ }
3928
+ names.push(...boundNames(part.slice(0, end).replace(/^\s*\.\.\./, "")));
3929
+ };
3930
+ for (let index = 0; index < list.length; index += 1) {
3931
+ const char = list.charAt(index);
3932
+ depth += OPEN.has(char) ? 1 : CLOSE.has(char) ? -1 : 0;
3933
+ if (char === "," && depth === 0) {
3934
+ take(list.slice(start, index));
3935
+ start = index + 1;
3936
+ }
3937
+ }
3938
+ take(list.slice(start));
3939
+ return names;
3940
+ }
3941
+ /** Whether `text` uses `name` as a value, not as a key or a property. */
3942
+ function mentions(text, name) {
3943
+ const escaped = name.replaceAll("$", String.raw`\$`);
3944
+ return new RegExp(String.raw`(?<![\w$.])${escaped}(?![\w$])(?!\s*:(?!:))`).test(text);
3945
+ }
3946
+ const camel$1 = (name) => name.replaceAll(/_([a-z\d])/g, (_, char) => char.toUpperCase());
3947
+ const compact = (text) => text.replaceAll(/\s+/g, " ").replaceAll(/\s*\.\s*/g, ".").replaceAll(/([([])\s+|\s+(?=[)\]])/g, "$1").trim();
3948
+ /** `customer_assets` and `customerAssets` compare equal. */
3949
+ const tableKey$1 = (name) => name.toLowerCase().replaceAll("_", "");
3950
+ const rpcName = (text, open) => /^\s*["'`]([\w.]+)/.exec(text.slice(open + 1))?.[1]?.split(".").at(-1);
3951
+ /**
3952
+ * Offsets of calls that write: repository and supabase-js writes, RPCs, block
3953
+ * methods and service methods named for a write.
3954
+ */
3955
+ function writesIn(text, code, services) {
3956
+ const writes = [...code.matchAll(new RegExp(REPOSITORY_WRITE, "g"))].map((match) => match.index);
3957
+ for (const match of code.matchAll(RPC_CALL)) {
3958
+ const name = rpcName(text, match.index + match[0].length - 1);
3959
+ if (name !== void 0 && WRITE_NAME.test(camel$1(name))) writes.push(match.index);
3960
+ }
3961
+ for (const match of code.matchAll(BLOCK_CALL)) if (WRITE_NAME.test(match[1])) writes.push(match.index);
3962
+ for (const match of code.matchAll(SERVICE_WRITE)) if (isService(match[1], services) && WRITE_NAME.test(match[2])) writes.push(match.index);
3963
+ return writes;
3964
+ }
3965
+ /** Reads by the database client itself, before following local functions. */
3966
+ function directReads(text, code) {
3967
+ const reads = [];
3968
+ const add = (match, kind, table, method) => {
3969
+ const open = match.index + match[0].length - 1;
3970
+ let call = compact(text.slice(match.index, open));
3971
+ if (kind === "rpc") {
3972
+ const name = rpcName(text, open);
3973
+ if (name !== void 0 && WRITE_NAME.test(camel$1(name))) return;
3974
+ call = name === void 0 ? call : `${call}("${name}")`;
3975
+ }
3976
+ let close = closeOf(code, open);
3977
+ 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);
3978
+ reads.push({
3979
+ start: match.index,
3980
+ open,
3981
+ close,
3982
+ call,
3983
+ kind,
3984
+ ...table === void 0 ? {} : { table },
3985
+ ...method === void 0 ? {} : { method }
3986
+ });
3987
+ };
3988
+ for (const match of code.matchAll(REPOSITORY_READ)) add(match, "table", match[1], match[2]);
3989
+ for (const match of code.matchAll(BLOCK_CALL)) if (!WRITE_NAME.test(match[1])) add(match, "other");
3990
+ for (const match of code.matchAll(RPC_CALL)) add(match, "rpc");
3991
+ for (const match of code.matchAll(FROM_SELECT)) {
3992
+ const from = match.index + match[0].indexOf("(");
3993
+ const table = /["'`]([\w.]+)["'`]/.exec(text.slice(from, from + match[1].length + 2))?.[1];
3994
+ add(match, "table", table?.split(".").at(-1));
3995
+ }
3996
+ return reads;
3997
+ }
3998
+ /**
3999
+ * Local functions that read and never write, followed through each other within
4000
+ * the file, mapped to the read they make.
4001
+ */
4002
+ function readerFunctions(code, direct) {
4003
+ const bodies = /* @__PURE__ */ new Map();
4004
+ for (const match of code.matchAll(LOCAL_FUNCTION)) {
4005
+ const name = match[1] ?? match[2];
4006
+ const params = match.index + match[0].length - 1;
4007
+ const afterParams = code.charAt(params) === "(" ? closeOf(code, params) + 1 : params;
4008
+ const arrow = code.indexOf("=>", afterParams);
4009
+ const brace = code.indexOf("{", afterParams);
4010
+ const start = arrow !== -1 && (brace === -1 || arrow < brace) ? arrow + 2 : brace;
4011
+ if (start === -1 || WRITE_NAME.test(name)) continue;
4012
+ const open = /^\s*\{/.test(code.slice(start)) ? code.indexOf("{", start) : -1;
4013
+ const end = open === -1 ? statementEnd(code, start) : closeOf(code, open);
4014
+ bodies.set(name, {
4015
+ start,
4016
+ end
4017
+ });
4018
+ }
4019
+ const readers = /* @__PURE__ */ new Map();
4020
+ for (const [name, body] of bodies) {
4021
+ const slice = code.slice(body.start, body.end);
4022
+ const read = direct.find((candidate) => candidate.start > body.start && candidate.start < body.end);
4023
+ if (read !== void 0 && !REPOSITORY_WRITE.test(slice)) readers.set(name, read);
4024
+ }
4025
+ let grew = true;
4026
+ while (grew) {
4027
+ grew = false;
4028
+ for (const [name, body] of bodies) {
4029
+ if (readers.has(name)) continue;
4030
+ const slice = code.slice(body.start, body.end);
4031
+ if (REPOSITORY_WRITE.test(slice)) continue;
4032
+ for (const [reader, read] of readers) if (reader !== name && callsOf(slice, reader).length > 0) {
4033
+ readers.set(name, read);
4034
+ grew = true;
4035
+ break;
4036
+ }
4037
+ }
4038
+ }
4039
+ return readers;
4040
+ }
4041
+ /** Offsets of `name(` calls that aren't a property, a definition or a method. */
4042
+ function callsOf(code, name) {
4043
+ const escaped = name.replaceAll("$", String.raw`\$`);
4044
+ 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);
4045
+ }
4046
+ /** Names bound to the result of a `create...Service(...)` factory. */
4047
+ function serviceNames(code) {
4048
+ const services = /* @__PURE__ */ new Set();
4049
+ for (const match of code.matchAll(SERVICE_FACTORY)) for (const name of boundNames(match[1])) services.add(name);
4050
+ return services;
4051
+ }
4052
+ const isService = (receiver, services) => services.has(receiver) || SERVICE_NAME.test(receiver);
4053
+ /** Every read in the file, including calls to readers and service reads. */
4054
+ function readsIn(text, code, services) {
4055
+ const direct = directReads(text, code);
4056
+ const reads = [...direct];
4057
+ for (const [name, read] of readerFunctions(code, direct)) for (const start of callsOf(code, name)) {
4058
+ const open = code.indexOf("(", start);
4059
+ reads.push({
4060
+ start,
4061
+ open,
4062
+ close: closeOf(code, open),
4063
+ call: `${name} (which calls ${read.call})`,
4064
+ kind: "other"
4065
+ });
4066
+ }
4067
+ for (const match of code.matchAll(SERVICE_READ)) {
4068
+ const receiver = match[1];
4069
+ if (!isService(receiver, services)) continue;
4070
+ const open = match.index + match[0].length - 1;
4071
+ reads.push({
4072
+ start: match.index,
4073
+ open,
4074
+ close: closeOf(code, open),
4075
+ call: `${receiver}.${match[2]}`,
4076
+ kind: "other"
4077
+ });
4078
+ }
4079
+ return reads.toSorted((a, b) => a.start - b.start);
4080
+ }
4081
+ /** The expression before `.map(` that starts at `end`, such as `page.ids`. */
4082
+ function receiverBefore(code, end) {
4083
+ let start = end;
4084
+ while (start > 0) {
4085
+ const char = code.charAt(start - 1);
4086
+ if (char === ")" || char === "]") {
4087
+ let depth = 0;
4088
+ for (start -= 1; start >= 0; start -= 1) {
4089
+ const inner = code.charAt(start);
4090
+ depth += CLOSE.has(inner) ? 1 : OPEN.has(inner) ? -1 : 0;
4091
+ if (depth === 0) break;
4092
+ }
4093
+ } else if (/[\w$.?!]/.test(char) || /\s/.test(char) && /^\??\./.test(code.slice(start).trimStart())) start -= 1;
4094
+ else break;
4095
+ }
4096
+ return code.slice(start, end).trim().replace(/^\.\.\./, "");
4097
+ }
4098
+ /** `for (... of ...)` bodies and `.map/.flatMap/.forEach` callbacks. */
4099
+ function scopesIn(code) {
4100
+ const scopes = [];
4101
+ for (const match of code.matchAll(LOOP)) {
4102
+ const open = match.index + match[0].length - 1;
4103
+ const close = closeOf(code, open);
4104
+ const header = /^\s*(?:const|let|var)\s+([\s\S]+?)\s+of\s+([\s\S]+)$/.exec(code.slice(open + 1, close));
4105
+ if (!header) continue;
4106
+ const bodyStart = close + 1;
4107
+ const end = /^\s*\{/.test(code.slice(bodyStart)) ? closeOf(code, code.indexOf("{", bodyStart)) : statementEnd(code, bodyStart);
4108
+ scopes.push({
4109
+ start: bodyStart,
4110
+ end,
4111
+ items: compact(header[2]),
4112
+ names: boundNames(header[1])
4113
+ });
4114
+ }
4115
+ for (const match of code.matchAll(CALLBACK)) {
4116
+ const open = match.index + match[0].length - 1;
4117
+ const close = closeOf(code, open);
4118
+ const callback = /^\s*(?:async\s+)?(?:function\s*[\w$]*\s*\(|\(|([\w$]+)\s*=>)/.exec(code.slice(open + 1, close));
4119
+ if (!callback) continue;
4120
+ let names;
4121
+ let start;
4122
+ if (callback[1] === void 0) {
4123
+ const params = open + callback[0].length;
4124
+ const paramsEnd = closeOf(code, params);
4125
+ names = parameterNames(code.slice(params + 1, paramsEnd));
4126
+ start = paramsEnd + 1;
4127
+ } else {
4128
+ names = [callback[1]];
4129
+ start = open + 1 + callback[0].length;
4130
+ }
4131
+ scopes.push({
4132
+ start,
4133
+ end: close,
4134
+ items: compact(receiverBefore(code, match.index)),
4135
+ names
4136
+ });
4137
+ }
4138
+ return scopes.toSorted((a, b) => a.end - a.start - (b.end - b.start));
4139
+ }
4140
+ /** Names in `scope` that hold the loop variable, or something derived from it. */
4141
+ function scopeNames(code, scope) {
4142
+ const names = [...scope.names];
4143
+ const body = code.slice(scope.start, scope.end);
4144
+ for (const match of body.matchAll(DECLARATION)) {
4145
+ const from = match.index + match[0].length;
4146
+ const init = body.slice(from, statementEnd(body, from));
4147
+ if (names.some((name) => mentions(init, name))) names.push(...boundNames(match[1]));
4148
+ }
4149
+ return names;
4150
+ }
4151
+ /** The innermost `{` before `at` that is still open there, and its close. */
4152
+ function enclosingEnd(code, at) {
4153
+ let depth = 0;
4154
+ for (let index = at; index < code.length; index += 1) {
4155
+ const char = code.charAt(index);
4156
+ if (OPEN.has(char)) depth += 1;
4157
+ else if (CLOSE.has(char)) {
4158
+ depth -= 1;
4159
+ if (depth < 0) return index;
4160
+ }
4161
+ }
4162
+ return code.length;
4163
+ }
4164
+ /** Variables that hold rows of an earlier awaited table read, and their scope. */
4165
+ function originsIn(text, code, reads) {
4166
+ const origins = [];
4167
+ const lineAt = lines$1(text);
4168
+ for (const match of code.matchAll(DECLARATION)) {
4169
+ const from = match.index + match[0].length;
4170
+ const end = statementEnd(code, from);
4171
+ const init = code.slice(from, end);
4172
+ const names = boundNames(match[1]);
4173
+ const scope = {
4174
+ from: end,
4175
+ to: enclosingEnd(code, match.index)
4176
+ };
4177
+ const inside = reads.filter((read) => read.start >= from && read.start < end);
4178
+ if (/^\s*await\b/.test(init) && inside.length > 0) {
4179
+ const all = /^\s*await\s+Promise\.all\s*\(\s*\[/.exec(init);
4180
+ const pattern = match[1].trim();
4181
+ if (all && pattern.startsWith("[")) {
4182
+ const entries = splitTop(code.slice(from + all[0].length, closeOf(code, from + all[0].length - 1)));
4183
+ let offset = from + all[0].length;
4184
+ for (const [index, entry] of entries.entries()) {
4185
+ const [low, high] = [offset, offset + entry.length];
4186
+ const read = inside.find((candidate) => candidate.start >= low && candidate.start < high);
4187
+ const name = boundNames(`[${splitTop(pattern.slice(1, -1))[index] ?? ""}]`)[0];
4188
+ offset += entry.length + 1;
4189
+ if (read?.table !== void 0 && name !== void 0) origins.push({
4190
+ name,
4191
+ table: read.table,
4192
+ call: read.call,
4193
+ line: lineAt(read.start),
4194
+ ...scope
4195
+ });
4196
+ }
4197
+ continue;
4198
+ }
4199
+ const read = inside[0];
4200
+ if (read.table !== void 0) for (const name of names) origins.push({
4201
+ name,
4202
+ table: read.table,
4203
+ call: read.call,
4204
+ line: lineAt(read.start),
4205
+ ...scope
4206
+ });
4207
+ continue;
4208
+ }
4209
+ const source = origins.findLast((origin) => match.index >= origin.from && match.index < origin.to && mentions(init, origin.name));
4210
+ if (source) for (const name of names) origins.push({
4211
+ ...source,
4212
+ name,
4213
+ ...scope
4214
+ });
4215
+ }
4216
+ return origins;
4217
+ }
4218
+ /** Parts of `list` split at top-level commas. */
4219
+ function splitTop(list) {
4220
+ const parts = [];
4221
+ let depth = 0;
4222
+ let start = 0;
4223
+ for (let index = 0; index < list.length; index += 1) {
4224
+ const char = list.charAt(index);
4225
+ depth += OPEN.has(char) ? 1 : CLOSE.has(char) ? -1 : 0;
4226
+ if (char === "," && depth === 0) {
4227
+ parts.push(list.slice(start, index));
4228
+ start = index + 1;
4229
+ }
4230
+ }
4231
+ parts.push(list.slice(start));
4232
+ return parts;
4233
+ }
4234
+ function lines$1(text) {
4235
+ const starts = [0];
4236
+ for (let index = 0; index < text.length; index += 1) if (text.charAt(index) === "\n") starts.push(index + 1);
4237
+ return (index) => {
4238
+ let low = 0;
4239
+ let high = starts.length - 1;
4240
+ while (low < high) {
4241
+ const mid = Math.ceil((low + high) / 2);
4242
+ if (starts[mid] <= index) low = mid;
4243
+ else high = mid - 1;
4244
+ }
4245
+ return low + 1;
4246
+ };
4247
+ }
4248
+ /**
4249
+ * The include on `outer` that loads the `inner` rows `args` asks for, from the
4250
+ * snapshot's foreign keys: `customer` when `outer` holds the key and `args`
4251
+ * filters on the column it references, `notes` when `inner` holds the key and
4252
+ * `args` filters on it.
4253
+ */
4254
+ function relationTo(snapshot, outer, inner, args) {
4255
+ const table = inner.table;
4256
+ if (table === void 0 || tableKey$1(outer) === tableKey$1(table)) return;
4257
+ const camelCase = /[A-Z]/.test(outer + table);
4258
+ const name = (raw) => camelCase ? camel$1(raw) : raw;
4259
+ const filters = (column) => column !== void 0 && new RegExp(String.raw`(?<![\w$])(?:${column}|${camel$1(column)})\s*:|["'\`]${column}["'\`]\s*,`).test(args);
4260
+ const candidates = [];
4261
+ const named = (column) => new RegExp(String.raw`(?<![\w$])(?:${column}|${camel$1(column)})(?![\w$])`).test(args);
4262
+ for (const relation of snapshot.generator.relationships) {
4263
+ const from = tableKey$1(relation.relation);
4264
+ const to = tableKey$1(relation.referenced_relation);
4265
+ const [column] = relation.columns;
4266
+ if (column === void 0) continue;
4267
+ if (from === tableKey$1(outer) && to === tableKey$1(table) && (inner.method === "get" || filters(relation.referenced_columns[0]))) {
4268
+ const found = {
4269
+ name: name(column.replace(/_id$/, "")),
4270
+ many: false
4271
+ };
4272
+ if (named(column)) return found;
4273
+ candidates.push(found);
4274
+ }
4275
+ if (from === tableKey$1(table) && to === tableKey$1(outer) && filters(column)) candidates.push({
4276
+ name: name(relation.relation),
4277
+ many: true
4278
+ });
4279
+ }
4280
+ return candidates[0];
4281
+ }
4282
+ /** `include: { quote: true }`, or `_count` for a count of related rows. */
4283
+ function includeOf(relation, read) {
4284
+ return relation.many && read.method === "count" ? `include: { _count: { ${relation.name}: true } }` : `include: { ${relation.name}: true }`;
4285
+ }
4286
+ function batchHint(read) {
4287
+ switch (read.kind) {
4288
+ 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.`;
4289
+ case "rpc": return "Give the function an array parameter (`uuid[]`) and call it once for every id, or add it to a read set.";
4290
+ 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.";
4291
+ default: return read.kind;
4292
+ }
4293
+ }
4294
+ /** `in: ids` or `in: [...ids]`: the read is already batched over `name`. */
4295
+ const batchedOver = (args, name) => new RegExp(String.raw`\bin\s*:\s*(?:\[\s*\.\.\.)?${name.replaceAll("$", String.raw`\$`)}\b`).test(args);
4296
+ /**
4297
+ * A scope that iterates a literal array (`for (const kind of ["a", "b"])`) runs
4298
+ * a fixed number of times; a batch, a retry or a loop that writes per item is
4299
+ * not a read pattern to fold into one request.
4300
+ */
4301
+ function skipScope(scope, writes) {
4302
+ return BATCHES.test(scope.items) || scope.items.startsWith("[") && !scope.items.includes("...") || writes.some((at) => at >= scope.start && at < scope.end);
4303
+ }
4304
+ /** Both checks share one pass over each file. */
4305
+ function analyze(file, snapshot) {
4306
+ const perItem = [];
4307
+ const waterfalls = [];
4308
+ if (!/\bdb\b|\$rpc|supabase|Db\b|blocks|Service/.test(file.text)) return {
4309
+ perItem,
4310
+ waterfalls
4311
+ };
4312
+ const code = codeOnly(file.text);
4313
+ const services = serviceNames(code);
4314
+ const reads = readsIn(file.text, code, services);
4315
+ if (reads.length === 0) return {
4316
+ perItem,
4317
+ waterfalls
4318
+ };
4319
+ const writes = writesIn(file.text, code, services);
4320
+ const rawArgs = (read) => file.text.slice(read.open + 1, read.close);
4321
+ const lineAt = lines$1(file.text);
4322
+ const origins = originsIn(file.text, code, reads);
4323
+ const reported = /* @__PURE__ */ new Set();
4324
+ for (const scope of scopesIn(code)) {
4325
+ if (skipScope(scope, writes)) continue;
4326
+ const names = scopeNames(code, scope);
4327
+ for (const read of reads) {
4328
+ const args = code.slice(read.open + 1, read.close);
4329
+ 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;
4330
+ reported.add(read.start);
4331
+ const line = lineAt(read.start);
4332
+ const root = /^[\w$]+/.exec(scope.items)?.[0];
4333
+ const outer = origins.findLast((origin) => origin.name === root && scope.start >= origin.from && scope.start < origin.to);
4334
+ const relation = outer ? relationTo(snapshot, outer.table, read, rawArgs(read)) : void 0;
4335
+ 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.` : batchHint(read);
4336
+ perItem.push({
4337
+ message: `${file.path}:${String(line)} calls ${read.call} once per item of \`${scope.items}\`, so n items make n requests (N+1). ${hint}`,
4338
+ target: `${file.path}:${String(line)}`,
4339
+ location: {
4340
+ file: file.path,
4341
+ line
4342
+ }
4343
+ });
4344
+ }
4345
+ }
4346
+ for (const read of reads) {
4347
+ if (read.table === void 0 || reported.has(read.start)) continue;
4348
+ const args = code.slice(read.open + 1, read.close);
4349
+ const origin = origins.findLast((candidate) => read.start >= candidate.from && read.start < candidate.to && mentions(args, candidate.name));
4350
+ const relation = origin ? relationTo(snapshot, origin.table, read, rawArgs(read)) : void 0;
4351
+ if (!origin || !relation) continue;
4352
+ const line = lineAt(read.start);
4353
+ waterfalls.push({
4354
+ message: `${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 \`${includeOf(relation, read)}\` to the first read so one request returns both.`,
4355
+ target: `${file.path}:${String(line)}`,
4356
+ location: {
4357
+ file: file.path,
4358
+ line
4359
+ }
4360
+ });
4361
+ }
4362
+ const byLine = (a, b) => (a.location?.line ?? 0) - (b.location?.line ?? 0);
4363
+ return {
4364
+ perItem: perItem.toSorted(byLine),
4365
+ waterfalls
4366
+ };
4367
+ }
4368
+ const analyses = /* @__PURE__ */ new WeakMap();
4369
+ function analyzeAll(context) {
4370
+ let result = analyses.get(context.sources);
4371
+ if (!result) {
4372
+ result = context.sources.map((file) => analyze(file, context.snapshot));
4373
+ analyses.set(context.sources, result);
4374
+ }
4375
+ return result;
4376
+ }
4377
+ const N_PLUS_ONE_RULES = [{
4378
+ code: "BS634",
4379
+ severity: "warning",
4380
+ title: "Database read once per item (N+1)",
4381
+ 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.",
4382
+ check: (context) => analyzeAll(context).flatMap((file) => file.perItem)
4383
+ }, {
4384
+ code: "BS635",
4385
+ severity: "warning",
4386
+ title: "Dependent read of a related table (waterfall)",
4387
+ 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.",
4388
+ check: (context) => analyzeAll(context).flatMap((file) => file.waterfalls)
4389
+ }];
3832
4390
  // src/cli/doctor/client-barrels.ts
3833
4391
  /** A `"use client"` directive as the first statement, after comments. */
3834
4392
  const USE_CLIENT$1 = /^\s*(?:(?:\/\/[^\n]*|\/\*[\s\S]*?\*\/)\s*)*["']use client["']/;
@@ -6999,6 +7557,7 @@ const RULES = [
6999
7557
  ...COOKIE_RULES,
7000
7558
  ...NEXT_CACHE_RULES,
7001
7559
  ...ROUND_TRIP_RULES,
7560
+ ...N_PLUS_ONE_RULES,
7002
7561
  ...CLAIM_RULES,
7003
7562
  ...MIGRATION_RULES,
7004
7563
  ...AUTHORIZATION_RULES,