better-supabase 0.15.0 → 0.16.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 (328) hide show
  1. package/dist/{adapter-B0b6MXYS.js → adapter-Dyks1lX1.js} +1 -1
  2. package/dist/{agents-5n8DWRfP.d.ts → agents-CMIB3802.d.ts} +1 -1
  3. package/dist/{ai-cache-DyHohbFP.d.ts → ai-cache-2LGgaT7F.d.ts} +1 -1
  4. package/dist/{ai-chat-D1GuRnke.d.ts → ai-chat-BCaKsvLW.d.ts} +1 -1
  5. package/dist/{ai-schedules-CAquecT_.d.ts → ai-schedules-BmkARmQ9.d.ts} +2 -2
  6. package/dist/ai-sdk/agents/index.d.ts +4 -4
  7. package/dist/ai-sdk/batches/index.d.ts +1 -1
  8. package/dist/ai-sdk/cache/index.d.ts +1 -1
  9. package/dist/ai-sdk/chat/index.d.ts +1 -1
  10. package/dist/ai-sdk/embeddings/index.d.ts +2 -2
  11. package/dist/ai-sdk/index.d.ts +4 -4
  12. package/dist/ai-sdk/memory/index.d.ts +3 -3
  13. package/dist/ai-sdk/workflow/index.d.ts +3 -3
  14. package/dist/{api-DxAPqMrE.d.ts → api-hHwieEfz.d.ts} +1 -1
  15. package/dist/{app-tables-CF2DD-Mu.d.ts → app-tables-yMQ4ubyY.d.ts} +1 -1
  16. package/dist/{approvals-Crutd4-o.d.ts → approvals-Dh9dUXrN.d.ts} +1 -1
  17. package/dist/{assistant-CD_h8Vxx.d.ts → assistant-ndGdOBax.d.ts} +2 -2
  18. package/dist/astro/index.d.ts +4 -4
  19. package/dist/astro/index.js +2 -2
  20. package/dist/{auth-module-BEFESDC4.js → auth-module-BbmX-N4L.js} +12 -4
  21. package/dist/{authorization-hooks-Cs1vP_ej.d.ts → authorization-hooks-D_pwXlBs.d.ts} +4 -0
  22. package/dist/better-result/index.d.ts +2 -2
  23. package/dist/{bind-CrMBwrPN.d.ts → bind-JGCPGUJh.d.ts} +4 -4
  24. package/dist/{block-env-B_uEM2xz.d.ts → block-env-y65GF_px.d.ts} +4 -4
  25. package/dist/blocks/access-requests/index.d.ts +1 -1
  26. package/dist/blocks/activities/index.d.ts +2 -2
  27. package/dist/blocks/agents/index.d.ts +2 -2
  28. package/dist/blocks/ai-cache/index.d.ts +2 -2
  29. package/dist/blocks/ai-chat/index.d.ts +5 -5
  30. package/dist/blocks/ai-files/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 +2 -2
  35. package/dist/blocks/approvals/index.d.ts +2 -2
  36. package/dist/blocks/assets/index.d.ts +1 -1
  37. package/dist/blocks/assignment/index.d.ts +1 -1
  38. package/dist/blocks/attachments/index.d.ts +2 -2
  39. package/dist/blocks/audit/index.d.ts +5 -5
  40. package/dist/blocks/automations/index.d.ts +4 -4
  41. package/dist/blocks/billable-time/index.d.ts +1 -1
  42. package/dist/blocks/billing/index.d.ts +3 -3
  43. package/dist/blocks/bookings/index.d.ts +3 -3
  44. package/dist/blocks/bulk/index.d.ts +1 -1
  45. package/dist/blocks/calendar/index.d.ts +2 -2
  46. package/dist/blocks/catalog/index.d.ts +1 -1
  47. package/dist/blocks/channels/index.d.ts +1 -1
  48. package/dist/blocks/collections/index.d.ts +1 -1
  49. package/dist/blocks/comments/index.d.ts +4 -4
  50. package/dist/blocks/compliance/index.d.ts +1 -1
  51. package/dist/blocks/connectors/index.d.ts +1 -1
  52. package/dist/blocks/contacts/index.d.ts +1 -1
  53. package/dist/blocks/content/index.d.ts +1 -1
  54. package/dist/blocks/contracts/index.d.ts +1 -1
  55. package/dist/blocks/courses/index.d.ts +1 -1
  56. package/dist/blocks/created-by/index.d.ts +1 -1
  57. package/dist/blocks/custom-fields/index.d.ts +1 -1
  58. package/dist/blocks/data-lifecycle/index.d.ts +2 -2
  59. package/dist/blocks/deals/index.d.ts +1 -1
  60. package/dist/blocks/dispatch/index.d.ts +1 -1
  61. package/dist/blocks/documents/index.d.ts +1 -1
  62. package/dist/blocks/domains/index.d.ts +1 -1
  63. package/dist/blocks/donations/index.d.ts +1 -1
  64. package/dist/blocks/drive/index.d.ts +2 -2
  65. package/dist/blocks/employees/index.d.ts +2 -2
  66. package/dist/blocks/enrichment/index.d.ts +1 -1
  67. package/dist/blocks/enrollments/index.d.ts +1 -1
  68. package/dist/blocks/entitlements/index.d.ts +3 -3
  69. package/dist/blocks/expenses/index.d.ts +1 -1
  70. package/dist/blocks/field-history/index.d.ts +1 -1
  71. package/dist/blocks/flags/index.d.ts +1 -1
  72. package/dist/blocks/forecasts/index.d.ts +1 -1
  73. package/dist/blocks/forms/index.d.ts +2 -2
  74. package/dist/blocks/goals/index.d.ts +1 -1
  75. package/dist/blocks/guests/index.d.ts +1 -1
  76. package/dist/blocks/hiring/index.d.ts +1 -1
  77. package/dist/blocks/identities/index.d.ts +2 -2
  78. package/dist/blocks/imports/index.d.ts +1 -1
  79. package/dist/blocks/inbox/index.d.ts +5 -5
  80. package/dist/blocks/incidents/index.d.ts +1 -1
  81. package/dist/blocks/index.d.ts +2 -2
  82. package/dist/blocks/inventory/index.d.ts +2 -2
  83. package/dist/blocks/invoices/index.d.ts +1 -1
  84. package/dist/blocks/knowledge/index.d.ts +2 -2
  85. package/dist/blocks/lead-scoring/index.d.ts +1 -1
  86. package/dist/blocks/leases/index.d.ts +1 -1
  87. package/dist/blocks/leave/index.d.ts +1 -1
  88. package/dist/blocks/ledger/index.d.ts +1 -1
  89. package/dist/blocks/mail-sync/index.d.ts +1 -1
  90. package/dist/blocks/memberships/index.d.ts +1 -1
  91. package/dist/blocks/memory/index.d.ts +3 -3
  92. package/dist/blocks/messaging/index.d.ts +4 -4
  93. package/dist/blocks/metrics/index.d.ts +2 -2
  94. package/dist/blocks/mfa/index.d.ts +2 -2
  95. package/dist/blocks/moderation/index.d.ts +1 -1
  96. package/dist/blocks/notifications/index.d.ts +5 -5
  97. package/dist/blocks/numbering/index.d.ts +1 -1
  98. package/dist/blocks/oauth-server/index.d.ts +1 -1
  99. package/dist/blocks/onboarding/index.d.ts +2 -2
  100. package/dist/blocks/orders/index.d.ts +3 -3
  101. package/dist/blocks/organizations/index.d.ts +2 -2
  102. package/dist/blocks/outbox/index.d.ts +2 -2
  103. package/dist/blocks/passes/index.d.ts +2 -2
  104. package/dist/blocks/permissions/index.d.ts +3 -3
  105. package/dist/blocks/pipelines/index.d.ts +1 -1
  106. package/dist/blocks/posts/index.d.ts +1 -1
  107. package/dist/blocks/profiles/index.d.ts +1 -1
  108. package/dist/blocks/promotions/index.d.ts +1 -1
  109. package/dist/blocks/push/index.d.ts +2 -2
  110. package/dist/blocks/queue/index.d.ts +30 -3
  111. package/dist/blocks/queue/index.js +2 -2
  112. package/dist/blocks/quotes/index.d.ts +1 -1
  113. package/dist/blocks/rank/index.d.ts +2 -2
  114. package/dist/blocks/reactions/index.d.ts +4 -4
  115. package/dist/blocks/relations/index.d.ts +1 -1
  116. package/dist/blocks/reminders/index.d.ts +3 -3
  117. package/dist/blocks/reviews/index.d.ts +1 -1
  118. package/dist/blocks/saved-views/index.d.ts +3 -3
  119. package/dist/blocks/scores/index.d.ts +1 -1
  120. package/dist/blocks/search/index.d.ts +3 -3
  121. package/dist/blocks/security-events/index.d.ts +1 -1
  122. package/dist/blocks/segments/index.d.ts +1 -1
  123. package/dist/blocks/sequences/index.d.ts +1 -1
  124. package/dist/blocks/service-accounts/index.d.ts +1 -1
  125. package/dist/blocks/sessions/index.d.ts +2 -2
  126. package/dist/blocks/settings/index.d.ts +2 -2
  127. package/dist/blocks/share-links/index.d.ts +1 -1
  128. package/dist/blocks/shipments/index.d.ts +1 -1
  129. package/dist/blocks/signatures/index.d.ts +1 -1
  130. package/dist/blocks/signing-keys/index.d.ts +1 -1
  131. package/dist/blocks/sla/index.d.ts +1 -1
  132. package/dist/blocks/sso/index.d.ts +1 -1
  133. package/dist/blocks/state-machine/index.d.ts +1 -1
  134. package/dist/blocks/subjects/index.d.ts +2 -2
  135. package/dist/blocks/tags/index.d.ts +2 -2
  136. package/dist/blocks/tasks/index.d.ts +2 -2
  137. package/dist/blocks/teams/index.d.ts +1 -1
  138. package/dist/blocks/templates/index.d.ts +3 -3
  139. package/dist/blocks/time-tracking/index.d.ts +1 -1
  140. package/dist/blocks/timeline/index.d.ts +3 -3
  141. package/dist/blocks/trash/index.d.ts +1 -1
  142. package/dist/blocks/undo/index.d.ts +2 -2
  143. package/dist/blocks/updated-at/index.d.ts +1 -1
  144. package/dist/blocks/usage/index.d.ts +3 -3
  145. package/dist/blocks/vercel-marketplace/index.d.ts +1 -1
  146. package/dist/blocks/versions/index.d.ts +1 -1
  147. package/dist/blocks/waitlist/index.d.ts +1 -1
  148. package/dist/blocks/webhooks/index.d.ts +4 -4
  149. package/dist/blocks/webhooks/index.js +1 -1
  150. package/dist/blocks/workflow-editor/index.d.ts +6 -6
  151. package/dist/blocks/workflow-editor/index.js +12 -1
  152. package/dist/blocks/workflows/index.d.ts +4 -4
  153. package/dist/{bookings-D4dvGXiR.d.ts → bookings-Dox2rced.d.ts} +1 -1
  154. package/dist/{bucket-CiNi8sIw.d.ts → bucket-vc-QRrva.d.ts} +40 -1
  155. package/dist/chat-sdk/index.d.ts +1 -1
  156. package/dist/cli/add-Bfb_ISrO.js +1 -0
  157. package/dist/cli/{add-BgsUjCan.js → add-D7TkPdco.js} +17 -12
  158. package/dist/cli/{add-DCI5JKjA.js → add-I8OW-qJH.js} +2 -2
  159. package/dist/cli/{backfill-nxPbcsns.js → backfill-DIz5DnlQ.js} +1 -1
  160. package/dist/cli/bin.js +1 -1
  161. package/dist/cli/{blocks-Cr4HGePW.js → blocks-Bp5RPoft.js} +1 -1
  162. package/dist/cli/{blocks-BZHI8mRC.js → blocks-xk-SE8gS.js} +1 -1
  163. package/dist/cli/{cache-CXgR_Ahi.js → cache-AznIssjI.js} +1 -1
  164. package/dist/cli/{codemod-DSN7iAdg.js → codemod-Aewxza6i.js} +95 -3
  165. package/dist/cli/{content-mapper-DNs7lTu7.js → content-mapper-DCrz6OIv.js} +2 -2
  166. package/dist/cli/{doctor-DDrEM6S1.js → doctor-DkOSLPEQ.js} +29 -14
  167. package/dist/cli/{gen-MtijJQ9r.js → gen-CFkYUnWq.js} +10 -10
  168. package/dist/cli/index.d.ts +1 -1
  169. package/dist/cli/index.js +6 -6
  170. package/dist/cli/{init-D-aDv9r5.js → init-CHj9ad4S.js} +5 -5
  171. package/dist/cli/legacy-prefix-DkTA3Rhx.js +141 -0
  172. package/dist/cli/{live-iEeH15ck.js → live-DGdLR41j.js} +2 -2
  173. package/dist/cli/{mcp-BAPyaQ62.js → mcp-BZno503V.js} +2 -2
  174. package/dist/cli/{metadata-DVx9Zgbj.js → metadata-BfgHMe4q.js} +3 -3
  175. package/dist/cli/{migration-safety-D7PhzFxm.js → migration-safety-BnnXPAro.js} +1 -1
  176. package/dist/cli/{module-migration-aPCckev6.js → module-migration-O_IxewFs.js} +5 -216
  177. package/dist/cli/{print-BeWO7OJY.js → print-DosQIFSy.js} +1 -1
  178. package/dist/cli/{remove-B46Dmd2M.js → remove-DK2G_KHm.js} +5 -4
  179. package/dist/cli/{render-ucJmUyuM.js → render-5y5a1QZr.js} +3 -3
  180. package/dist/cli/{run-CvYVAztY.js → run-Bs4OKdDI.js} +20 -7
  181. package/dist/cli/{run-DYhLBcFW.js → run-MRET30vh.js} +20 -20
  182. package/dist/cli/{shared-LZroULBe.js → shared-BLqbvY2x.js} +1 -1
  183. package/dist/cli/{snapshot-C8MVPyO8.js → snapshot-uTUlEzY2.js} +2 -2
  184. package/dist/cli/{source-DANaJJVc.js → source-D2gJHKwC.js} +1 -1
  185. package/dist/cli/{spec-DGVNMSSB.js → spec-Cm2einTO.js} +2 -2
  186. package/dist/cli/{spec-g8_G5K7o.js → spec-DUjOtciN.js} +1 -1
  187. package/dist/cli/sql-layout-lUWenjJw.js +247 -0
  188. package/dist/cli/{sync-btj01bcM.js → sync-CZMRB3aU.js} +2 -1
  189. package/dist/cli/{upgrade-B596d4t8.js → upgrade-BFEIMC7U.js} +4 -137
  190. package/dist/cli/{upgrade-Dw3TMQzn.js → upgrade-fVsJniXm.js} +2 -2
  191. package/dist/cli/{version-Du4CgONY.js → version-B2Dr6VmJ.js} +1 -1
  192. package/dist/client/index.d.ts +5 -5
  193. package/dist/client/index.js +1 -1
  194. package/dist/client/native/index.d.ts +5 -5
  195. package/dist/client/native/index.js +1 -1
  196. package/dist/{client-BAEbEA7t.js → client-C_mlji5R.js} +6 -5
  197. package/dist/{composite-BARuBEDE.js → composite-B3TIjId4.js} +1 -1
  198. package/dist/{composite-Dsxj7T5K.d.ts → composite-CfYyU3vs.d.ts} +4 -3
  199. package/dist/config/index.d.ts +1 -1
  200. package/dist/{context-CEuTKrkz.d.ts → context-8kb8m5uO.d.ts} +24 -2
  201. package/dist/{controller-BrP0gn47.d.ts → controller-BW-5Opig.d.ts} +1 -1
  202. package/dist/{conversion-BAbucuXq.d.ts → conversion-3iv2r7YC.d.ts} +1 -1
  203. package/dist/create/index.d.ts +2 -2
  204. package/dist/create/index.js +1 -1
  205. package/dist/{define-DFBnQyYg.d.ts → define-C5AcEkEJ.d.ts} +1 -1
  206. package/dist/{define-block-BVcLQ3DF.d.ts → define-block-C1RHXz7L.d.ts} +3 -3
  207. package/dist/delegation-C7eWP2r8.d.ts +14 -0
  208. package/dist/{delegation--93jRsVO.js → delegation-DGOIiT8k.js} +12 -5
  209. package/dist/edge/index.d.ts +5 -5
  210. package/dist/edge/index.js +3 -3
  211. package/dist/{embeddings-kFbRvuic.d.ts → embeddings-D_RsS6ow.d.ts} +1 -1
  212. package/dist/{entitlements-CJpYQXeE.d.ts → entitlements-sO977DO-.d.ts} +1 -1
  213. package/dist/{envelope-Bzu0JnY2.js → envelope-DEI2iX-d.js} +1 -1
  214. package/dist/eve/index.d.ts +2 -2
  215. package/dist/{eve-BFSwTu1z.d.ts → eve-B7jxYPCw.d.ts} +2 -2
  216. package/dist/{executor-CVIn6JHa.d.ts → executor-BcNWcD-4.d.ts} +2 -2
  217. package/dist/{executor-_2ekNofh.d.ts → executor-Bi056Cnj.d.ts} +1 -1
  218. package/dist/expo/index.d.ts +2 -2
  219. package/dist/expo/index.js +2 -2
  220. package/dist/{field-errors-fsbFktYF.d.ts → field-errors-Dt86dCKk.d.ts} +12 -12
  221. package/dist/{framework-BKyTeS-j.d.ts → framework-BGdZVyPL.d.ts} +3 -3
  222. package/dist/{framework-DDdkR7FX.js → framework-BozTXRzt.js} +1 -1
  223. package/dist/{gateway-TD1pRfTP.d.ts → gateway-DzI687yd.d.ts} +3 -3
  224. package/dist/hono/index.d.ts +4 -4
  225. package/dist/hono/index.js +2 -2
  226. package/dist/{index-C-qpk8EQ.d.ts → index-CENWq3zb.d.ts} +1 -1
  227. package/dist/{index-Do2ChN_y.d.ts → index-CQhPHHDF.d.ts} +20 -2
  228. package/dist/{index-B938YqY-.d.ts → index-CTu-3fJB.d.ts} +51 -3
  229. package/dist/{index-CguFm716.d.ts → index-Cc4mIQS8.d.ts} +32 -4
  230. package/dist/{index-DLq69k3F.d.ts → index-CcAmFNVi.d.ts} +2 -2
  231. package/dist/{index-BnH4Gomw.d.ts → index-Craf712U.d.ts} +44 -12
  232. package/dist/{index-BUuVq1co.d.ts → index-DZKCc2WM.d.ts} +3 -3
  233. package/dist/index.d.ts +2 -2
  234. package/dist/{knowledge-CtL-Vfgy.d.ts → knowledge-F1IhRI4Q.d.ts} +1 -1
  235. package/dist/list/index.d.ts +1 -1
  236. package/dist/{list-query-BDVutLFr.d.ts → list-query-DYhgRTd5.d.ts} +1 -1
  237. package/dist/mapper/bin.js +5 -5
  238. package/dist/mcp/index.d.ts +3 -3
  239. package/dist/mcp/index.js +1 -1
  240. package/dist/mcp/sdk/index.d.ts +2 -2
  241. package/dist/mcp/sdk/index.js +1 -1
  242. package/dist/next/client/index.d.ts +81 -1
  243. package/dist/next/client/index.js +178 -2
  244. package/dist/next/index.d.ts +15 -14
  245. package/dist/next/index.js +2 -2
  246. package/dist/orpc/index.d.ts +4 -4
  247. package/dist/orpc/index.js +1 -1
  248. package/dist/otel/index.js +4 -4
  249. package/dist/{outbox-HvGAJuBe.d.ts → outbox-HxjZTfF6.d.ts} +1 -1
  250. package/dist/{ports-DOhtuw3c.js → ports-CaVRXjxq.js} +1 -1
  251. package/dist/{ports-sx226JUL.d.ts → ports-mObLgH1z.d.ts} +1 -1
  252. package/dist/powersync/index.d.ts +2 -2
  253. package/dist/preset/index.d.ts +3 -3
  254. package/dist/{push-token-D3Vcf0Pf.d.ts → push-token-BSSvsWXZ.d.ts} +1 -1
  255. package/dist/query/index.d.ts +1 -1
  256. package/dist/{rate-limit-o44SYkVY.js → rate-limit-Dt9vAY4E.js} +53 -0
  257. package/dist/react/index.d.ts +6 -6
  258. package/dist/react/index.js +3 -3
  259. package/dist/react/native/index.d.ts +1 -1
  260. package/dist/react/native/index.js +1 -1
  261. package/dist/react/server.d.ts +12 -7
  262. package/dist/react/server.js +8 -3
  263. package/dist/react/session.d.ts +5 -0
  264. package/dist/react/session.js +9 -1
  265. package/dist/{react-BuDYI62C.js → react-CZUZYn9E.js} +41 -4
  266. package/dist/react-router/index.d.ts +3 -3
  267. package/dist/react-router/index.js +2 -2
  268. package/dist/realtime/index.d.ts +6 -6
  269. package/dist/realtime/index.js +2 -1
  270. package/dist/{record-form-BYs9xv_N.d.ts → record-form-D9ILuVtA.d.ts} +1 -1
  271. package/dist/records/index.d.ts +7 -7
  272. package/dist/relay-gKvKJ3xf.js +208 -0
  273. package/dist/{resource-execute-CzHuDsil.d.ts → resource-execute-Cpnob1Vj.d.ts} +1 -1
  274. package/dist/{resource-types-DnKiH4G2.d.ts → resource-types-pMeLs68X.d.ts} +1 -1
  275. package/dist/{resources-B9cQxhjw.d.ts → resources-7iq2-5_A.d.ts} +1 -1
  276. package/dist/server/index.d.ts +150 -11
  277. package/dist/server/index.js +400 -4
  278. package/dist/{server-types-CFtehAsr.d.ts → server-types-CK8mUIUT.d.ts} +5 -354
  279. package/dist/{session-CH0SKgIz.d.ts → session-DWmFv3vB.d.ts} +2 -1
  280. package/dist/session-status-qQLm7jzh.d.ts +82 -0
  281. package/dist/{sign-in-DNCdrk05.js → sign-in-B64114O4.js} +1 -1
  282. package/dist/{sign-in-BsIaNx2C.js → sign-in-CmPK1AgM.js} +20 -10
  283. package/dist/solid/index.d.ts +7 -7
  284. package/dist/solid/index.js +1 -1
  285. package/dist/solid-start/index.d.ts +3 -3
  286. package/dist/solid-start/index.js +2 -2
  287. package/dist/spec/index.d.ts +1 -1
  288. package/dist/sql/index.d.ts +4 -4
  289. package/dist/sql/index.js +2 -2
  290. package/dist/{sql-ClHIdgKS.js → sql-Dl3Alk43.js} +402 -13
  291. package/dist/sqlite/index.d.ts +1 -1
  292. package/dist/ssr/index.d.ts +1 -1
  293. package/dist/storage/index.d.ts +3 -3
  294. package/dist/storage/index.js +54 -1
  295. package/dist/{subject-readers-BNSzkqw_.d.ts → subject-readers-8GySC9Z8.d.ts} +1 -1
  296. package/dist/support-B4ZBVxt3.d.ts +357 -0
  297. package/dist/svelte/index.d.ts +7 -7
  298. package/dist/svelte/index.js +1 -1
  299. package/dist/sveltekit/index.d.ts +4 -4
  300. package/dist/sveltekit/index.js +2 -2
  301. package/dist/{tags-BjHflcHF.d.ts → tags-qvVk79pp.d.ts} +1 -1
  302. package/dist/tanstack-db/index.d.ts +1 -1
  303. package/dist/tanstack-start/index.d.ts +3 -3
  304. package/dist/tanstack-start/index.js +2 -2
  305. package/dist/{tenant-yYg0E2-n.d.ts → tenant-DOKIJI62.d.ts} +1 -1
  306. package/dist/testing/index.d.ts +13 -12
  307. package/dist/{timeline-CtG0sehj.d.ts → timeline-CvTuXYvn.d.ts} +3 -3
  308. package/dist/{topic-CJrQZQaa.d.ts → topic-CZXHhZye.d.ts} +3 -3
  309. package/dist/{types-CAQBmpDx.d.ts → types-A4yyKEsg.d.ts} +1 -1
  310. package/dist/{types-SFRomQF7.d.ts → types-Czq9Xtpa.d.ts} +1 -7
  311. package/dist/{types-BBQLbui9.d.ts → types-DsRfiQ0v.d.ts} +1 -1
  312. package/dist/{usage-D7QkrwzV.d.ts → usage-Dp45V42p.d.ts} +1 -1
  313. package/dist/{verify-CMou8dWZ.d.ts → verify-CjvNLY7N.d.ts} +1 -1
  314. package/dist/vue/index.d.ts +7 -7
  315. package/dist/vue/index.js +1 -1
  316. package/dist/{watch-topic-BcGfvZOE.d.ts → watch-topic-BAxoPKZx.d.ts} +1 -1
  317. package/dist/workflow-sdk/builder/index.d.ts +3 -3
  318. package/dist/workflow-sdk/builder/index.js +1 -1
  319. package/dist/workflow-sdk/index.d.ts +1 -1
  320. package/dist/workflow-sdk/index.js +1 -1
  321. package/dist/{workflow-sdk-BFHu4sci.d.ts → workflow-sdk-B3Ss55Fy.d.ts} +1 -1
  322. package/dist/{workflow-sdk-BVlFEB5Q.js → workflow-sdk-Cf0LAOFF.js} +2 -2
  323. package/dist/yjs/index.d.ts +1 -1
  324. package/package.json +1 -1
  325. package/schemas/doctor-report-v1.json +1 -0
  326. package/skills/better-supabase-api/SKILL.md +3 -1
  327. package/skills/better-supabase-auth/SKILL.md +7 -0
  328. package/dist/cli/add-DWjlVwvP.js +0 -1
