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,6 +1,6 @@
1
1
  import { r as readIfExists } from "./io-DH1kcmmP.js";
2
- import { t as CACHE_DIR } from "./cache-CXgR_Ahi.js";
3
- import { x as installedVersion } from "./snapshot-C8MVPyO8.js";
2
+ import { t as CACHE_DIR } from "./cache-AznIssjI.js";
3
+ import { x as installedVersion } from "./snapshot-uTUlEzY2.js";
4
4
  import { t as i } from "./jsonc-D5Fu67jw.js";
5
5
  import { resolve } from "node:path";
6
6
  import { createHash } from "node:crypto";
@@ -1,40 +1,41 @@
1
1
  import { a as list, p as commandMeta, r as defineCliCommand } from "./command-CQ61x6gN.js";
2
2
  import { i as plain } 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, r as errorText } from "./errors-BTe6A15O.js";
5
5
  import { i as isLocalDatabaseUrl, r as databaseHost } from "./agent-CbuPvI2x.js";
6
6
  import { a as sameText, t as display } from "./io-DH1kcmmP.js";
7
- import { t as CACHE_DIR } from "./cache-CXgR_Ahi.js";
7
+ import { t as CACHE_DIR } from "./cache-AznIssjI.js";
8
8
  import { t as byCodePoint } from "./compare-BmIWVEui.js";
9
- import { C as satisfies, S as peerVersions, c as isSqliteLiteDriver, n as managementTarget, o as snapshotFile, r as openSource, s as liteDriverOf, t as loadSnapshot, u as MetadataRejectedError } from "./snapshot-C8MVPyO8.js";
10
- import { d as configFor, r as renderFiles, u as notNullTag } from "./render-ucJmUyuM.js";
9
+ import { C as satisfies, S as peerVersions, c as isSqliteLiteDriver, n as managementTarget, o as snapshotFile, r as openSource, s as liteDriverOf, t as loadSnapshot, u as MetadataRejectedError } from "./snapshot-uTUlEzY2.js";
10
+ import { d as configFor, r as renderFiles, u as notNullTag } from "./render-5y5a1QZr.js";
11
11
  import { t as isRecord } from "./guards-CUlDNYZs.js";
12
- import { i as request } from "./source-DANaJJVc.js";
13
- import { A as providerLabel, S as moduleLayoutFor, b as blockDeclaredTables, i as migrationHolds, o as migrationModules, r as latestMigration, t as MODULES_SUFFIX, x as migrationsDir, y as compiledReadSets } from "./module-migration-aPCckev6.js";
12
+ import { i as request } from "./source-D2gJHKwC.js";
13
+ import { T as providerLabel, i as migrationHolds, o as migrationModules, r as latestMigration, t as MODULES_SUFFIX, y as compiledReadSets } from "./module-migration-O_IxewFs.js";
14
14
  import { l as stdinDatabaseUrl, n as databaseUrl } from "./config-9t5ec_N7.js";
15
15
  import { a as findRepoRoot, c as httpHooks, d as readSupabaseToml, f as schemaPaths, h as tomlGet, i as diffEngine, l as migrationCommand, n as declarativeSchemasDir, p as sqlWorkflow, u as pgFunctionHooks } from "./supabase-toml-CncmQbO0.js";
16
16
  import { t as PROCESS_ENV } from "./env-DMgjB_4y.js";
17
17
  import { n as readStackStatus } from "./stack-status-B_Ipd_-z.js";
18
18
  import { t as connect } from "./db-CQCLx7cx.js";
19
- 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-DNs7lTu7.js";
19
+ 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-DCrz6OIv.js";
20
20
  import { c as insideRoot, i as changeLines, r as applyPlan } from "./files-CX71yBm8.js";
21
- import { S as splinterTables, _ as withoutStrings, a as METADATA_GAPS_TEXT, b as appTablesOf, c as accessModule, d as RLS_RULES, f as appliesTo, g as policyHelpers, h as functionObject, l as entitlementsModule, m as functionBody, p as escape$2, s as AUTHORIZATION_RULES, u as COMMANDS$2, v as BLOCK_PREFIX, x as advisorRule, y as blockTargets } from "./run-CvYVAztY.js";
22
- import { a as permissionCatalogKeys, i as lineOf, l as tableObject, n as exposed, o as policyObject, r as exposedSchemas, s as qualified, t as catalogOf, u as workflowOf } from "./shared-LZroULBe.js";
23
- import { o as wiringFor, r as configInstances, t as MIGRATION_SAFETY_RULES } from "./migration-safety-D7PhzFxm.js";
21
+ import { C as splinterTables, S as advisorRule, _ as withoutStrings, a as METADATA_GAPS_TEXT, b as appTablesOf, c as accessModule, d as RLS_RULES, f as appliesTo, g as policyHelpers, h as functionObject, l as entitlementsModule, m as functionBody, p as escape$2, s as AUTHORIZATION_RULES, u as COMMANDS$2, v as BLOCK_PREFIX, x as appViewsOf, y as blockTargets } from "./run-Bs4OKdDI.js";
22
+ import { n as migrationsDir, r as moduleLayoutFor, t as blockDeclaredTables } from "./sql-layout-lUWenjJw.js";
23
+ import { a as permissionCatalogKeys, i as lineOf, l as tableObject, n as exposed, o as policyObject, r as exposedSchemas, s as qualified, t as catalogOf, u as workflowOf } from "./shared-BLqbvY2x.js";
24
+ import { o as wiringFor, r as configInstances, t as MIGRATION_SAFETY_RULES } from "./migration-safety-BnnXPAro.js";
24
25
  import { t as orphanedBlockFiles } from "./orphans-BAboqyVM.js";
25
- import { i as reservedRoles, n as ident$1, r as literal$1, t as LIVE_RULES } from "./live-iEeH15ck.js";
26
+ import { i as reservedRoles, n as ident$1, r as literal$1, t as LIVE_RULES } from "./live-DGdLR41j.js";
26
27
  import { a as sourceFlags, n as SOURCE_ARGS } from "./source-args-IpJRJO5t.js";
