better-supabase 0.15.0 → 0.15.1

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 (284) 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-D_Hz-ik5.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/{app-tables-CF2DD-Mu.d.ts → app-tables-CbCFSXLG.d.ts} +1 -1
  15. package/dist/{approvals-Crutd4-o.d.ts → approvals-Dh9dUXrN.d.ts} +1 -1
  16. package/dist/{assistant-CD_h8Vxx.d.ts → assistant-ndGdOBax.d.ts} +2 -2
  17. package/dist/astro/index.d.ts +2 -2
  18. package/dist/astro/index.js +2 -2
  19. package/dist/{authorization-hooks-Cs1vP_ej.d.ts → authorization-hooks-D_pwXlBs.d.ts} +4 -0
  20. package/dist/{bind-CrMBwrPN.d.ts → bind-h5jre2K0.d.ts} +3 -3
  21. package/dist/{block-env-B_uEM2xz.d.ts → block-env-BrfRvPrj.d.ts} +4 -4
  22. package/dist/blocks/access-requests/index.d.ts +1 -1
  23. package/dist/blocks/activities/index.d.ts +2 -2
  24. package/dist/blocks/agents/index.d.ts +2 -2
  25. package/dist/blocks/ai-cache/index.d.ts +2 -2
  26. package/dist/blocks/ai-chat/index.d.ts +5 -5
  27. package/dist/blocks/ai-files/index.d.ts +1 -1
  28. package/dist/blocks/ai-keys/index.d.ts +1 -1
  29. package/dist/blocks/ai-schedules/index.d.ts +2 -2
  30. package/dist/blocks/announcements/index.d.ts +4 -4
  31. package/dist/blocks/api-keys/index.d.ts +2 -2
  32. package/dist/blocks/approvals/index.d.ts +2 -2
  33. package/dist/blocks/assets/index.d.ts +1 -1
  34. package/dist/blocks/assignment/index.d.ts +1 -1
  35. package/dist/blocks/attachments/index.d.ts +2 -2
  36. package/dist/blocks/audit/index.d.ts +3 -3
  37. package/dist/blocks/automations/index.d.ts +4 -4
  38. package/dist/blocks/billable-time/index.d.ts +1 -1
  39. package/dist/blocks/billing/index.d.ts +2 -2
  40. package/dist/blocks/bookings/index.d.ts +3 -3
  41. package/dist/blocks/bulk/index.d.ts +1 -1
  42. package/dist/blocks/calendar/index.d.ts +2 -2
  43. package/dist/blocks/catalog/index.d.ts +1 -1
  44. package/dist/blocks/channels/index.d.ts +1 -1
  45. package/dist/blocks/collections/index.d.ts +1 -1
  46. package/dist/blocks/comments/index.d.ts +4 -4
  47. package/dist/blocks/compliance/index.d.ts +1 -1
  48. package/dist/blocks/connectors/index.d.ts +1 -1
  49. package/dist/blocks/contacts/index.d.ts +1 -1
  50. package/dist/blocks/content/index.d.ts +1 -1
  51. package/dist/blocks/contracts/index.d.ts +1 -1
  52. package/dist/blocks/courses/index.d.ts +1 -1
  53. package/dist/blocks/created-by/index.d.ts +1 -1
  54. package/dist/blocks/custom-fields/index.d.ts +1 -1
  55. package/dist/blocks/data-lifecycle/index.d.ts +2 -2
  56. package/dist/blocks/deals/index.d.ts +1 -1
  57. package/dist/blocks/dispatch/index.d.ts +1 -1
  58. package/dist/blocks/documents/index.d.ts +1 -1
  59. package/dist/blocks/domains/index.d.ts +1 -1
  60. package/dist/blocks/donations/index.d.ts +1 -1
  61. package/dist/blocks/drive/index.d.ts +2 -2
  62. package/dist/blocks/employees/index.d.ts +2 -2
  63. package/dist/blocks/enrichment/index.d.ts +1 -1
  64. package/dist/blocks/enrollments/index.d.ts +1 -1
  65. package/dist/blocks/entitlements/index.d.ts +3 -3
  66. package/dist/blocks/expenses/index.d.ts +1 -1
  67. package/dist/blocks/field-history/index.d.ts +1 -1
  68. package/dist/blocks/flags/index.d.ts +1 -1
  69. package/dist/blocks/forecasts/index.d.ts +1 -1
  70. package/dist/blocks/forms/index.d.ts +2 -2
  71. package/dist/blocks/goals/index.d.ts +1 -1
  72. package/dist/blocks/guests/index.d.ts +1 -1
  73. package/dist/blocks/hiring/index.d.ts +1 -1
  74. package/dist/blocks/identities/index.d.ts +2 -2
  75. package/dist/blocks/imports/index.d.ts +1 -1
  76. package/dist/blocks/inbox/index.d.ts +5 -5
  77. package/dist/blocks/incidents/index.d.ts +1 -1
  78. package/dist/blocks/index.d.ts +2 -2
  79. package/dist/blocks/inventory/index.d.ts +2 -2
  80. package/dist/blocks/invoices/index.d.ts +1 -1
  81. package/dist/blocks/knowledge/index.d.ts +2 -2
  82. package/dist/blocks/lead-scoring/index.d.ts +1 -1
  83. package/dist/blocks/leases/index.d.ts +1 -1
  84. package/dist/blocks/leave/index.d.ts +1 -1
  85. package/dist/blocks/ledger/index.d.ts +1 -1
  86. package/dist/blocks/mail-sync/index.d.ts +1 -1
  87. package/dist/blocks/memberships/index.d.ts +1 -1
  88. package/dist/blocks/memory/index.d.ts +3 -3
  89. package/dist/blocks/messaging/index.d.ts +4 -4
  90. package/dist/blocks/metrics/index.d.ts +2 -2
  91. package/dist/blocks/mfa/index.d.ts +2 -2
  92. package/dist/blocks/moderation/index.d.ts +1 -1
  93. package/dist/blocks/notifications/index.d.ts +5 -5
  94. package/dist/blocks/numbering/index.d.ts +1 -1
  95. package/dist/blocks/oauth-server/index.d.ts +1 -1
  96. package/dist/blocks/onboarding/index.d.ts +2 -2
  97. package/dist/blocks/orders/index.d.ts +3 -3
  98. package/dist/blocks/organizations/index.d.ts +2 -2
  99. package/dist/blocks/outbox/index.d.ts +2 -2
  100. package/dist/blocks/passes/index.d.ts +2 -2
  101. package/dist/blocks/permissions/index.d.ts +3 -3
  102. package/dist/blocks/pipelines/index.d.ts +1 -1
  103. package/dist/blocks/posts/index.d.ts +1 -1
  104. package/dist/blocks/profiles/index.d.ts +1 -1
  105. package/dist/blocks/promotions/index.d.ts +1 -1
  106. package/dist/blocks/push/index.d.ts +2 -2
  107. package/dist/blocks/queue/index.d.ts +2 -2
  108. package/dist/blocks/queue/index.js +1 -1
  109. package/dist/blocks/quotes/index.d.ts +1 -1
  110. package/dist/blocks/rank/index.d.ts +2 -2
  111. package/dist/blocks/reactions/index.d.ts +4 -4
  112. package/dist/blocks/relations/index.d.ts +1 -1
  113. package/dist/blocks/reminders/index.d.ts +3 -3
  114. package/dist/blocks/reviews/index.d.ts +1 -1
  115. package/dist/blocks/saved-views/index.d.ts +2 -2
  116. package/dist/blocks/scores/index.d.ts +1 -1
  117. package/dist/blocks/search/index.d.ts +3 -3
  118. package/dist/blocks/security-events/index.d.ts +1 -1
  119. package/dist/blocks/segments/index.d.ts +1 -1
  120. package/dist/blocks/sequences/index.d.ts +1 -1
  121. package/dist/blocks/service-accounts/index.d.ts +1 -1
  122. package/dist/blocks/sessions/index.d.ts +2 -2
  123. package/dist/blocks/settings/index.d.ts +2 -2
  124. package/dist/blocks/share-links/index.d.ts +1 -1
  125. package/dist/blocks/shipments/index.d.ts +1 -1
  126. package/dist/blocks/signatures/index.d.ts +1 -1
  127. package/dist/blocks/signing-keys/index.d.ts +1 -1
  128. package/dist/blocks/sla/index.d.ts +1 -1
  129. package/dist/blocks/sso/index.d.ts +1 -1
  130. package/dist/blocks/state-machine/index.d.ts +1 -1
  131. package/dist/blocks/subjects/index.d.ts +2 -2
  132. package/dist/blocks/tags/index.d.ts +2 -2
  133. package/dist/blocks/tasks/index.d.ts +2 -2
  134. package/dist/blocks/teams/index.d.ts +1 -1
  135. package/dist/blocks/templates/index.d.ts +3 -3
  136. package/dist/blocks/time-tracking/index.d.ts +1 -1
  137. package/dist/blocks/timeline/index.d.ts +1 -1
  138. package/dist/blocks/trash/index.d.ts +1 -1
  139. package/dist/blocks/undo/index.d.ts +2 -2
  140. package/dist/blocks/updated-at/index.d.ts +1 -1
  141. package/dist/blocks/usage/index.d.ts +3 -3
  142. package/dist/blocks/vercel-marketplace/index.d.ts +1 -1
  143. package/dist/blocks/versions/index.d.ts +1 -1
  144. package/dist/blocks/waitlist/index.d.ts +1 -1
  145. package/dist/blocks/webhooks/index.d.ts +3 -3
  146. package/dist/blocks/workflow-editor/index.d.ts +6 -6
  147. package/dist/blocks/workflow-editor/index.js +12 -1
  148. package/dist/blocks/workflows/index.d.ts +4 -4
  149. package/dist/{bookings-D4dvGXiR.d.ts → bookings-Dox2rced.d.ts} +1 -1
  150. package/dist/chat-sdk/index.d.ts +1 -1
  151. package/dist/cli/{add-DCI5JKjA.js → add-C04vkBk9.js} +2 -2
  152. package/dist/cli/add-CUH0rORo.js +1 -0
  153. package/dist/cli/{add-BgsUjCan.js → add-DNOL9PDu.js} +17 -12
  154. package/dist/cli/{backfill-nxPbcsns.js → backfill-VFzf-TJP.js} +1 -1
  155. package/dist/cli/bin.js +1 -1
  156. package/dist/cli/{blocks-Cr4HGePW.js → blocks-Bn7WUca5.js} +1 -1
  157. package/dist/cli/{blocks-BZHI8mRC.js → blocks-Cb7mILFU.js} +1 -1
  158. package/dist/cli/{cache-CXgR_Ahi.js → cache-DkplpIGe.js} +1 -1
  159. package/dist/cli/{codemod-DSN7iAdg.js → codemod-BbaE5dL_.js} +95 -3
  160. package/dist/cli/{content-mapper-DNs7lTu7.js → content-mapper-Cdx6arxu.js} +2 -2
  161. package/dist/cli/{doctor-DDrEM6S1.js → doctor-C-VO-QQ2.js} +29 -14
  162. package/dist/cli/{gen-MtijJQ9r.js → gen-yRHOHW1b.js} +10 -10
  163. package/dist/cli/index.d.ts +1 -1
  164. package/dist/cli/index.js +6 -6
  165. package/dist/cli/{init-D-aDv9r5.js → init-BOw0SX65.js} +5 -5
  166. package/dist/cli/legacy-prefix-DkTA3Rhx.js +141 -0
  167. package/dist/cli/{live-iEeH15ck.js → live-Lmg-hYyO.js} +2 -2
  168. package/dist/cli/{mcp-BAPyaQ62.js → mcp-DQ1zR2eA.js} +2 -2
  169. package/dist/cli/{metadata-DVx9Zgbj.js → metadata-CZaxkv21.js} +3 -3
  170. package/dist/cli/{migration-safety-D7PhzFxm.js → migration-safety-BbhLu2fo.js} +1 -1
  171. package/dist/cli/{module-migration-aPCckev6.js → module-migration-DOn6EmNz.js} +5 -216
  172. package/dist/cli/{print-BeWO7OJY.js → print-D_xf8PPj.js} +1 -1
  173. package/dist/cli/{remove-B46Dmd2M.js → remove-BY_TOTRj.js} +5 -4
  174. package/dist/cli/{render-ucJmUyuM.js → render-lJmHr0y9.js} +3 -3
  175. package/dist/cli/{run-CvYVAztY.js → run-BJ6IMs_H.js} +20 -7
  176. package/dist/cli/{run-DYhLBcFW.js → run-DkB0fhc9.js} +20 -20
  177. package/dist/cli/{shared-LZroULBe.js → shared-Bh-6IqJS.js} +1 -1
  178. package/dist/cli/{snapshot-C8MVPyO8.js → snapshot-Bzcigm7T.js} +2 -2
  179. package/dist/cli/{source-DANaJJVc.js → source-WoLdcQzN.js} +1 -1
  180. package/dist/cli/{spec-g8_G5K7o.js → spec-BF_dpwzW.js} +1 -1
  181. package/dist/cli/{spec-DGVNMSSB.js → spec-CZMiLhv_.js} +2 -2
  182. package/dist/cli/sql-layout-rFP0oq1N.js +247 -0
  183. package/dist/cli/{sync-btj01bcM.js → sync-mANmYYoL.js} +2 -1
  184. package/dist/cli/{upgrade-B596d4t8.js → upgrade-B0Q9wMs-.js} +4 -137
  185. package/dist/cli/{upgrade-Dw3TMQzn.js → upgrade-BrNLt92u.js} +2 -2
  186. package/dist/cli/{version-Du4CgONY.js → version-CyavsyGA.js} +1 -1
  187. package/dist/client/index.d.ts +5 -5
  188. package/dist/client/native/index.d.ts +4 -4
  189. package/dist/{composite-BARuBEDE.js → composite-B3TIjId4.js} +1 -1
  190. package/dist/{composite-Dsxj7T5K.d.ts → composite-BZYXlVBN.d.ts} +2 -2
  191. package/dist/config/index.d.ts +1 -1
  192. package/dist/{context-CEuTKrkz.d.ts → context-TGX2eDS5.d.ts} +24 -2
  193. package/dist/{controller-BrP0gn47.d.ts → controller-DyPPMFSw.d.ts} +1 -1
  194. package/dist/{conversion-BAbucuXq.d.ts → conversion-O-kyhXcC.d.ts} +1 -1
  195. package/dist/create/index.d.ts +2 -2
  196. package/dist/create/index.js +1 -1
  197. package/dist/{define-block-BVcLQ3DF.d.ts → define-block-DvvcM54N.d.ts} +1 -1
  198. package/dist/delegation-C7eWP2r8.d.ts +14 -0
  199. package/dist/{delegation--93jRsVO.js → delegation-DGOIiT8k.js} +12 -5
  200. package/dist/edge/index.d.ts +1 -1
  201. package/dist/edge/index.js +3 -3
  202. package/dist/{embeddings-kFbRvuic.d.ts → embeddings-D_RsS6ow.d.ts} +1 -1
  203. package/dist/{entitlements-CJpYQXeE.d.ts → entitlements-BnhDBxLW.d.ts} +1 -1
  204. package/dist/{envelope-Bzu0JnY2.js → envelope-DEI2iX-d.js} +1 -1
  205. package/dist/eve/index.d.ts +2 -2
  206. package/dist/{eve-BFSwTu1z.d.ts → eve-B7jxYPCw.d.ts} +2 -2
  207. package/dist/{executor-_2ekNofh.d.ts → executor-Bi056Cnj.d.ts} +1 -1
  208. package/dist/expo/index.d.ts +1 -1
  209. package/dist/expo/index.js +2 -2
  210. package/dist/{field-errors-fsbFktYF.d.ts → field-errors-DYtg1mwv.d.ts} +5 -5
  211. package/dist/{framework-DDdkR7FX.js → framework-BozTXRzt.js} +1 -1
  212. package/dist/{framework-BKyTeS-j.d.ts → framework-h5lP_5yj.d.ts} +3 -3
  213. package/dist/{gateway-TD1pRfTP.d.ts → gateway-DzI687yd.d.ts} +3 -3
  214. package/dist/hono/index.d.ts +1 -1
  215. package/dist/hono/index.js +2 -2
  216. package/dist/{index-BnH4Gomw.d.ts → index-Ab4UeEn_.d.ts} +8 -8
  217. package/dist/{index-BUuVq1co.d.ts → index-B4gcStOz.d.ts} +2 -2
  218. package/dist/{index-C-qpk8EQ.d.ts → index-BAHGLvGD.d.ts} +1 -1
  219. package/dist/{index-CguFm716.d.ts → index-BfK6olKm.d.ts} +31 -3
  220. package/dist/{index-DLq69k3F.d.ts → index-BfkltrGJ.d.ts} +1 -1
  221. package/dist/{index-B938YqY-.d.ts → index-DN9mfmhA.d.ts} +1 -1
  222. package/dist/{knowledge-CtL-Vfgy.d.ts → knowledge-F1IhRI4Q.d.ts} +1 -1
  223. package/dist/mapper/bin.js +5 -5
  224. package/dist/mcp/index.d.ts +1 -1
  225. package/dist/mcp/index.js +1 -1
  226. package/dist/mcp/sdk/index.d.ts +1 -1
  227. package/dist/mcp/sdk/index.js +1 -1
  228. package/dist/next/index.d.ts +8 -8
  229. package/dist/next/index.js +2 -2
  230. package/dist/orpc/index.d.ts +1 -1
  231. package/dist/orpc/index.js +1 -1
  232. package/dist/otel/index.js +4 -4
  233. package/dist/{outbox-HvGAJuBe.d.ts → outbox-HxjZTfF6.d.ts} +1 -1
  234. package/dist/{ports-sx226JUL.d.ts → ports-CpdiQv1D.d.ts} +1 -1
  235. package/dist/powersync/index.d.ts +1 -1
  236. package/dist/preset/index.d.ts +3 -3
  237. package/dist/{push-token-D3Vcf0Pf.d.ts → push-token-B3m3pWAv.d.ts} +1 -1
  238. package/dist/query/index.d.ts +1 -1
  239. package/dist/react/index.d.ts +5 -5
  240. package/dist/react/native/index.d.ts +1 -1
  241. package/dist/react/server.d.ts +5 -5
  242. package/dist/react-router/index.d.ts +2 -2
  243. package/dist/react-router/index.js +2 -2
  244. package/dist/realtime/index.d.ts +4 -4
  245. package/dist/{record-form-BYs9xv_N.d.ts → record-form-DB_5Ue_B.d.ts} +1 -1
  246. package/dist/records/index.d.ts +7 -7
  247. package/dist/server/index.d.ts +7 -6
  248. package/dist/server/index.js +5 -4
  249. package/dist/{server-types-CFtehAsr.d.ts → server-types-7QPzW2bF.d.ts} +1 -1
  250. package/dist/{session-CH0SKgIz.d.ts → session-CfBCJGgc.d.ts} +1 -1
  251. package/dist/{sign-in-DNCdrk05.js → sign-in-B64114O4.js} +1 -1
  252. package/dist/solid/index.d.ts +5 -5
  253. package/dist/solid-start/index.d.ts +2 -2
  254. package/dist/solid-start/index.js +2 -2
  255. package/dist/sql/index.d.ts +4 -4
  256. package/dist/sql/index.js +2 -2
  257. package/dist/{sql-ClHIdgKS.js → sql-OLVW4t08.js} +275 -13
  258. package/dist/ssr/index.d.ts +1 -1
  259. package/dist/{subject-readers-BNSzkqw_.d.ts → subject-readers-8GySC9Z8.d.ts} +1 -1
  260. package/dist/svelte/index.d.ts +5 -5
  261. package/dist/sveltekit/index.d.ts +2 -2
  262. package/dist/sveltekit/index.js +2 -2
  263. package/dist/tanstack-start/index.d.ts +2 -2
  264. package/dist/tanstack-start/index.js +2 -2
  265. package/dist/{tenant-yYg0E2-n.d.ts → tenant-DzFsg0Pc.d.ts} +1 -1
  266. package/dist/testing/index.d.ts +10 -10
  267. package/dist/{timeline-CtG0sehj.d.ts → timeline-WrFMgd3U.d.ts} +2 -2
  268. package/dist/{topic-CJrQZQaa.d.ts → topic-DNFEFGKI.d.ts} +1 -1
  269. package/dist/{types-CAQBmpDx.d.ts → types-A4yyKEsg.d.ts} +1 -1
  270. package/dist/{types-SFRomQF7.d.ts → types-Czq9Xtpa.d.ts} +1 -7
  271. package/dist/{types-BBQLbui9.d.ts → types-DsRfiQ0v.d.ts} +1 -1
  272. package/dist/{usage-D7QkrwzV.d.ts → usage-Dp45V42p.d.ts} +1 -1
  273. package/dist/vue/index.d.ts +5 -5
  274. package/dist/{watch-topic-BcGfvZOE.d.ts → watch-topic-Bo9S2R4P.d.ts} +1 -1
  275. package/dist/workflow-sdk/builder/index.d.ts +3 -3
  276. package/dist/workflow-sdk/builder/index.js +1 -1
  277. package/dist/workflow-sdk/index.d.ts +1 -1
  278. package/dist/workflow-sdk/index.js +1 -1
  279. package/dist/{workflow-sdk-BFHu4sci.d.ts → workflow-sdk-B3Ss55Fy.d.ts} +1 -1
  280. package/dist/{workflow-sdk-BVlFEB5Q.js → workflow-sdk-Cf0LAOFF.js} +2 -2
  281. package/dist/yjs/index.d.ts +1 -1
  282. package/package.json +1 -1
  283. package/schemas/doctor-report-v1.json +1 -0
  284. package/dist/cli/add-DWjlVwvP.js +0 -1