@@ -1,10 +1,10 @@
1
1
  import { n as CliError, r as errorText } from "./errors-BTe6A15O.js";
2
2
  import { n as importPath } from "./io-DH1kcmmP.js";
3
- import { i as cachedTypesModule, n as cachedDatabaseTypes, s as typesModuleKey } from "./cache-CXgR_Ahi.js";
3
+ import { i as cachedTypesModule, n as cachedDatabaseTypes, s as typesModuleKey } from "./cache-AznIssjI.js";
4
4
  import { t as byCodePoint } from "./compare-BmIWVEui.js";
5
- import { f as generateDatabaseTypes, h as restrictSchemas, p as oxfmtInstalled, v as tsTypeOf } from "./snapshot-C8MVPyO8.js";
5
+ import { f as generateDatabaseTypes, h as restrictSchemas, p as oxfmtInstalled, v as tsTypeOf } from "./snapshot-uTUlEzY2.js";
6
6
  import { t as isRecord$1 } from "./guards-CUlDNYZs.js";
7
- import { a as toCatalog } from "./source-DANaJJVc.js";
7
+ import { a as toCatalog } from "./source-D2gJHKwC.js";
8
8
  import { basename, dirname, isAbsolute, join, posix, relative, resolve } from "node:path";
9
9
  import { entityNames } from "better-supabase/blocks";