27
28
  import { i as PLUGIN_SUBPATH_RENAMES, n as BLOCK_SUBPATH_RENAMES, o as SPEC_SUBPATH_RENAMES, t as BLOCK_EXPORT_RENAMES } from "./codemod-block-renames-BuSaTE_G.js";
28
29
  import { n as PLATFORM_SCHEMAS } from "./in-stack-diff-DQTW53Vf.js";
29
30
  import { i as staleVariables, r as stackEnvValues, t as PREFIX_NAMES } from "./stack-env-6hS-WEmh.js";
30
31
  import { a as readSharedMemory, n as listStacks, t as branchName } from "./stacks-BYlQ96WS.js";
31
- import { i as refuseWithMetadata, r as readMetadataSnapshot } from "./metadata-DVx9Zgbj.js";
32
+ import { i as refuseWithMetadata, r as readMetadataSnapshot } from "./metadata-BfgHMe4q.js";
32
33
  import { existsSync } from "node:fs";
33
34
  import { dirname, resolve } from "node:path";
34
35
  import { createHash } from "node:crypto";
35
36
  import { glob, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
36
37
  import { DEFAULT_ACTIVE_TENANT, tenantClaimPaths } from "better-supabase/config";
37
- import { SECRET_COLUMNS, SQL_MODULES, TENANT_SCOPE_POLICY, adoptedTables, blockFileState, blockSqlVersion, contractSignature, customContracts, dataExportPlan, excludedColumns, expiredFlagsQuery, hasColumnAccess, migrationOptionUses, moduleDeprecations, moduleEventTriggers, moduleFileVersion, moduleLayout, notNullCheckName, renderBlocks, sameBlockFile, sameTenantColumn, sameTenantTrigger, scopePolicyName, sharedRolesProblems, subjectColumns, widenedCommands } from "better-supabase/sql";
38
+ import { SECRET_COLUMNS, SQL_MODULES, TENANT_SCOPE_POLICY, adoptedTables, adoptedViews, blockFileState, blockSqlVersion, contractSignature, customContracts, dataExportPlan, excludedColumns, expiredFlagsQuery, hasColumnAccess, migrationOptionUses, moduleDeprecations, moduleEventTriggers, moduleFileVersion, moduleLayout, notNullCheckName, renderBlocks, sameBlockFile, sameTenantColumn, sameTenantTrigger, scopePolicyName, sharedRolesProblems, subjectColumns, widenedCommands } from "better-supabase/sql";
38
39
  import { defineBucket, parseSize } from "better-supabase/storage";
39
40
  //#region src/cli/doctor/env.ts
40
41
  const PUBLIC_PREFIXES = [
@@ -258,6 +259,20 @@ const ADOPTION_RULES = [
258
259
  }];
259
260
  }
260
261
  },