@@ -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-WoLdcQzN.js";
3
+ import { l as tableObject, n as exposed, s as qualified, t as catalogOf } from "./shared-Bh-6IqJS.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-DkB0fhc9.js";
3
+ import { t as VERSION } from "./version-CyavsyGA.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-Bzcigm7T.js";
4
+ import { c as metaPaths, n as render } from "./render-lJmHr0y9.js";
5
+ import { i as generationNotices, n as runGen, o as fromMetadata, r as UNFORMATTED, t as refuseRowConditionedBuckets } from "./run-BJ6IMs_H.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-Bh-6IqJS.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-rFP0oq1N.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-DOn6EmNz.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-DOn6EmNz.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-rFP0oq1N.js";
8
+ import { g as templateContextFor, i as blocksWiringPath, n as blockClients } from "./add-DNOL9PDu.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-mANmYYoL.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-Cb7mILFU.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";
@@ -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-DkplpIGe.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-Bzcigm7T.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-WoLdcQzN.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-DkplpIGe.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-Bzcigm7T.js";
6
+ import { n as render } from "./render-lJmHr0y9.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-DOn6EmNz.js";
8
+ import { s as schemaStampPath } from "./content-mapper-Cdx6arxu.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-rFP0oq1N.js";
11
+ import { l as tableObject, n as exposed, o as policyObject, s as qualified, t as catalogOf } from "./shared-Bh-6IqJS.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-CyavsyGA.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-BOw0SX65.js").then((m) => m.initCommand)],
20
+ ["add", () => import("./add-CUH0rORo.js").then((m) => m.addCommand)],
21
+ ["remove", () => import("./remove-BY_TOTRj.js").then((m) => m.removeCommand)],
22
+ ["upgrade", () => import("./upgrade-BrNLt92u.js").then((m) => m.upgradeCommand)],
23
+ ["gen", () => import("./gen-yRHOHW1b.js").then((m) => m.genCommand)],
24
+ ["doctor", () => import("./doctor-C-VO-QQ2.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-VFzf-TJP.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-Bn7WUca5.js").then((m) => m.blocksListCommand)],
35
+ ["blocks view", () => import("./blocks-Bn7WUca5.js").then((m) => m.blocksViewCommand)],
36
+ ["blocks search", () => import("./blocks-Bn7WUca5.js").then((m) => m.blocksSearchCommand)],
37
+ ["spec emit", () => import("./spec-BF_dpwzW.js").then((m) => m.specEmitCommand)],
38
+ ["spec validate", () => import("./spec-BF_dpwzW.js").then((m) => m.specValidateCommand)],
39
+ ["mcp", () => import("./mcp-DQ1zR2eA.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-BbaE5dL_.js").then((m) => m.codemodCommand("0.4"))],
43
+ ["codemod 0.5", () => import("./codemod-BbaE5dL_.js").then((m) => m.codemodCommand("0.5"))],
44
+ ["codemod 0.6", () => import("./codemod-BbaE5dL_.js").then((m) => m.codemodCommand("0.6"))],
45
+ ["codemod 0.9", () => import("./codemod-BbaE5dL_.js").then((m) => m.codemodCommand("0.9"))],
46
+ ["codemod 0.11", () => import("./codemod-BbaE5dL_.js").then((m) => m.codemodCommand("0.11"))],
47
+ ["codemod 0.15", () => import("./codemod-BbaE5dL_.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-WoLdcQzN.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-DkplpIGe.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-WoLdcQzN.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-CyavsyGA.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 +1 @@
1
- export { n as specEmitCommand, i as specValidateCommand } from "./spec-DGVNMSSB.js";
1
+ export { n as specEmitCommand, i as specValidateCommand } from "./spec-CZMiLhv_.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-CyavsyGA.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-DkplpIGe.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";