10
10
  import { DEFAULT_CLAIMS, blockEntities, blockEntityRenames, blockSubjectTypes, tenantClaimPaths, tenantNameOf } from "better-supabase/config";
@@ -1,13 +1,14 @@
1
1
  import { r as errorText } from "./errors-BTe6A15O.js";
2
2
  import { a as sameText, t as display } from "./io-DH1kcmmP.js";
3
- import { c as writeAtomic, o as storeTypesModule, s as typesModuleKey, t as CACHE_DIR } from "./cache-CXgR_Ahi.js";
3
+ import { c as writeAtomic, o as storeTypesModule, s as typesModuleKey, t as CACHE_DIR } from "./cache-AznIssjI.js";
4
4
  import { t as byCodePoint } from "./compare-BmIWVEui.js";
5
- import { _ as stabilizeMetadata, b as typegenVersionNotice, p as oxfmtInstalled, t as loadSnapshot, y as typegenVersion } from "./snapshot-C8MVPyO8.js";
6
- import { n as render } from "./render-ucJmUyuM.js";
7
- import { A as providerLabel, D as entitlementRequirements, E as accessRequirements, O as entitlementsMode, T as accessProviderMode, c as sameModuleMigration, j as unsafeKey, k as moduleKeyProblems, l as writeLatestMigration, n as READ_SETS_SUFFIX, r as latestMigration, u as writesMigrations, w as writtenByBlocks, x as migrationsDir, y as compiledReadSets } from "./module-migration-aPCckev6.js";
8
- import { s as schemaStampPath } from "./content-mapper-DNs7lTu7.js";
5
+ import { _ as stabilizeMetadata, b as typegenVersionNotice, p as oxfmtInstalled, t as loadSnapshot, y as typegenVersion } from "./snapshot-uTUlEzY2.js";
6
+ import { n as render } from "./render-5y5a1QZr.js";
7
+ import { C as entitlementsMode, E as unsafeKey, S as entitlementRequirements, T as providerLabel, b as accessProviderMode, c as sameModuleMigration, l as writeLatestMigration, n as READ_SETS_SUFFIX, r as latestMigration, u as writesMigrations, w as moduleKeyProblems, x as accessRequirements, y as compiledReadSets } from "./module-migration-O_IxewFs.js";
8
+ import { s as schemaStampPath } from "./content-mapper-DCrz6OIv.js";
9
9
  import { a as changedFiles, d as fileDiff, i as changeLines, r as applyPlan, s as hasConflicts } from "./files-CX71yBm8.js";