262
+ {
263
+ code: "BS349",
264
+ severity: "warning",
265
+ title: "Block writes through a view Postgres can't update",
266
+ description: "A block table is mapped to a view of the app's (`blocks.<name>.tables`), and the block's TypeScript API inserts, updates or deletes its rows, but the view is not auto-updatable and has no `instead of` trigger: it has `distinct`, `group by`, a join, an aggregate or a set operation, or it is a materialized view. The block's functions that read the view work; the API calls that write it fail. Write those rows to the table under the view, add `instead of` triggers to the view, or map the block's table to a table.",
267
+ check: (context) => {
268
+ const views = appViewsOf(context);
269
+ if (Object.keys(views.ownViews).length === 0) return [];
270
+ return adoptedViews(context.config.blocks, appTablesOf(context), views).filter((view) => view.writes && !view.updatable).map((view) => ({
271
+ message: `blocks.${view.module}.tables.${view.logical} is the view ${view.view}, which Postgres can't write through, and the block's TypeScript API writes ${view.logical} rows. Those calls fail; write the rows to the table under the view, add instead of triggers, or map ${view.logical} to a table.`,
272
+ target: view.view
273
+ }));
274
+ }
275
+ },
261
276
  {
262
277
  code: "BS341",
263
278
  severity: "warning",
@@ -1612,7 +1627,7 @@ async function danglingAuditRegistrations(context) {
1612
1627
  async function missingAdoptedColumns(context) {
1613
1628
  const db = context.database;
1614
1629
  if (!db || "skipped" in db) return [];
1615
- const tables = adoptedTables(context.config.blocks, appTablesOf(context));
1630
+ const tables = adoptedTables(context.config.blocks, appTablesOf(context), appViewsOf(context));
1616
1631
  if (tables.length === 0) return [];
1617
1632
  const names = tables.map((table) => `(${literal$1(table.schema)}, ${literal$1(table.table)})`).join(", ");
1618
1633
  let rows;
@@ -1,21 +1,21 @@
1
1
  import { a as list, p as commandMeta, r as defineCliCommand } from "./command-CQ61x6gN.js";
2
2
  import { i as plain } from "./style-Bm2X5JrN.js";
3
3
  import { a as parseNames, i as failedResult, n as CliError } from "./errors-BTe6A15O.js";
4
- import { u as catalogFingerprint } from "./cache-CXgR_Ahi.js";
5
- import { a as serializeSnapshot, g as serializeGenerator, h as restrictSchemas, o as snapshotFile, r as openSource, t as loadSnapshot } from "./snapshot-C8MVPyO8.js";
6
- import { f as dataMigration } from "./module-migration-aPCckev6.js";
4
+ import { u as catalogFingerprint } from "./cache-AznIssjI.js";
5
+ import { a as serializeSnapshot, g as serializeGenerator, h as restrictSchemas, o as snapshotFile, r as openSource, t as loadSnapshot } from "./snapshot-uTUlEzY2.js";
6
+ import { f as dataMigration } from "./module-migration-O_IxewFs.js";
7
7
  import { d as GEN_TASKS, p as isGenTask } from "./config-9t5ec_N7.js";
8
8
  import { c as insideRoot, r as applyPlan, u as planResult } from "./files-CX71yBm8.js";
9
- import { n as runGen } from "./run-CvYVAztY.js";
10
- import { t as syncModules } from "./sync-btj01bcM.js";
11
- import { t as addModules } from "./add-DCI5JKjA.js";
12
- import { n as listModules, t as printModule } from "./print-BeWO7OJY.js";
9
+ import { n as runGen } from "./run-Bs4OKdDI.js";
10
+ import { t as syncModules } from "./sync-CZMRB3aU.js";
11
+ import { t as addModules } from "./add-I8OW-qJH.js";
12
+ import { n as listModules, t as printModule } from "./print-DosQIFSy.js";
13
13
  import { a as sourceFlags, i as sourceArgs, n as SOURCE_ARGS } from "./source-args-IpJRJO5t.js";
14
- import { a as runMetadataGen, n as checkMetadataFlags, t as EMITS } from "./metadata-DVx9Zgbj.js";
14
+ import { a as runMetadataGen, n as checkMetadataFlags, t as EMITS } from "./metadata-BfgHMe4q.js";
15
15
  import { a as runEnv } from "./env-BBl5L8Bf.js";
16
- import { c as watchLoop, o as parseInterval, r as specOptionsFromConfig, s as stampFiles, t as runSpec } from "./spec-DGVNMSSB.js";
16
+ import { c as watchLoop, o as parseInterval, r as specOptionsFromConfig, s as stampFiles, t as runSpec } from "./spec-Cm2einTO.js";
17
17
  import { t as runSeed } from "./seed-Cz8PcXeT.js";
18
- import { t as upgrade } from "./upgrade-B596d4t8.js";
18
+ import { t as upgrade } from "./upgrade-BFEIMC7U.js";
19
19
  import { existsSync } from "node:fs";
20
20
  import { resolve } from "node:path";
21
21
  //#region src/cli/commands/sql.ts
@@ -798,6 +798,6 @@ export declare function emitModule(model: Model, options: EmitOptions): string;
798
798
  export declare function loadConfig(cwd: string, explicit?: string, environment?: string, path?: string | undefined): Promise<ResolvedConfig>;
799
799
  //#endregion
800
800
  //#region src/cli/version.d.ts
801
- export declare const VERSION = "0.15.0";
801
+ export declare const VERSION = "0.16.0";
802
802
  //#endregion
803
803
  export type { Catalog, CatalogCheck, CatalogColumn, CatalogColumnGrant, CatalogEnum, CatalogForeignKey, CatalogFunction, CatalogFunctionArg, CatalogGrant, CatalogIndex, CatalogPolicy, CatalogTable, CatalogTrigger, CatalogUnique, Choice, Cli, CliArgs, CliCommand, CliCommandDef, CliContext, CliEnv, CliErrorCode, CliErrorOptions, CliIo, CliLog, CliProblem, CliProblemExtensions, CommandResult, CreateCliOptions, ExitCode, ExtrasFunction, ExtrasHook, ExtrasHookFunction, ExtrasTable, ForeignKeyAction, Format, GeneratorMetadata, IntrospectionSource, ManagementSourceOptions, NextStep, Paint, Prompter, Queryable, RunOptions, RunResult, Snapshot, SnapshotBucket, SnapshotExtras };
package/dist/cli/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { a as list, r as defineCliCommand } from "./command-CQ61x6gN.js";
2
- import { i as run, n as createCli, r as help, t as commandNames } from "./run-DYhLBcFW.js";
3
- import { t as VERSION } from "./version-Du4CgONY.js";
2
+ import { i as run, n as createCli, r as help, t as commandNames } from "./run-MRET30vh.js";
3
+ import { t as VERSION } from "./version-B2Dr6VmJ.js";
4
4
  import { n as CliError, t as CLI_ERRORS_URL } from "./errors-BTe6A15O.js";
5
- import { a as serializeSnapshot, i as parseSnapshot, l as introspect, t as loadSnapshot } from "./snapshot-C8MVPyO8.js";
6
- import { a as emitBlockConfig, l as buildModel, o as GENERATED_HEADER, r as renderFiles, s as emitModule } from "./render-ucJmUyuM.js";
7
- import { a as toCatalog, n as managementSource, r as pgSource } from "./source-DANaJJVc.js";
5
+ import { a as serializeSnapshot, i as parseSnapshot, l as introspect, t as loadSnapshot } from "./snapshot-uTUlEzY2.js";
6
+ import { a as emitBlockConfig, l as buildModel, o as GENERATED_HEADER, r as renderFiles, s as emitModule } from "./render-5y5a1QZr.js";
7
+ import { a as toCatalog, n as managementSource, r as pgSource } from "./source-D2gJHKwC.js";
8
8
  import { s as loadConfig } from "./config-9t5ec_N7.js";
9
- import { n as runGen } from "./run-CvYVAztY.js";
9
+ import { n as runGen } from "./run-Bs4OKdDI.js";
10
10
  //#region src/cli/introspect/from-catalog.ts
11
11
  /**
12
12
  * Builds a snapshot from catalog records: the inverse of `toCatalog`. Tests and
@@ -2,14 +2,14 @@ import { a as list, p as commandMeta, r as defineCliCommand } from "./command-CQ
2
2
  import { i as plain } from "./style-Bm2X5JrN.js";
3
3
  import { n as CliError } from "./errors-BTe6A15O.js";
4
4
  import { r as readIfExists } from "./io-DH1kcmmP.js";
5
- import { l as TYPEGEN_VERSION } from "./cache-CXgR_Ahi.js";
5
+ import { l as TYPEGEN_VERSION } from "./cache-AznIssjI.js";
6
6
  import { a as findConfig, s as loadConfig } from "./config-9t5ec_N7.js";
7
- import { r as contentMapperFiles } from "./content-mapper-DNs7lTu7.js";
7
+ import { r as contentMapperFiles } from "./content-mapper-DCrz6OIv.js";
8
8
  import { i as changeLines, n as PLAN_ARGS, r as applyPlan, u as planResult } from "./files-CX71yBm8.js";
9
- import { C as promptConventions, S as hasConventionFlags, _ as templatePlan, b as conventionFlags, c as AUTHZ_NOTE, d as chooseIntegrations, f as integrationFiles, g as templateContextFor, h as parseIntegrations, i as blocksWiringPath, l as createUrlParam, m as packagesFor, o as writeDesign, p as overwrite, r as blockConfigImport, s as readPresetInput, u as CANCELLED, v as CONVENTION_ARGS, w as withConventions, x as defaultConventions, y as CONVENTION_COMPLETIONS } from "./add-BgsUjCan.js";
10
- import { a as wiringFiles, c as baseFiles, f as needsLib, i as wiringChecklist, m as suggestedIntegrations, n as latestMigrationVersion, o as wiringFor, p as resolveIntegrations, r as configInstances, s as TEMPLATES } from "./migration-safety-D7PhzFxm.js";
9
+ import { C as promptConventions, S as hasConventionFlags, _ as templatePlan, b as conventionFlags, c as AUTHZ_NOTE, d as chooseIntegrations, f as integrationFiles, g as templateContextFor, h as parseIntegrations, i as blocksWiringPath, l as createUrlParam, m as packagesFor, o as writeDesign, p as overwrite, r as blockConfigImport, s as readPresetInput, u as CANCELLED, v as CONVENTION_ARGS, w as withConventions, x as defaultConventions, y as CONVENTION_COMPLETIONS } from "./add-D7TkPdco.js";
10
+ import { a as wiringFiles, c as baseFiles, f as needsLib, i as wiringChecklist, m as suggestedIntegrations, n as latestMigrationVersion, o as wiringFor, p as resolveIntegrations, r as configInstances, s as TEMPLATES } from "./migration-safety-BnnXPAro.js";
11
11
  import { n as installCommand, t as detectProject } from "./detect-D9JaAX20.js";
12
- import { s as enablePgDelta, t as syncModules } from "./sync-btj01bcM.js";
12
+ import { s as enablePgDelta, t as syncModules } from "./sync-CZMRB3aU.js";
13
13
  import { existsSync } from "node:fs";
14
14
  import { join, posix, resolve } from "node:path";
15
15
  import { glob, readFile } from "node:fs/promises";
@@ -0,0 +1,141 @@
1
+ //#region src/cli/sql/legacy-prefix.ts
2
+ /**
3
+ * Prefixes of the names the library builds outside the module files (realtime
4
+ * broadcast triggers, tenant checks, state transitions, JSON Schema checks).
5
+ */
6
+ const LEGACY_PREFIXES = [
7
+ "bs_broadcast_",
8
+ "bs_same_tenant_",
9
+ "bs_transition_",
10
+ "bs_json_"
11
+ ];
12
+ const LEGACY_NAME = /\bbs_[a-z0-9_]+/g;
13
+ /**
14
+ * JWT claims under their 0.14 name, which 0.15 module SQL still reads; they
15
+ * name no database object.
16
+ */
17
+ const LEGACY_CLAIMS = /* @__PURE__ */ new Set(["bs_permission_cap"]);
18
+ /** The `bs_` object names in installed module SQL, before 0.15 renamed them. */
19
+ function legacyPrefixNames(text) {
20
+ return [...new Set(text.match(LEGACY_NAME))].filter((name) => !LEGACY_CLAIMS.has(name)).toSorted();
21
+ }
22
+ const array = (values) => `array[${values.map((value) => `'${value.replaceAll("'", "''")}'`).join(", ")}]::text[]`;
23
+ /**
24
+ * Renames the installed `bs_` triggers, policies, constraints, indexes and
25
+ * functions to `bsb_`, so the module files' `drop ... if exists bsb_x` replace
26
+ * them instead of adding a second copy. Only the names in `names` and the
27
+ * runtime prefixes are renamed, and only while the new name is free, so the
28
+ * step can run again.
29
+ */
30
+ function legacyPrefixSql(names) {
31
+ return `do $bsb_rename$
32
+ declare
33
+ v_names constant text[] := ${array(names)};
34
+ v_prefixes constant text[] := ${array(LEGACY_PREFIXES)};
35
+ r record;
36
+ begin
37
+ for r in
38
+ select t.tgname as name, t.tgrelid::regclass::text as rel
39
+ from pg_trigger t
40
+ where not t.tgisinternal
41
+ and (t.tgname = any (v_names) or exists (select 1 from unnest(v_prefixes) x where starts_with(t.tgname, x)))
42
+ and not exists (select 1 from pg_trigger u where u.tgrelid = t.tgrelid and u.tgname = 'bsb_' || substr(t.tgname, 4))
43
+ loop
44
+ begin
45
+ execute format('alter trigger %I on %s rename to %I', r.name, r.rel, 'bsb_' || substr(r.name, 4));
46
+ exception when insufficient_privilege then
47
+ raise warning 'better-supabase: rename % to bsb_% by hand; the migration role does not own it', r.name, substr(r.name, 4);
48
+ end;
49
+ end loop;
50
+
51
+ for r in
52
+ select p.polname as name, p.polrelid::regclass::text as rel
53
+ from pg_policy p
54
+ where (p.polname = any (v_names) or exists (select 1 from unnest(v_prefixes) x where starts_with(p.polname, x)))
55
+ and not exists (select 1 from pg_policy q where q.polrelid = p.polrelid and q.polname = 'bsb_' || substr(p.polname, 4))
56
+ loop
57
+ begin
58
+ execute format('alter policy %I on %s rename to %I', r.name, r.rel, 'bsb_' || substr(r.name, 4));
59
+ exception when insufficient_privilege then
60
+ raise warning 'better-supabase: rename % to bsb_% by hand; the migration role does not own it', r.name, substr(r.name, 4);
61
+ end;
62
+ end loop;
63
+
64
+ for r in
65
+ select c.conname as name, c.conrelid::regclass::text as rel
66
+ from pg_constraint c
67
+ where c.conrelid <> 0
68
+ and (c.conname = any (v_names) or exists (select 1 from unnest(v_prefixes) x where starts_with(c.conname, x)))
69
+ and not exists (select 1 from pg_constraint d where d.conrelid = c.conrelid and d.conname = 'bsb_' || substr(c.conname, 4))
70
+ loop
71
+ begin
72
+ execute format('alter table %s rename constraint %I to %I', r.rel, r.name, 'bsb_' || substr(r.name, 4));
73
+ exception when insufficient_privilege then
74
+ raise warning 'better-supabase: rename % to bsb_% by hand; the migration role does not own it', r.name, substr(r.name, 4);
75
+ end;
76
+ end loop;
77
+
78
+ for r in
79
+ select n.nspname as schema, i.relname as name
80
+ from pg_class i
81
+ join pg_namespace n on n.oid = i.relnamespace
82
+ where i.relkind in ('i', 'I')
83
+ and (i.relname = any (v_names) or exists (select 1 from unnest(v_prefixes) x where starts_with(i.relname, x)))
84
+ and not exists (select 1 from pg_constraint c where c.conindid = i.oid)
85
+ and to_regclass(format('%I.%I', n.nspname, 'bsb_' || substr(i.relname, 4))) is null
86
+ loop
87
+ begin
88
+ execute format('alter index %I.%I rename to %I', r.schema, r.name, 'bsb_' || substr(r.name, 4));
89
+ exception when insufficient_privilege then
90
+ raise warning 'better-supabase: rename % to bsb_% by hand; the migration role does not own it', r.name, substr(r.name, 4);
91
+ end;
92
+ end loop;
93
+
94
+ for r in
95
+ select f.oid::regprocedure::text as fn, f.proname as name
96
+ from pg_proc f
97
+ join pg_namespace n on n.oid = f.pronamespace
98
+ where n.nspname not in ('pg_catalog', 'information_schema')
99
+ and (f.proname = any (v_names) or exists (select 1 from unnest(v_prefixes) x where starts_with(f.proname, x)))
100
+ and not exists (
101
+ select 1 from pg_proc g
102
+ where g.pronamespace = f.pronamespace and g.proname = 'bsb_' || substr(f.proname, 4)
103
+ and g.proargtypes = f.proargtypes
104
+ )
105
+ loop
106
+ begin
107
+ execute format('alter function %s rename to %I', r.fn, 'bsb_' || substr(r.name, 4));
108
+ exception when insufficient_privilege then
109
+ raise warning 'better-supabase: rename % to bsb_% by hand; the migration role does not own it', r.name, substr(r.name, 4);
110
+ end;
111
+ end loop;
112
+ end
113
+ $bsb_rename$;`;
114
+ }
115
+ /**
116
+ * Creates `better_supabase.blocks` and copies the rows of the 0.14
117
+ * `better_supabase.modules` table into it, so the schema diff that drops the
118
+ * old table loses no installed versions.
119
+ */
120
+ const legacyBlocksTableSql = `create schema if not exists better_supabase;
121
+ create table if not exists better_supabase.blocks (
122
+ name text primary key,
123
+ version integer not null,
124
+ mode text not null,
125
+ installed_at timestamptz not null default now(),
126
+ updated_at timestamptz not null default now()
127
+ );
128
+ alter table better_supabase.blocks enable row level security;
129
+ revoke all on better_supabase.blocks from anon, authenticated;
130
+ grant select on better_supabase.blocks to service_role;
131
+ do $bsb_blocks$
132
+ begin
133
+ if to_regclass('better_supabase.modules') is not null then
134
+ insert into better_supabase.blocks (name, version, mode, installed_at, updated_at)
135
+ select name, version, mode, installed_at, updated_at from better_supabase.modules
136
+ on conflict (name) do nothing;
137
+ end if;
138
+ end
139
+ $bsb_blocks$;`;
140
+ //#endregion
141
+ export { legacyPrefixSql as a, legacyPrefixNames as i, LEGACY_PREFIXES as n, legacyBlocksTableSql as r, LEGACY_CLAIMS as t };
@@ -1,6 +1,6 @@
1
1
  import { r as errorText } from "./errors-BTe6A15O.js";
2
- import "./source-DANaJJVc.js";
3
- import { l as tableObject, n as exposed, s as qualified, t as catalogOf } from "./shared-LZroULBe.js";
2
+ import "./source-D2gJHKwC.js";
3
+ import { l as tableObject, n as exposed, s as qualified, t as catalogOf } from "./shared-BLqbvY2x.js";
4
4
  //#region src/cli/doctor/reserved-roles.ts
5
5
  /**
6
6
  * Supautils' `reserved_roles` on Supabase. Nobody but a superuser may alter,
@@ -1,6 +1,6 @@
1
1
  import { p as commandMeta, r as defineCliCommand } from "./command-CQ61x6gN.js";
2
- import { a as envelope, i as run } from "./run-DYhLBcFW.js";
3
- import { t as VERSION } from "./version-Du4CgONY.js";
2
+ import { a as envelope, i as run } from "./run-MRET30vh.js";
3
+ import { t as VERSION } from "./version-B2Dr6VmJ.js";
4
4
  import { n as CliError } from "./errors-BTe6A15O.js";
5
5
  import { n as consentToken } from "./agent-CbuPvI2x.js";
6
6
  import { C as optional, D as record, N as unknown, a as array, d as is, j as string$1, k as safeParse, o as boolean, t as PROCESS_ENV, x as object } from "./env-DMgjB_4y.js";
@@ -1,8 +1,8 @@
1
1
  import { n as CliError, r as errorText } from "./errors-BTe6A15O.js";
2
2
  import { i as readStdin } from "./io-DH1kcmmP.js";
3
- import { m as parseMetadataDocument, u as MetadataRejectedError } from "./snapshot-C8MVPyO8.js";
4
- import { c as metaPaths, n as render } from "./render-ucJmUyuM.js";
5
- import { i as generationNotices, n as runGen, o as fromMetadata, r as UNFORMATTED, t as refuseRowConditionedBuckets } from "./run-CvYVAztY.js";
3
+ import { m as parseMetadataDocument, u as MetadataRejectedError } from "./snapshot-uTUlEzY2.js";
4
+ import { c as metaPaths, n as render } from "./render-5y5a1QZr.js";
5
+ import { i as generationNotices, n as runGen, o as fromMetadata, r as UNFORMATTED, t as refuseRowConditionedBuckets } from "./run-Bs4OKdDI.js";
6
6
  import { basename, join, relative, resolve, sep } from "node:path";
7
7
  import { readFile } from "node:fs/promises";
8
8
  import { jsonSchema, standardSchema, valibot, zod } from "better-supabase/config";
@@ -1,5 +1,5 @@
1
1
  import { f as INTEGRATIONS } from "./config-9t5ec_N7.js";
2
- import { c as splitStatements } from "./shared-LZroULBe.js";
2
+ import { c as splitStatements } from "./shared-BLqbvY2x.js";
3
3
  import { dirname, join, posix } from "node:path";
4
4
  import { readdir } from "node:fs/promises";
5
5
  import { INTEGRATION_INFO, groupEntries } from "better-supabase/config";
@@ -1,13 +1,11 @@
1
1
  import { n as CliError } from "./errors-BTe6A15O.js";
2
- import { d as TypegenMissingError, i as parseSnapshot } from "./snapshot-C8MVPyO8.js";
3
- import { a as toCatalog } from "./source-DANaJJVc.js";
4
- import { d as readSupabaseToml, f as schemaPaths, n as declarativeSchemasDir, p as sqlWorkflow } from "./supabase-toml-CncmQbO0.js";
2
+ import { d as readSupabaseToml, p as sqlWorkflow } from "./supabase-toml-CncmQbO0.js";
5
3
  import { t as importFresh } from "./fresh-import-DzgsGHkX.js";
6
4
  import { i as changeLines, r as applyPlan } from "./files-CX71yBm8.js";
7
- import { existsSync } from "node:fs";
8
- import { dirname, join, relative, resolve, sep } from "node:path";
5
+ import { a as sqlPlan, i as schemasDirOf, n as migrationsDir, r as moduleLayoutFor } from "./sql-layout-lUWenjJw.js";
6
+ import { resolve } from "node:path";
9
7
  import { readFile, readdir } from "node:fs/promises";
10
- import { MODULE_ID_TYPES, adoptedColumnProblems, auditRegistrations, compileReadSets, declaredPolicies, declaredTableColumns, declaredTables, declaredUpdatedAtTriggers, extensionSchema, moduleIdType, moduleLayout, modulePermissionKeys, moduleSchemaExtensions, policyGrants, renderBlocks, resolveBlocks, resolveExposeColumns, rlsTables, sameTenantLayout, scopeProblems, templateFunctions } from "better-supabase/sql";
8
+ import { MODULE_ID_TYPES, compileReadSets, moduleIdType, moduleLayout, modulePermissionKeys, moduleSchemaExtensions, renderBlocks, resolveBlocks, scopeProblems, templateFunctions } from "better-supabase/sql";
11
9
  import { isReadSet } from "better-supabase";
12
10
  //#region src/cli/authorization.ts
13
11
  /** How findings name the provider. */
@@ -210,215 +208,6 @@ const entitlementRequirements = (provider) => [...templateFunctions(provider.mem
210
208
  role: "supabase_auth_admin"
211
209
  }))];
212
210
  //#endregion
213
- //#region src/cli/sql-layout.ts
214
- /** The folder the module data files sit next to, for the project's workflow. */
215
- async function schemasDirOf(config) {
216
- const toml = await readSupabaseToml(config.root);
217
- return declarativeSchemasDir(toml, sqlWorkflow(config, toml));
218
- }
219
- /** The declarative schema files, then the migrations oldest first. */
220
- async function schemaTexts(config) {
221
- const toml = await readSupabaseToml(config.root);
222
- const migrations = resolve(config.root, migrationsDir(config));
223
- 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)) : []];
224
- return Promise.all(paths.map(async (path) => ({
225
- path,
226
- text: await readFile(resolve(config.root, path), "utf-8")
227
- })));
228
- }
229
- async function declarativeTexts(config) {
230
- const toml = await readSupabaseToml(config.root);
231
- const { files } = await schemaPaths(config.root, toml, sqlWorkflow(config, toml));
232
- if (files.length === 0) return schemaTexts(config);
233
- return Promise.all(files.map(async (path) => ({
234
- path,
235
- text: await readFile(resolve(config.root, path), "utf-8")
236
- })));
237
- }
238
- /**
239
- * The `better_supabase.audit(...)` calls in the declarative schemas, then the
240
- * migrations oldest first, so a later call or `unaudit` wins.
241
- */
242
- async function auditedTables(config) {
243
- return auditRegistrations(await schemaTexts(config));
244
- }
245
- /**
246
- * The layout `upgrade` and doctor render the module files with, so both see the
247
- * same grants, session policies, audit triggers and vector schema.
248
- */
249
- async function moduleLayoutFor(config, input) {
250
- const resolved = new Set(resolveBlocks(input.names, input.entitlementsProvider ? { entitlementsProvider: input.entitlementsProvider } : {}).map((module) => module.name));
251
- const own = await ownLayout(config);
252
- const adopted = adoptedColumnProblems(config.blocks, await declarativeTexts(config), config.schemas, own.ownTables);
253
- if (adopted.length > 0) throw new TypeError(adopted.join("\n"));
254
- const fromPolicies = resolved.has("grants") && config.blocks["grants"]?.options?.["fromPolicies"] === true;
255
- const sessionPolicies = resolved.has("sessions") && config.blocks["sessions"]?.options?.["policies"] === true;
256
- const sameTenant = config.blocks["memberships"]?.options?.["sameTenant"];
257
- const autoSameTenant = resolved.has("memberships") && typeof sameTenant === "object" && sameTenant !== null && "auto" in sameTenant && sameTenant.auto === true;
258
- const base = moduleLayout(config, input.testsDir, input.readSets ?? [], input.entitlementsProvider, input.accessProvider, input.permissionCatalog);
259
- const grants = base.grants === void 0 ? void 0 : resolveExposeColumns(base.grants, await declarativeTexts(config), config.schemas);
260
- return {
261
- ...base,
262
- ...grants === void 0 ? {} : { grants },
263
- schemasDir: await schemasDirOf(config),
264
- ...resolved.has("audit") ? { auditedTables: await auditedTables(config) } : {},
265
- ...resolved.has("vector-search") ? vectorSchemaOf(await schemaTexts(config)) : {},
266
- ...fromPolicies ? { policyGrants: policyGrants(await declarativeTexts(config), config.schemas) } : {},
267
- ...fromPolicies ? { rlsTables: rlsTables(await declarativeTexts(config), config.schemas) } : {},
268
- ...autoSameTenant ? sameTenantLayout(await declarativeTexts(config), config.schemas) : {},
269
- ...fromPolicies || sessionPolicies ? { declaredTables: declaredTables(await declarativeTexts(config), config.schemas) } : {},
270
- ...own
271
- };
272
- }
273
- /**
274
- * `ownTables`, `ownColumns`, `ownUpdatedAtTriggers` and `ownPolicies`: the
275
- * database's tables, then the app's files.
276
- */
277
- async function ownLayout(config) {
278
- const database = await databaseTables(config);
279
- const own = (await declarativeTexts(config)).filter((source) => !writtenByBlocks(source));
280
- const columns = Object.fromEntries([...declaredTableColumns(own, config.schemas)].map(([table, names]) => [table, [...names]]));
281
- return {
282
- ownTables: {
283
- ...database.tables,
284
- ...ownDeclaredTables(own, config.schemas)
285
- },
286
- ownColumns: {
287
- ...database.columns,
288
- ...columns
289
- },
290
- ownUpdatedAtTriggers: {
291
- ...database.updatedAtTriggers,
292
- ...declaredUpdatedAtTriggers(own, config.schemas)
293
- },
294
- ownPolicies: {
295
- ...database.policies,
296
- ...declaredPolicies(own, config.schemas)
297
- }
298
- };
299
- }
300
- /** A trigger function named like one that keeps `updated_at` current. */
301
- const UPDATED_AT_FUNCTION = /updated_at|moddatetime|touch/i;
302
- const BLOCK_MARKER = /^-- @(?:bsb-block|bsb-tables|bs-module|bs-app-tables)\b/m;
303
- const BLOCK_MIGRATION = /_better_supabase_[a-z_]+\.sql$/;
304
- /**
305
- * The `schema.table`s that the files better-supabase wrote create, among
306
- * `sources`; a table an app table entry enriches is not one of them.
307
- */
308
- function blockDeclaredTables(sources, schemas) {
309
- return new Set(declaredTables(sources.filter(writtenByBlocks), schemas));
310
- }
311
- /** A file better-supabase wrote: a block file or a module migration. */
312
- function writtenByBlocks(source) {
313
- return BLOCK_MARKER.test(source.text) || BLOCK_MIGRATION.test(source.path);
314
- }
315
- /**
316
- * The tables in the saved snapshot (`source.snapshot`) that no block file or
317
- * module migration created, mapped to `database`. Without a snapshot, the app's
318
- * schema files and migrations stand in for it.
319
- */
320
- async function databaseTables(config) {
321
- const none = {
322
- tables: {},
323
- columns: {},
324
- updatedAtTriggers: {},
325
- policies: {}
326
- };
327
- const path = config.source.snapshot;
328
- if (path === void 0 || !existsSync(resolve(config.root, path))) return none;
329
- let snapshot;
330
- try {
331
- snapshot = await parseSnapshot(JSON.parse(await readFile(resolve(config.root, path), "utf-8")), path);
332
- } catch (cause) {
333
- if (cause instanceof TypegenMissingError) return none;
334
- throw cause;
335
- }
336
- const created = blockDeclaredTables(await schemaTexts(config), config.schemas);
337
- const tables = {};
338
- const columns = {};
339
- const updatedAtTriggers = {};
340
- const policies = {};
341
- for (const table of toCatalog(snapshot).tables) {
342
- const name = `${table.schema}.${table.name}`;
343
- if (config.schemas.includes(table.schema) && !created.has(name)) {
344
- tables[name] = "database";
345
- columns[name] = table.columns.map((column) => column.name);
346
- const kept = table.triggers.find((trigger) => !trigger.name.startsWith("bsb_") && trigger.events.includes("update") && UPDATED_AT_FUNCTION.test(trigger.function));
347
- if (kept !== void 0) updatedAtTriggers[name] = kept.name;
348
- policies[name] = table.policies.filter((policy) => !policy.name.startsWith("bsb_"));
349
- }
350
- }
351
- return {
352
- tables,
353
- columns,
354
- updatedAtTriggers,
355
- policies
356
- };
357
- }
358
- /**
359
- * `schema.table` to the app's own schema file that creates it: every
360
- * declarative file, or migration, that better-supabase didn't write.
361
- */
362
- function ownDeclaredTables(sources, schemas) {
363
- const ownTables = {};
364
- for (const source of sources) for (const table of declaredTables([source], schemas)) ownTables[table] ??= source.path;
365
- return ownTables;
366
- }
367
- function vectorSchemaOf(sources) {
368
- const schema = extensionSchema(sources, "vector");
369
- return schema === void 0 ? {} : { vectorSchema: schema };
370
- }
371
- /**
372
- * The folder that holds both the project root and `sql.dir`: the root, or an
373
- * ancestor when `sql.dir` points at a shared stack. The `sql` commands write
374
- * SQL files only inside it.
375
- */
376
- function sqlRoot(config) {
377
- const dir = resolve(config.root, config.sql.dir);
378
- let stop = resolve(config.root);
379
- while (dir !== stop && !dir.startsWith(stop + sep) && dirname(stop) !== stop) stop = dirname(stop);
380
- return stop;
381
- }
382
- /**
383
- * A plan for files under the project root or `sql.dir`, with paths relative to
384
- * the project root.
385
- */
386
- function sqlPlan(config, plan) {
387
- return {
388
- ...plan,
389
- root: sqlRoot(config),
390
- base: config.root,
391
- files: plan.files.map((file) => ({
392
- ...file,
393
- path: resolve(config.root, file.path)
394
- })),
395
- ...plan.remove ? { remove: plan.remove.map((entry) => {
396
- const path = resolve(config.root, typeof entry === "string" ? entry : entry.path);
397
- return typeof entry === "string" ? path : {
398
- ...entry,
399
- path
400
- };
401
- }) } : {}
402
- };
403
- }
404
- /**
405
- * The migrations folder next to the `config.toml` found walking up from
406
- * `sql.dir`, relative to the root; `supabase/migrations` without one. The walk
407
- * stops where `sql.dir` and the root meet, so a `sql.dir` outside the project
408
- * (a shared stack in a monorepo) finds that stack's folder.
409
- */
410
- function migrationsDir(config) {
411
- const root = resolve(config.root);
412
- let dir = resolve(root, config.sql.dir);
413
- const stop = sqlRoot(config);
414
- for (;;) {
415
- if (existsSync(join(dir, "config.toml"))) return relative(root, join(dir, "migrations")).replaceAll("\\", "/");
416
- if (dir === stop || dirname(dir) === dir) break;
417
- dir = dirname(dir);
418
- }
419
- return "supabase/migrations";
420
- }
421
- //#endregion
422
211
  //#region src/cli/read-sets.ts