10
- import { l as tableObject, n as exposed, o as policyObject, s as qualified, t as catalogOf } from "./shared-LZroULBe.js";
10
+ import { n as migrationsDir, o as writtenByBlocks } from "./sql-layout-lUWenjJw.js";
11
+ import { l as tableObject, n as exposed, o as policyObject, s as qualified, t as catalogOf } from "./shared-BLqbvY2x.js";
11
12
  import { existsSync } from "node:fs";
12
13
  import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
13
14
  import { readFile } from "node:fs/promises";
@@ -121,6 +122,18 @@ function appTablesOf(context) {
121
122
  const created = new Set(declaredTables((context.sqlFiles ?? []).filter(writtenByBlocks), context.config.schemas));
122
123
  return Object.fromEntries(catalogOf(context).tables.filter((table) => context.config.schemas.includes(table.schema) && !created.has(qualified(table))).map((table) => [qualified(table), "database"]));
123
124
  }
125
+ /**
126
+ * The views among the app's tables, and the columns of each, for the layout a
127
+ * block reads them with.
128
+ */
129
+ function appViewsOf(context) {
130
+ const own = appTablesOf(context);
131
+ const views = catalogOf(context).tables.filter((table) => table.kind === "view" && Object.hasOwn(own, qualified(table)));
132
+ return {
133
+ ownViews: Object.fromEntries(views.map((view) => [qualified(view), { updatable: view.insertable && view.updatable }])),
134
+ ownColumns: Object.fromEntries(views.map((view) => [qualified(view), view.columns.map((column) => column.name)]))
135
+ };
136
+ }
124
137
  //#endregion
125
138
  //#region src/cli/doctor/block-policies.ts
126
139
  /** The prefix the render pass gives block policies on the app's tables. */
@@ -1424,4 +1437,4 @@ async function runGen(options) {
1424
1437
  };
1425
1438
  }
1426
1439
  //#endregion
1427
- export { splinterTables as S, withoutStrings as _, METADATA_GAPS_TEXT as a, appTablesOf as b, accessModule as c, RLS_RULES as d, appliesTo as f, policyHelpers as g, functionObject as h, generationNotices as i, entitlementsModule as l, functionBody as m, runGen as n, fromMetadata as o, escape as p, UNFORMATTED as r, AUTHORIZATION_RULES as s, refuseRowConditionedBuckets as t, COMMANDS as u, BLOCK_PREFIX as v, advisorRule as x, blockTargets as y };
1440
+ export { splinterTables as C, advisorRule as S, withoutStrings as _, METADATA_GAPS_TEXT as a, appTablesOf as b, accessModule as c, RLS_RULES as d, appliesTo as f, policyHelpers as g, functionObject as h, generationNotices as i, entitlementsModule as l, functionBody as m, runGen as n, fromMetadata as o, escape as p, UNFORMATTED as r, AUTHORIZATION_RULES as s, refuseRowConditionedBuckets as t, COMMANDS as u, BLOCK_PREFIX as v, appViewsOf as x, blockTargets as y };
@@ -1,6 +1,6 @@
1
1
  import { c as COMMANDS, d as GROUPS, f as RESERVED_NAMES, h as runCommand, i as joinRepeated, m as parseArgs$2, o as listArgs, s as runsWithInvalidConfig, t as GLOBAL_ARGS, u as DOCS_ORIGIN } from "./command-CQ61x6gN.js";
2
2
  import { n as highlight, r as painter } from "./style-Bm2X5JrN.js";
3
- import { t as VERSION } from "./version-Du4CgONY.js";
3
+ import { t as VERSION } from "./version-B2Dr6VmJ.js";
4
4
  import { n as CliError, o as toCliError } from "./errors-BTe6A15O.js";
5
5
  import { a as missingInputNext, o as resolveAgent, t as checkConsent } from "./agent-CbuPvI2x.js";
6
6
  import { a as globalFlags, c as resolveCommand, i as commandTree, n as closestName, o as isVariadic, r as commandArgs, t as checkArgs } from "./parse-B9Iv_-Pf.js";
@@ -16,35 +16,35 @@ import { resolve } from "node:path";
16
16
  * loads on demand, so `--version` and `--help` import no command.
17
17
  */
18
18
  const LOADERS = [
19
- ["init", () => import("./init-D-aDv9r5.js").then((m) => m.initCommand)],
20
- ["add", () => import("./add-DWjlVwvP.js").then((m) => m.addCommand)],
21
- ["remove", () => import("./remove-B46Dmd2M.js").then((m) => m.removeCommand)],
22
- ["upgrade", () => import("./upgrade-Dw3TMQzn.js").then((m) => m.upgradeCommand)],
23
- ["gen", () => import("./gen-MtijJQ9r.js").then((m) => m.genCommand)],
24
- ["doctor", () => import("./doctor-DDrEM6S1.js").then((m) => m.doctorCommand)],
19
+ ["init", () => import("./init-CHj9ad4S.js").then((m) => m.initCommand)],
20
+ ["add", () => import("./add-Bfb_ISrO.js").then((m) => m.addCommand)],
21
+ ["remove", () => import("./remove-DK2G_KHm.js").then((m) => m.removeCommand)],
22
+ ["upgrade", () => import("./upgrade-fVsJniXm.js").then((m) => m.upgradeCommand)],
23
+ ["gen", () => import("./gen-CFkYUnWq.js").then((m) => m.genCommand)],
24
+ ["doctor", () => import("./doctor-DkOSLPEQ.js").then((m) => m.doctorCommand)],
25
25
  ["db query", () => import("./db-DrBI_HNv.js").then((m) => m.dbQueryCommand)],
26
26
  ["db diff", () => import("./db-DrBI_HNv.js").then((m) => m.dbDiffCommand)],
27
27
  ["db seed", () => import("./seed-D6XijwbR.js").then((m) => m.seedCommand)],
28
- ["db backfill", () => import("./backfill-nxPbcsns.js").then((m) => m.dbBackfillCommand)],
28
+ ["db backfill", () => import("./backfill-DIz5DnlQ.js").then((m) => m.dbBackfillCommand)],
29
29
  ["dev env", () => import("./env-CAU1nknN.js").then((m) => m.envCommand)],
30
30
  ["dev run", () => import("./run-BXx6D1aR.js").then((m) => m.runCommand)],
31
31
  ["dev keys", () => import("./keys-DGEpMbeB.js").then((m) => m.keysCommand)],
32
32
  ["dev stack ls", () => import("./stack-CWEHdO0b.js").then((m) => m.stackLsCommand)],
33
33
  ["dev stack prune", () => import("./stack-CWEHdO0b.js").then((m) => m.stackPruneCommand)],
34
- ["blocks list", () => import("./blocks-Cr4HGePW.js").then((m) => m.blocksListCommand)],
35
- ["blocks view", () => import("./blocks-Cr4HGePW.js").then((m) => m.blocksViewCommand)],
36
- ["blocks search", () => import("./blocks-Cr4HGePW.js").then((m) => m.blocksSearchCommand)],
37
- ["spec emit", () => import("./spec-g8_G5K7o.js").then((m) => m.specEmitCommand)],
38
- ["spec validate", () => import("./spec-g8_G5K7o.js").then((m) => m.specValidateCommand)],
39
- ["mcp", () => import("./mcp-BAPyaQ62.js").then((m) => m.mcpCommand)],
34
+ ["blocks list", () => import("./blocks-Bp5RPoft.js").then((m) => m.blocksListCommand)],
35
+ ["blocks view", () => import("./blocks-Bp5RPoft.js").then((m) => m.blocksViewCommand)],
36
+ ["blocks search", () => import("./blocks-Bp5RPoft.js").then((m) => m.blocksSearchCommand)],
37
+ ["spec emit", () => import("./spec-DUjOtciN.js").then((m) => m.specEmitCommand)],
38
+ ["spec validate", () => import("./spec-DUjOtciN.js").then((m) => m.specValidateCommand)],
39
+ ["mcp", () => import("./mcp-BZno503V.js").then((m) => m.mcpCommand)],
40
40
  ["skills list", () => import("./skills-toUan_OV.js").then((m) => m.skillsListCommand)],
41
41
  ["skills install", () => import("./skills-toUan_OV.js").then((m) => m.skillsInstallCommand)],
42
- ["codemod 0.4", () => import("./codemod-DSN7iAdg.js").then((m) => m.codemodCommand("0.4"))],
43
- ["codemod 0.5", () => import("./codemod-DSN7iAdg.js").then((m) => m.codemodCommand("0.5"))],
44
- ["codemod 0.6", () => import("./codemod-DSN7iAdg.js").then((m) => m.codemodCommand("0.6"))],
45
- ["codemod 0.9", () => import("./codemod-DSN7iAdg.js").then((m) => m.codemodCommand("0.9"))],
46
- ["codemod 0.11", () => import("./codemod-DSN7iAdg.js").then((m) => m.codemodCommand("0.11"))],
47
- ["codemod 0.15", () => import("./codemod-DSN7iAdg.js").then((m) => m.codemodCommand("0.15"))],
42
+ ["codemod 0.4", () => import("./codemod-Aewxza6i.js").then((m) => m.codemodCommand("0.4"))],
43
+ ["codemod 0.5", () => import("./codemod-Aewxza6i.js").then((m) => m.codemodCommand("0.5"))],
44
+ ["codemod 0.6", () => import("./codemod-Aewxza6i.js").then((m) => m.codemodCommand("0.6"))],
45
+ ["codemod 0.9", () => import("./codemod-Aewxza6i.js").then((m) => m.codemodCommand("0.9"))],
46
+ ["codemod 0.11", () => import("./codemod-Aewxza6i.js").then((m) => m.codemodCommand("0.11"))],
47
+ ["codemod 0.15", () => import("./codemod-Aewxza6i.js").then((m) => m.codemodCommand("0.15"))],
48
48
  ["completion", () => import("./completion-BwI0_Ap5.js").then((m) => m.completionCommand)],
49
49
  ["config", () => import("./config-CPux9Wa7.js").then((m) => m.configCommand)]
50
50
  ];
@@ -1,4 +1,4 @@
1
- import { a as toCatalog } from "./source-DANaJJVc.js";
1
+ import { a as toCatalog } from "./source-D2gJHKwC.js";
2
2
  import { h as tomlGet, p as sqlWorkflow, r as detectWorkflow } from "./supabase-toml-CncmQbO0.js";
3
3
  //#region src/cli/doctor/shared.ts
4
4
  const catalogs = /* @__PURE__ */ new WeakMap();
@@ -1,7 +1,7 @@
1
1
  import { n as CliError, r as errorText } from "./errors-BTe6A15O.js";
2
- import { d as readExtras, l as TYPEGEN_VERSION, r as cachedIntrospect } from "./cache-CXgR_Ahi.js";
2
+ import { d as readExtras, l as TYPEGEN_VERSION, r as cachedIntrospect } from "./cache-AznIssjI.js";
3
3
  import { t as byCodePoint } from "./compare-BmIWVEui.js";
4
- import { n as managementSource, r as pgSource } from "./source-DANaJJVc.js";
4
+ import { n as managementSource, r as pgSource } from "./source-D2gJHKwC.js";
5
5
  import { n as databaseUrl, u as accessToken } from "./config-9t5ec_N7.js";
6
6
  import { d as readSupabaseToml, f as schemaPaths, h as tomlGet, u as pgFunctionHooks } from "./supabase-toml-CncmQbO0.js";
7
7
  import { t as connect } from "./db-CQCLx7cx.js";
@@ -1,4 +1,4 @@
1
- import { t as VERSION } from "./version-Du4CgONY.js";
1
+ import { t as VERSION } from "./version-B2Dr6VmJ.js";
2
2
  import { n as CliError } from "./errors-BTe6A15O.js";
3
3
  import { r as redactUrl } from "./redact-KGAk2Ul9.js";
4
4
  import { n as HTTP_CHANNEL } from "./trace-VbdO6bcN.js";
@@ -1,9 +1,9 @@
1
1
  import { n as __require, t as __commonJSMin } from "./rolldown-runtime-kJ_i4yPo.js";
2
2
  import { p as commandMeta, r as defineCliCommand } from "./command-CQ61x6gN.js";
3
- import { t as VERSION } from "./version-Du4CgONY.js";
3
+ import { t as VERSION } from "./version-B2Dr6VmJ.js";
4
4
  import { i as failedResult, n as CliError, r as errorText } from "./errors-BTe6A15O.js";
5
5
  import { t as display } from "./io-DH1kcmmP.js";
6
- import { c as writeAtomic, t as CACHE_DIR } from "./cache-CXgR_Ahi.js";
6
+ import { c as writeAtomic, t as CACHE_DIR } from "./cache-AznIssjI.js";
7
7
  import { t as isRecord } from "./guards-CUlDNYZs.js";
8
8
  import { t as importFresh } from "./fresh-import-DzgsGHkX.js";
9
9
  import { a as changedFiles, i as changeLines, r as applyPlan } from "./files-CX71yBm8.js";