423
212
  /** Every read set exported by the modules in `config.readSets`. */
424
213
  async function loadReadSets(config) {
@@ -731,4 +520,4 @@ async function writeLatestMigration(config, suffix, contents, options) {
731
520
  };
732
521
  }
733
522
  //#endregion
734
- export { providerLabel as A, sqlPlan as C, entitlementRequirements as D, accessRequirements as E, entitlementsMode as O, moduleLayoutFor as S, accessProviderMode as T, layoutFor as _, migrationInstances as a, blockDeclaredTables as b, sameModuleMigration as c, DATA_NEXT as d, dataMigration as f, layout as g, MEMBERSHIP_CLAIM_MODULES as h, migrationHolds as i, unsafeKey as j, moduleKeyProblems as k, writeLatestMigration as l, writeExtensionsMigration as m, READ_SETS_SUFFIX as n, migrationModules as o, migrationStamp as p, latestMigration as r, renderModuleMigration as s, MODULES_SUFFIX as t, writesMigrations as u, providerOwnsMemberships as v, writtenByBlocks as w, migrationsDir as x, compiledReadSets as y };
523
+ export { entitlementsMode as C, unsafeKey as E, entitlementRequirements as S, providerLabel as T, layoutFor as _, migrationInstances as a, accessProviderMode as b, sameModuleMigration as c, DATA_NEXT as d, dataMigration as f, layout as g, MEMBERSHIP_CLAIM_MODULES as h, migrationHolds as i, writeLatestMigration as l, writeExtensionsMigration as m, READ_SETS_SUFFIX as n, migrationModules as o, migrationStamp as p, latestMigration as r, renderModuleMigration as s, MODULES_SUFFIX as t, writesMigrations as u, providerOwnsMemberships as v, moduleKeyProblems as w, accessRequirements as x, compiledReadSets as y };
@@ -1,5 +1,5 @@
1
1
  import { n as CliError } from "./errors-BTe6A15O.js";