@@ -1 +1 @@
1
- export { n as specEmitCommand, i as specValidateCommand } from "./spec-DGVNMSSB.js";
1
+ export { n as specEmitCommand, i as specValidateCommand } from "./spec-Cm2einTO.js";
@@ -0,0 +1,247 @@
1
+ import { d as TypegenMissingError, i as parseSnapshot } from "./snapshot-uTUlEzY2.js";
2
+ import { a as toCatalog } from "./source-D2gJHKwC.js";
3
+ import { d as readSupabaseToml, f as schemaPaths, n as declarativeSchemasDir, p as sqlWorkflow } from "./supabase-toml-CncmQbO0.js";
4
+ import { existsSync } from "node:fs";
5
+ import { dirname, join, relative, resolve, sep } from "node:path";
6
+ import { readFile, readdir } from "node:fs/promises";
7
+ import { adoptedColumnProblems, auditRegistrations, declaredPolicies, declaredTableColumns, declaredTables, declaredUpdatedAtTriggers, declaredViews, extensionSchema, moduleLayout, policyGrants, resolveBlocks, resolveExposeColumns, rlsTables, sameTenantLayout } from "better-supabase/sql";
8
+ //#region src/cli/sql-layout.ts
9
+ /** The folder the module data files sit next to, for the project's workflow. */
10
+ async function schemasDirOf(config) {
11
+ const toml = await readSupabaseToml(config.root);
12
+ return declarativeSchemasDir(toml, sqlWorkflow(config, toml));
13
+ }
14
+ /** The declarative schema files, then the migrations oldest first. */
15
+ async function schemaTexts(config) {
16
+ const toml = await readSupabaseToml(config.root);
17
+ const migrations = resolve(config.root, migrationsDir(config));
18
+ const paths = [...(await schemaPaths(config.root, toml, sqlWorkflow(config, toml))).files, ...existsSync(migrations) ? (await readdir(migrations)).filter((name) => name.endsWith(".sql")).toSorted().map((name) => join(migrations, name)) : []];
19
+ return Promise.all(paths.map(async (path) => ({
20
+ path,
21
+ text: await readFile(resolve(config.root, path), "utf-8")
22
+ })));
23
+ }
24
+ async function declarativeTexts(config) {
25
+ const toml = await readSupabaseToml(config.root);
26
+ const { files } = await schemaPaths(config.root, toml, sqlWorkflow(config, toml));
27
+ if (files.length === 0) return schemaTexts(config);
28
+ return Promise.all(files.map(async (path) => ({
29
+ path,
30
+ text: await readFile(resolve(config.root, path), "utf-8")
31
+ })));
32
+ }
33
+ /**
34
+ * The `better_supabase.audit(...)` calls in the declarative schemas, then the
35
+ * migrations oldest first, so a later call or `unaudit` wins.
36
+ */
37
+ async function auditedTables(config) {
38
+ return auditRegistrations(await schemaTexts(config));
39
+ }
40
+ /**
41
+ * The layout `upgrade` and doctor render the module files with, so both see the
42
+ * same grants, session policies, audit triggers and vector schema.
43
+ */
44
+ async function moduleLayoutFor(config, input) {
45
+ const resolved = new Set(resolveBlocks(input.names, input.entitlementsProvider ? { entitlementsProvider: input.entitlementsProvider } : {}).map((module) => module.name));
46
+ const own = await ownLayout(config);
47
+ const adopted = adoptedColumnProblems(config.blocks, await declarativeTexts(config), config.schemas, own.ownTables);
48
+ if (adopted.length > 0) throw new TypeError(adopted.join("\n"));
49
+ const fromPolicies = resolved.has("grants") && config.blocks["grants"]?.options?.["fromPolicies"] === true;
50
+ const sessionPolicies = resolved.has("sessions") && config.blocks["sessions"]?.options?.["policies"] === true;
51
+ const sameTenant = config.blocks["memberships"]?.options?.["sameTenant"];
52
+ const autoSameTenant = resolved.has("memberships") && typeof sameTenant === "object" && sameTenant !== null && "auto" in sameTenant && sameTenant.auto === true;
53
+ const base = moduleLayout(config, input.testsDir, input.readSets ?? [], input.entitlementsProvider, input.accessProvider, input.permissionCatalog);
54
+ const grants = base.grants === void 0 ? void 0 : resolveExposeColumns(base.grants, await declarativeTexts(config), config.schemas);
55
+ return {
56
+ ...base,
57
+ ...grants === void 0 ? {} : { grants },
58
+ schemasDir: await schemasDirOf(config),
59
+ ...resolved.has("audit") ? { auditedTables: await auditedTables(config) } : {},
60
+ ...resolved.has("vector-search") ? vectorSchemaOf(await schemaTexts(config)) : {},
61
+ ...fromPolicies ? { policyGrants: policyGrants(await declarativeTexts(config), config.schemas) } : {},
62
+ ...fromPolicies ? { rlsTables: rlsTables(await declarativeTexts(config), config.schemas) } : {},
63
+ ...autoSameTenant ? sameTenantLayout(await declarativeTexts(config), config.schemas) : {},
64
+ ...fromPolicies || sessionPolicies ? { declaredTables: declaredTables(await declarativeTexts(config), config.schemas) } : {},
65
+ ...own
66
+ };
67
+ }
68
+ /**
69
+ * `ownTables`, `ownViews`, `ownColumns`, `ownUpdatedAtTriggers` and
70
+ * `ownPolicies`: the database's tables and views, then the app's files.
71
+ */
72
+ async function ownLayout(config) {
73
+ const database = await databaseTables(config);
74
+ const own = (await declarativeTexts(config)).filter((source) => !writtenByBlocks(source));
75
+ const columns = Object.fromEntries([...declaredTableColumns(own, config.schemas)].map(([table, names]) => [table, [...names]]));
76
+ const views = ownDeclaredViews(own, config.schemas);
77
+ return {
78
+ ownTables: {
79
+ ...database.tables,
80
+ ...ownDeclaredTables(own, config.schemas),
81
+ ...views.tables
82
+ },
83
+ ownViews: {
84
+ ...database.views,
85
+ ...views.views
86
+ },
87
+ ownColumns: {
88
+ ...database.columns,
89
+ ...columns,
90
+ ...views.columns
91
+ },
92
+ ownUpdatedAtTriggers: {
93
+ ...database.updatedAtTriggers,
94
+ ...declaredUpdatedAtTriggers(own, config.schemas)
95
+ },
96
+ ownPolicies: {
97
+ ...database.policies,
98
+ ...declaredPolicies(own, config.schemas)
99
+ }
100
+ };
101
+ }
102
+ /** A trigger function named like one that keeps `updated_at` current. */
103
+ const UPDATED_AT_FUNCTION = /updated_at|moddatetime|touch/i;
104
+ const BLOCK_MARKER = /^-- @(?:bsb-block|bsb-tables|bs-module|bs-app-tables)\b/m;
105
+ const BLOCK_MIGRATION = /_better_supabase_[a-z_]+\.sql$/;
106
+ /**
107
+ * The `schema.table`s that the files better-supabase wrote create, among
108
+ * `sources`; a table an app table entry enriches is not one of them.
109
+ */
110
+ function blockDeclaredTables(sources, schemas) {
111
+ return new Set(declaredTables(sources.filter(writtenByBlocks), schemas));
112
+ }
113
+ /** A file better-supabase wrote: a block file or a module migration. */
114
+ function writtenByBlocks(source) {
115
+ return BLOCK_MARKER.test(source.text) || BLOCK_MIGRATION.test(source.path);
116
+ }
117
+ /**
118
+ * The tables in the saved snapshot (`source.snapshot`) that no block file or
119
+ * module migration created, mapped to `database`. Without a snapshot, the app's
120
+ * schema files and migrations stand in for it.
121
+ */
122
+ async function databaseTables(config) {
123
+ const none = {
124
+ tables: {},
125
+ views: {},
126
+ columns: {},
127
+ updatedAtTriggers: {},
128
+ policies: {}
129
+ };
130
+ const path = config.source.snapshot;
131
+ if (path === void 0 || !existsSync(resolve(config.root, path))) return none;
132
+ let snapshot;
133
+ try {
134
+ snapshot = await parseSnapshot(JSON.parse(await readFile(resolve(config.root, path), "utf-8")), path);
135
+ } catch (cause) {
136
+ if (cause instanceof TypegenMissingError) return none;
137
+ throw cause;
138
+ }
139
+ const created = blockDeclaredTables(await schemaTexts(config), config.schemas);
140
+ const tables = {};
141
+ const views = {};
142
+ const columns = {};
143
+ const updatedAtTriggers = {};
144
+ const policies = {};
145
+ for (const table of toCatalog(snapshot).tables) {
146
+ const name = `${table.schema}.${table.name}`;
147
+ if (config.schemas.includes(table.schema) && !created.has(name)) {
148
+ tables[name] = "database";
149
+ columns[name] = table.columns.map((column) => column.name);
150
+ if (table.kind === "view") views[name] = { updatable: table.insertable && table.updatable };
151
+ const kept = table.triggers.find((trigger) => !trigger.name.startsWith("bsb_") && trigger.events.includes("update") && UPDATED_AT_FUNCTION.test(trigger.function));
152
+ if (kept !== void 0) updatedAtTriggers[name] = kept.name;
153
+ policies[name] = table.policies.filter((policy) => !policy.name.startsWith("bsb_"));
154
+ }
155
+ }
156
+ return {
157
+ tables,
158
+ views,
159
+ columns,
160
+ updatedAtTriggers,
161
+ policies
162
+ };
163
+ }
164
+ /**
165
+ * `schema.table` to the app's own schema file that creates it: every
166
+ * declarative file, or migration, that better-supabase didn't write.
167
+ */
168
+ function ownDeclaredTables(sources, schemas) {
169
+ const ownTables = {};
170
+ for (const source of sources) for (const table of declaredTables([source], schemas)) ownTables[table] ??= source.path;
171
+ return ownTables;
172
+ }
173
+ /**
174
+ * The views and materialized views the app's own files create, as `ownTables`
175
+ * entries, with their columns where the files name them.
176
+ */
177
+ function ownDeclaredViews(sources, schemas) {
178
+ const tables = {};
179
+ const views = {};
180
+ const columns = {};
181
+ for (const source of sources) for (const [view, declared] of declaredViews([source], schemas)) {
182
+ tables[view] ??= source.path;
183
+ views[view] = { updatable: declared.updatable };
184
+ if (declared.columns !== void 0) columns[view] = declared.columns;
185
+ }
186
+ return {
187
+ tables,
188
+ views,
189
+ columns
190
+ };
191
+ }
192
+ function vectorSchemaOf(sources) {
193
+ const schema = extensionSchema(sources, "vector");
194
+ return schema === void 0 ? {} : { vectorSchema: schema };
195
+ }
196
+ /**
197
+ * The folder that holds both the project root and `sql.dir`: the root, or an
198
+ * ancestor when `sql.dir` points at a shared stack. The `sql` commands write
199
+ * SQL files only inside it.
200
+ */
201
+ function sqlRoot(config) {
202
+ const dir = resolve(config.root, config.sql.dir);
203
+ let stop = resolve(config.root);
204
+ while (dir !== stop && !dir.startsWith(stop + sep) && dirname(stop) !== stop) stop = dirname(stop);
205
+ return stop;
206
+ }
207
+ /**
208
+ * A plan for files under the project root or `sql.dir`, with paths relative to
209
+ * the project root.
210
+ */
211
+ function sqlPlan(config, plan) {
212
+ return {
213
+ ...plan,
214
+ root: sqlRoot(config),
215
+ base: config.root,
216
+ files: plan.files.map((file) => ({
217
+ ...file,
218
+ path: resolve(config.root, file.path)
219
+ })),
220
+ ...plan.remove ? { remove: plan.remove.map((entry) => {
221
+ const path = resolve(config.root, typeof entry === "string" ? entry : entry.path);
222
+ return typeof entry === "string" ? path : {
223
+ ...entry,
224
+ path
225
+ };
226
+ }) } : {}
227
+ };
228
+ }
229
+ /**
230
+ * The migrations folder next to the `config.toml` found walking up from
231
+ * `sql.dir`, relative to the root; `supabase/migrations` without one. The walk
232
+ * stops where `sql.dir` and the root meet, so a `sql.dir` outside the project
233
+ * (a shared stack in a monorepo) finds that stack's folder.
234
+ */
235
+ function migrationsDir(config) {
236
+ const root = resolve(config.root);
237
+ let dir = resolve(root, config.sql.dir);
238
+ const stop = sqlRoot(config);
239
+ for (;;) {
240
+ if (existsSync(join(dir, "config.toml"))) return relative(root, join(dir, "migrations")).replaceAll("\\", "/");
241
+ if (dir === stop || dirname(dir) === dir) break;
242
+ dir = dirname(dir);
243
+ }
244
+ return "supabase/migrations";
245
+ }
246
+ //#endregion
247
+ export { sqlPlan as a, schemasDirOf as i, migrationsDir as n, writtenByBlocks as o, moduleLayoutFor as r, blockDeclaredTables as t };
@@ -1,8 +1,9 @@
1
1
  import { n as CliError } from "./errors-BTe6A15O.js";
2
2
  import { t as display } from "./io-DH1kcmmP.js";
3
- import { C as sqlPlan, _ as layoutFor, c as sameModuleMigration, d as DATA_NEXT, l as writeLatestMigration, m as writeExtensionsMigration, r as latestMigration, s as renderModuleMigration, t as MODULES_SUFFIX, u as writesMigrations, x as migrationsDir } from "./module-migration-aPCckev6.js";
3
+ import { _ as layoutFor, c as sameModuleMigration, d as DATA_NEXT, l as writeLatestMigration, m as writeExtensionsMigration, r as latestMigration, s as renderModuleMigration, t as MODULES_SUFFIX, u as writesMigrations } from "./module-migration-O_IxewFs.js";
4
4
  import { d as readSupabaseToml, f as schemaPaths, h as tomlGet, i as diffEngine, l as migrationCommand, o as findSupabaseRoot, p as sqlWorkflow, t as PGDELTA_TABLE } from "./supabase-toml-CncmQbO0.js";
5
5
  import { d as fileDiff, i as changeLines, l as keepHandEdit, o as handEditedError, r as applyPlan, t as HAND_EDITED, u as planResult } from "./files-CX71yBm8.js";
6
+ import { a as sqlPlan, n as migrationsDir } from "./sql-layout-lUWenjJw.js";
6
7
  import { t as loadTopics } from "./topics-BpdnYmWb.js";
7
8
  import { t as orphanedBlockFiles } from "./orphans-BAboqyVM.js";
8
9
  import { dirname, join, resolve } from "node:path";
@@ -1,145 +1,12 @@
1
1
  import { t as display } from "./io-DH1kcmmP.js";
2
- import { C as sqlPlan, _ as layoutFor, a as migrationInstances, c as sameModuleMigration, o as migrationModules, p as migrationStamp, r as latestMigration, s as renderModuleMigration, t as MODULES_SUFFIX, u as writesMigrations, x as migrationsDir } from "./module-migration-aPCckev6.js";
2
+ import { _ as layoutFor, a as migrationInstances, c as sameModuleMigration, o as migrationModules, p as migrationStamp, r as latestMigration, s as renderModuleMigration, t as MODULES_SUFFIX, u as writesMigrations } from "./module-migration-O_IxewFs.js";
3
3
  import { d as fileDiff, i as changeLines, r as applyPlan } from "./files-CX71yBm8.js";
4
- import { a as write, o as topicPolicyFile, r as nextStep } from "./sync-btj01bcM.js";
4
+ import { a as sqlPlan, n as migrationsDir } from "./sql-layout-lUWenjJw.js";
5
+ import { a as write, o as topicPolicyFile, r as nextStep } from "./sync-CZMRB3aU.js";
6
+ import { a as legacyPrefixSql, i as legacyPrefixNames, r as legacyBlocksTableSql } from "./legacy-prefix-DkTA3Rhx.js";
5
7
  import { resolve } from "node:path";
6
8
  import { readFile } from "node:fs/promises";
7
9
  import { BLOCK_RENAMES, SQL_MODULES, currentBlockName, entityRenamePlan, formerBlockName, moduleFileVersion, moduleTopics, renderBlocks, sameBlockFile, upgradePlan } from "better-supabase/sql";
8
- //#region src/cli/sql/legacy-prefix.ts
9
- /**
10
- * Prefixes of the names the library builds outside the module files (realtime
11
- * broadcast triggers, tenant checks, state transitions, JSON Schema checks).
12
- */
13
- const LEGACY_PREFIXES = [
14
- "bs_broadcast_",
15
- "bs_same_tenant_",
16
- "bs_transition_",
17
- "bs_json_"
18
- ];
19
- const LEGACY_NAME = /\bbs_[a-z0-9_]+/g;
20
- /** The `bs_` object names in installed module SQL, before 0.15 renamed them. */
21
- function legacyPrefixNames(text) {
22
- return [...new Set(text.match(LEGACY_NAME))].toSorted();
23
- }
24
- const array = (values) => `array[${values.map((value) => `'${value.replaceAll("'", "''")}'`).join(", ")}]::text[]`;
25
- /**
26
- * Renames the installed `bs_` triggers, policies, constraints, indexes and
27
- * functions to `bsb_`, so the module files' `drop ... if exists bsb_x` replace
28
- * them instead of adding a second copy. Only the names in `names` and the
29
- * runtime prefixes are renamed, and only while the new name is free, so the
30
- * step can run again.
31
- */
32
- function legacyPrefixSql(names) {
33
- return `do $bsb_rename$
34
- declare
35
- v_names constant text[] := ${array(names)};
36
- v_prefixes constant text[] := ${array(LEGACY_PREFIXES)};
37
- r record;
38
- begin
39
- for r in
40
- select t.tgname as name, t.tgrelid::regclass::text as rel
41
- from pg_trigger t
42
- where not t.tgisinternal
43
- and (t.tgname = any (v_names) or exists (select 1 from unnest(v_prefixes) x where starts_with(t.tgname, x)))
44
- and not exists (select 1 from pg_trigger u where u.tgrelid = t.tgrelid and u.tgname = 'bsb_' || substr(t.tgname, 4))
45
- loop
46
- begin
47
- execute format('alter trigger %I on %s rename to %I', r.name, r.rel, 'bsb_' || substr(r.name, 4));
48
- exception when insufficient_privilege then
49
- raise warning 'better-supabase: rename % to bsb_% by hand; the migration role does not own it', r.name, substr(r.name, 4);
50
- end;
51
- end loop;
52
-
53
- for r in
54
- select p.polname as name, p.polrelid::regclass::text as rel
55
- from pg_policy p
56
- where (p.polname = any (v_names) or exists (select 1 from unnest(v_prefixes) x where starts_with(p.polname, x)))
57
- and not exists (select 1 from pg_policy q where q.polrelid = p.polrelid and q.polname = 'bsb_' || substr(p.polname, 4))
58
- loop
59
- begin
60
- execute format('alter policy %I on %s rename to %I', r.name, r.rel, 'bsb_' || substr(r.name, 4));
61
- exception when insufficient_privilege then
62
- raise warning 'better-supabase: rename % to bsb_% by hand; the migration role does not own it', r.name, substr(r.name, 4);
63
- end;
64
- end loop;
65
-
66
- for r in
67
- select c.conname as name, c.conrelid::regclass::text as rel
68
- from pg_constraint c
69
- where c.conrelid <> 0
70
- and (c.conname = any (v_names) or exists (select 1 from unnest(v_prefixes) x where starts_with(c.conname, x)))
71
- and not exists (select 1 from pg_constraint d where d.conrelid = c.conrelid and d.conname = 'bsb_' || substr(c.conname, 4))
72
- loop
73
- begin
74
- execute format('alter table %s rename constraint %I to %I', r.rel, r.name, 'bsb_' || substr(r.name, 4));
75
- exception when insufficient_privilege then
76
- raise warning 'better-supabase: rename % to bsb_% by hand; the migration role does not own it', r.name, substr(r.name, 4);
77
- end;
78
- end loop;
79
-
80
- for r in
81
- select n.nspname as schema, i.relname as name
82
- from pg_class i
83
- join pg_namespace n on n.oid = i.relnamespace
84
- where i.relkind in ('i', 'I')
85
- and (i.relname = any (v_names) or exists (select 1 from unnest(v_prefixes) x where starts_with(i.relname, x)))
86
- and not exists (select 1 from pg_constraint c where c.conindid = i.oid)
87
- and to_regclass(format('%I.%I', n.nspname, 'bsb_' || substr(i.relname, 4))) is null
88
- loop
89
- begin
90
- execute format('alter index %I.%I rename to %I', r.schema, r.name, 'bsb_' || substr(r.name, 4));
91
- exception when insufficient_privilege then
92
- raise warning 'better-supabase: rename % to bsb_% by hand; the migration role does not own it', r.name, substr(r.name, 4);
93
- end;
94
- end loop;
95
-
96
- for r in
97
- select f.oid::regprocedure::text as fn, f.proname as name
98
- from pg_proc f
99
- join pg_namespace n on n.oid = f.pronamespace
100
- where n.nspname not in ('pg_catalog', 'information_schema')
101
- and (f.proname = any (v_names) or exists (select 1 from unnest(v_prefixes) x where starts_with(f.proname, x)))
102
- and not exists (
103
- select 1 from pg_proc g
104
- where g.pronamespace = f.pronamespace and g.proname = 'bsb_' || substr(f.proname, 4)
105
- and g.proargtypes = f.proargtypes
106
- )
107
- loop
108
- begin
109
- execute format('alter function %s rename to %I', r.fn, 'bsb_' || substr(r.name, 4));
110
- exception when insufficient_privilege then
111
- raise warning 'better-supabase: rename % to bsb_% by hand; the migration role does not own it', r.name, substr(r.name, 4);
112
- end;
113
- end loop;
114
- end
115
- $bsb_rename$;`;
116
- }
117
- /**
118
- * Creates `better_supabase.blocks` and copies the rows of the 0.14
119
- * `better_supabase.modules` table into it, so the schema diff that drops the
120
- * old table loses no installed versions.
121
- */
122
- const legacyBlocksTableSql = `create schema if not exists better_supabase;
123
- create table if not exists better_supabase.blocks (
124
- name text primary key,
125
- version integer not null,
126
- mode text not null,
127
- installed_at timestamptz not null default now(),
128
- updated_at timestamptz not null default now()
129
- );
130
- alter table better_supabase.blocks enable row level security;
131
- revoke all on better_supabase.blocks from anon, authenticated;
132
- grant select on better_supabase.blocks to service_role;
133
- do $bsb_blocks$
134
- begin
135
- if to_regclass('better_supabase.modules') is not null then
136
- insert into better_supabase.blocks (name, version, mode, installed_at, updated_at)
137
- select name, version, mode, installed_at, updated_at from better_supabase.modules
138
- on conflict (name) do nothing;
139
- end if;
140
- end
141
- $bsb_blocks$;`;
142
- //#endregion
143
10
  //#region src/cli/sql/renamed-blocks.ts