2
- import { g as layout, o as migrationModules, r as latestMigration, u as writesMigrations } from "./module-migration-aPCckev6.js";
2
+ import { g as layout, o as migrationModules, r as latestMigration, u as writesMigrations } from "./module-migration-O_IxewFs.js";
3
3
  import { existsSync } from "node:fs";
4
4
  import { resolve } from "node:path";
5
5
  import { SQL_MODULES, contractSignature, customContracts, moduleBody, moduleFilePaths } from "better-supabase/sql";
@@ -2,14 +2,15 @@ import { p as commandMeta, r as defineCliCommand } from "./command-CQ61x6gN.js";
2
2
  import { i as plain } from "./style-Bm2X5JrN.js";
3
3
  import { n as CliError } from "./errors-BTe6A15O.js";
4
4
  import { r as readIfExists, t as display } from "./io-DH1kcmmP.js";
5
- import { C as sqlPlan, _ as layoutFor } from "./module-migration-aPCckev6.js";
5
+ import { _ as layoutFor } from "./module-migration-O_IxewFs.js";
6
6
  import { i as changeLines, n as PLAN_ARGS, r as applyPlan, t as HAND_EDITED, u as planResult } from "./files-CX71yBm8.js";
7
- import { g as templateContextFor, i as blocksWiringPath, n as blockClients } from "./add-BgsUjCan.js";
7
+ import { a as sqlPlan } from "./sql-layout-lUWenjJw.js";
8
+ import { g as templateContextFor, i as blocksWiringPath, n as blockClients } from "./add-D7TkPdco.js";
8
9
  import { t as detectProject } from "./detect-D9JaAX20.js";
9
10
  import { _ as wiringBlocks, a as configObject, c as mask, i as closingIndex, l as properties } from "./config-edit-CrWfk8s3.js";
10
- import { n as guardedRemoval } from "./sync-btj01bcM.js";
11
+ import { n as guardedRemoval } from "./sync-CZMRB3aU.js";
11
12
  import { t as SQL_ARGS } from "./args-UEwg0l-N.js";
12
- import { t as blockNames } from "./blocks-BZHI8mRC.js";
13
+ import { t as blockNames } from "./blocks-xk-SE8gS.js";
13
14
  import { i as tidyInline, t as cutRange } from "./config-group-C8tjut39.js";
14
15
  import { existsSync } from "node:fs";
15
16
  import { resolve } from "node:path";