144
11
  /** Block names match `[a-z0-9-]+`, so quoting needs no escaping. */
145
12
  const literal = (name) => `'${name}'`;
@@ -1,8 +1,8 @@
1
1
  import { p as commandMeta, r as defineCliCommand } from "./command-CQ61x6gN.js";
2
2
  import { i as plain } from "./style-Bm2X5JrN.js";
3
- import { t as syncModules } from "./sync-btj01bcM.js";
3
+ import { t as syncModules } from "./sync-CZMRB3aU.js";
4
4
  import { t as SQL_ARGS } from "./args-UEwg0l-N.js";
5
- import { t as upgrade } from "./upgrade-B596d4t8.js";
5
+ import { t as upgrade } from "./upgrade-BFEIMC7U.js";
6
6
  //#region src/cli/commands/upgrade.ts
7
7
  const UPGRADE_ARGS = {
8
8
  check: {
@@ -1,4 +1,4 @@
1
1
  //#region src/cli/version.ts
2
- const VERSION = "0.15.0";
2
+ const VERSION = "0.16.0";
3
3
  //#endregion
4
4
  export { VERSION as t };
@@ -1,8 +1,8 @@
1
1
  import { a as DataSync, c as LocalTablesOption, i as DataEntry, l as liveEngine, n as DataEngine, o as DataSyncState, r as DataEngineOptions, s as LiveEngineOptions, t as DataChanges, u as memoryEngine } from "../data-engine-BWoz9lED.js";
2
- import { n as TopicPort, r as TopicWatch, t as TopicHandle } from "../watch-topic-BcGfvZOE.js";
3
- import { a as PickFilesOptions, c as Shortcut, d as UploadPort, f as memoryStorage, i as KeyboardPort, l as StoragePort, n as DeepLinkPort, o as PickedFile, p as storageUpload, r as FilePickerPort, s as PushTokenPort, t as ClientPorts, u as UploadDestination } from "../ports-sx226JUL.js";
4
- import { a as ClientAuth, i as BindClientOptions, n as AuthUser, o as bindClient, r as BetterClient, t as AuthSnapshot } from "../bind-CrMBwrPN.js";
5
- import { a as defineController, i as ControllerState, n as Controller, o as whileSignedIn, r as ControllerParts, t as AuthPort } from "../controller-BrP0gn47.js";
2
+ import { n as TopicPort, r as TopicWatch, t as TopicHandle } from "../watch-topic-BAxoPKZx.js";
3
+ import { a as PickFilesOptions, c as Shortcut, d as UploadPort, f as memoryStorage, i as KeyboardPort, l as StoragePort, n as DeepLinkPort, o as PickedFile, p as storageUpload, r as FilePickerPort, s as PushTokenPort, t as ClientPorts, u as UploadDestination } from "../ports-mObLgH1z.js";
4
+ import { a as ClientAuth, i as BindClientOptions, n as AuthUser, o as bindClient, r as BetterClient, t as AuthSnapshot } from "../bind-JGCPGUJh.js";
5
+ import { a as defineController, i as ControllerState, n as Controller, o as whileSignedIn, r as ControllerParts, t as AuthPort } from "../controller-BW-5Opig.js";
6
6
  import { n as FunctionContract } from "../function-contract-DxFNOmsm.js";
7
- import { a as webDeepLinks, c as webPorts, d as FunctionContracts, f as FunctionsHost, h as functions, i as WebPushTokenOptions, l as webPushToken, m as TypedFunctions, n as createClient, o as webFilePicker, p as InvokeOptions, r as PushRegistrationLike, s as webKeyboard, t as ClientOptions, u as webStorage } from "../index-BUuVq1co.js";
7
+ import { a as webDeepLinks, c as webPorts, d as FunctionContracts, f as FunctionsHost, h as functions, i as WebPushTokenOptions, l as webPushToken, m as TypedFunctions, n as createClient, o as webFilePicker, p as InvokeOptions, r as PushRegistrationLike, s as webKeyboard, t as ClientOptions, u as webStorage } from "../index-DZKCc2WM.js";
8
8
  export { type AuthPort, type AuthSnapshot, type AuthUser, type BetterClient, type BindClientOptions, type ClientAuth, ClientOptions, type ClientPorts, type Controller, type ControllerParts, type ControllerState, type DataChanges, type DataEngine, type DataEngineOptions, type DataEntry, type DataSync, type DataSyncState, type DeepLinkPort, type FilePickerPort, type FunctionContract, type FunctionContracts, type FunctionsHost, type InvokeOptions, type KeyboardPort, type LiveEngineOptions, type LocalTablesOption, type PickFilesOptions, type PickedFile, type PushRegistrationLike, type PushTokenPort, type Shortcut, type StoragePort, type TopicHandle, type TopicPort, type TopicWatch, type TypedFunctions, type UploadDestination, type UploadPort, type WebPushTokenOptions, bindClient, createClient, defineController, functions, liveEngine, memoryEngine, memoryStorage, storageUpload, webDeepLinks, webFilePicker, webKeyboard, webPorts, webPushToken, webStorage, whileSignedIn };
@@ -2,7 +2,7 @@ import { n as dbError } from "../errors-BVFgt8BZ.js";
2
2
  import { a as ok, r as err, t as AsyncResult } from "../result-ntFBW2p2.js";
3
3
  import { i as isProblem, r as fromProblem } from "../problem-Bf0cJ7tk.js";
4
4
  import { EnvValidationError, parseEnv } from "../env/index.js";
5
- import { n as storageUpload, r as bindClient, t as memoryStorage } from "../ports-DOhtuw3c.js";
5
+ import { n as storageUpload, r as bindClient, t as memoryStorage } from "../ports-CaVRXjxq.js";
6
6
  import { a as memoryEngine, n as liveEngine } from "../data-engine-D1BkmBoR.js";
7
7
  import { n as whileSignedIn, t as defineController } from "../controller-BEliOBOv.js";
8
8
  import { createBrowserClient } from "@supabase/ssr";