better-supabase 0.16.0 → 0.17.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 (269) hide show
  1. package/dist/{ai-schedules-BmkARmQ9.d.ts → ai-schedules-Dk9H3kAp.d.ts} +1 -1
  2. package/dist/ai-sdk/agents/index.d.ts +2 -2
  3. package/dist/{api-hHwieEfz.d.ts → api-CpL3hm87.d.ts} +1 -1
  4. package/dist/{app-tables-D29Rahtg.js → app-tables-Q0TYfeih.js} +1 -0
  5. package/dist/{app-tables-yMQ4ubyY.d.ts → app-tables-dS02piE7.d.ts} +1 -1
  6. package/dist/astro/index.d.ts +3 -3
  7. package/dist/{authorization-HZdJCaVm.d.ts → authorization-CNsvnwle.d.ts} +19 -3
  8. package/dist/better-result/index.d.ts +2 -2
  9. package/dist/{bind-JGCPGUJh.d.ts → bind-C801IaK-.d.ts} +4 -4
  10. package/dist/{block-env-y65GF_px.d.ts → block-env-BeG4DiiO.d.ts} +4 -4
  11. package/dist/blocks/access-requests/index.d.ts +1 -1
  12. package/dist/blocks/activities/index.d.ts +1 -1
  13. package/dist/blocks/agents/index.d.ts +1 -1
  14. package/dist/blocks/ai-cache/index.d.ts +1 -1
  15. package/dist/blocks/ai-chat/index.d.ts +4 -4
  16. package/dist/blocks/ai-files/index.d.ts +1 -1
  17. package/dist/blocks/ai-keys/index.d.ts +1 -1
  18. package/dist/blocks/ai-schedules/index.d.ts +2 -2
  19. package/dist/blocks/announcements/index.d.ts +4 -4
  20. package/dist/blocks/api-keys/index.d.ts +2 -2
  21. package/dist/blocks/approvals/index.d.ts +1 -1
  22. package/dist/blocks/assets/index.d.ts +1 -1
  23. package/dist/blocks/assignment/index.d.ts +1 -1
  24. package/dist/blocks/attachments/index.d.ts +2 -2
  25. package/dist/blocks/audit/index.d.ts +5 -5
  26. package/dist/blocks/automations/index.d.ts +3 -3
  27. package/dist/blocks/billable-time/index.d.ts +1 -1
  28. package/dist/blocks/billing/index.d.ts +3 -3
  29. package/dist/blocks/bookings/index.d.ts +2 -2
  30. package/dist/blocks/bulk/index.d.ts +1 -1
  31. package/dist/blocks/calendar/index.d.ts +2 -2
  32. package/dist/blocks/catalog/index.d.ts +1 -1
  33. package/dist/blocks/channels/index.d.ts +1 -1
  34. package/dist/blocks/collections/index.d.ts +1 -1
  35. package/dist/blocks/comments/index.d.ts +5 -5
  36. package/dist/blocks/compliance/index.d.ts +1 -1
  37. package/dist/blocks/connectors/index.d.ts +1 -1
  38. package/dist/blocks/contacts/index.d.ts +1 -1
  39. package/dist/blocks/content/index.d.ts +1 -1
  40. package/dist/blocks/contracts/index.d.ts +1 -1
  41. package/dist/blocks/courses/index.d.ts +1 -1
  42. package/dist/blocks/created-by/index.d.ts +4 -3
  43. package/dist/blocks/created-by/index.js +2 -2
  44. package/dist/blocks/custom-fields/index.d.ts +1 -1
  45. package/dist/blocks/data-lifecycle/index.d.ts +1 -1
  46. package/dist/blocks/deals/index.d.ts +1 -1
  47. package/dist/blocks/dispatch/index.d.ts +1 -1
  48. package/dist/blocks/documents/index.d.ts +1 -1
  49. package/dist/blocks/domains/index.d.ts +1 -1
  50. package/dist/blocks/donations/index.d.ts +1 -1
  51. package/dist/blocks/drive/index.d.ts +1 -1
  52. package/dist/blocks/employees/index.d.ts +2 -2
  53. package/dist/blocks/enrichment/index.d.ts +1 -1
  54. package/dist/blocks/enrollments/index.d.ts +1 -1
  55. package/dist/blocks/entitlements/index.d.ts +3 -3
  56. package/dist/blocks/expenses/index.d.ts +1 -1
  57. package/dist/blocks/field-history/index.d.ts +1 -1
  58. package/dist/blocks/flags/index.d.ts +1 -1
  59. package/dist/blocks/forecasts/index.d.ts +1 -1
  60. package/dist/blocks/forms/index.d.ts +2 -2
  61. package/dist/blocks/goals/index.d.ts +1 -1
  62. package/dist/blocks/guests/index.d.ts +1 -1
  63. package/dist/blocks/hiring/index.d.ts +1 -1
  64. package/dist/blocks/identities/index.d.ts +1 -1
  65. package/dist/blocks/imports/index.d.ts +1 -1
  66. package/dist/blocks/inbox/index.d.ts +5 -5
  67. package/dist/blocks/incidents/index.d.ts +1 -1
  68. package/dist/blocks/index.d.ts +2 -2
  69. package/dist/blocks/inventory/index.d.ts +1 -1
  70. package/dist/blocks/invoices/index.d.ts +1 -1
  71. package/dist/blocks/knowledge/index.d.ts +1 -1
  72. package/dist/blocks/lead-scoring/index.d.ts +1 -1
  73. package/dist/blocks/leases/index.d.ts +1 -1
  74. package/dist/blocks/leave/index.d.ts +1 -1
  75. package/dist/blocks/ledger/index.d.ts +1 -1
  76. package/dist/blocks/mail-sync/index.d.ts +1 -1
  77. package/dist/blocks/memberships/index.d.ts +1 -1
  78. package/dist/blocks/memory/index.d.ts +1 -1
  79. package/dist/blocks/messaging/index.d.ts +5 -5
  80. package/dist/blocks/metrics/index.d.ts +1 -1
  81. package/dist/blocks/mfa/index.d.ts +2 -2
  82. package/dist/blocks/moderation/index.d.ts +1 -1
  83. package/dist/blocks/notifications/index.d.ts +4 -4
  84. package/dist/blocks/numbering/index.d.ts +1 -1
  85. package/dist/blocks/oauth-server/index.d.ts +1 -1
  86. package/dist/blocks/onboarding/index.d.ts +2 -2
  87. package/dist/blocks/orders/index.d.ts +2 -2
  88. package/dist/blocks/organizations/index.d.ts +2 -2
  89. package/dist/blocks/outbox/index.d.ts +1 -1
  90. package/dist/blocks/passes/index.d.ts +1 -1
  91. package/dist/blocks/permissions/index.d.ts +3 -3
  92. package/dist/blocks/pipelines/index.d.ts +1 -1
  93. package/dist/blocks/posts/index.d.ts +1 -1
  94. package/dist/blocks/profiles/index.d.ts +1 -1
  95. package/dist/blocks/promotions/index.d.ts +1 -1
  96. package/dist/blocks/push/index.d.ts +2 -2
  97. package/dist/blocks/queue/index.d.ts +1 -1
  98. package/dist/blocks/quotes/index.d.ts +1 -1
  99. package/dist/blocks/rank/index.d.ts +1 -1
  100. package/dist/blocks/reactions/index.d.ts +4 -4
  101. package/dist/blocks/relations/index.d.ts +1 -1
  102. package/dist/blocks/reminders/index.d.ts +1 -1
  103. package/dist/blocks/reviews/index.d.ts +1 -1
  104. package/dist/blocks/saved-views/index.d.ts +3 -3
  105. package/dist/blocks/scores/index.d.ts +1 -1
  106. package/dist/blocks/search/index.d.ts +3 -3
  107. package/dist/blocks/security-events/index.d.ts +1 -1
  108. package/dist/blocks/segments/index.d.ts +1 -1
  109. package/dist/blocks/sequences/index.d.ts +1 -1
  110. package/dist/blocks/service-accounts/index.d.ts +1 -1
  111. package/dist/blocks/sessions/index.d.ts +2 -2
  112. package/dist/blocks/settings/index.d.ts +2 -2
  113. package/dist/blocks/share-links/index.d.ts +1 -1
  114. package/dist/blocks/shipments/index.d.ts +1 -1
  115. package/dist/blocks/signatures/index.d.ts +1 -1
  116. package/dist/blocks/signing-keys/index.d.ts +1 -1
  117. package/dist/blocks/sla/index.d.ts +1 -1
  118. package/dist/blocks/sso/index.d.ts +1 -1
  119. package/dist/blocks/state-machine/index.d.ts +1 -1
  120. package/dist/blocks/subjects/index.d.ts +2 -2
  121. package/dist/blocks/tags/index.d.ts +2 -2
  122. package/dist/blocks/tasks/index.d.ts +2 -2
  123. package/dist/blocks/teams/index.d.ts +1 -1
  124. package/dist/blocks/templates/index.d.ts +1 -1
  125. package/dist/blocks/time-tracking/index.d.ts +1 -1
  126. package/dist/blocks/timeline/index.d.ts +3 -3
  127. package/dist/blocks/trash/index.d.ts +1 -1
  128. package/dist/blocks/undo/index.d.ts +2 -2
  129. package/dist/blocks/updated-at/index.d.ts +7 -4
  130. package/dist/blocks/updated-at/index.js +2 -2
  131. package/dist/blocks/usage/index.d.ts +2 -2
  132. package/dist/blocks/vercel-marketplace/index.d.ts +1 -1
  133. package/dist/blocks/versions/index.d.ts +1 -1
  134. package/dist/blocks/waitlist/index.d.ts +1 -1
  135. package/dist/blocks/webhooks/index.d.ts +2 -2
  136. package/dist/blocks/workflow-editor/index.d.ts +4 -4
  137. package/dist/blocks/workflows/index.d.ts +4 -4
  138. package/dist/cli/{add-I8OW-qJH.js → add-BinNYhFD.js} +2 -2
  139. package/dist/cli/{add-D7TkPdco.js → add-DMcrsWjC.js} +13 -11
  140. package/dist/cli/add-z-3pXI6C.js +1 -0
  141. package/dist/cli/{backfill-DIz5DnlQ.js → backfill-DxBB62Zr.js} +3 -3
  142. package/dist/cli/bin.js +1 -1
  143. package/dist/cli/{blocks-xk-SE8gS.js → blocks-DSgTifw0.js} +1 -1
  144. package/dist/cli/{blocks-Bp5RPoft.js → blocks-rxOS-Mzz.js} +1 -1
  145. package/dist/cli/{cache-AznIssjI.js → cache-oU0yHKf0.js} +1 -1
  146. package/dist/cli/{codemod-Aewxza6i.js → codemod-Dsrv_3gQ.js} +1 -1
  147. package/dist/cli/{config-9t5ec_N7.js → config-2rwFHbwj.js} +3 -1
  148. package/dist/cli/{config-CBqkQjjN.js → config-C6XylzKz.js} +1 -1
  149. package/dist/cli/{content-mapper-DCrz6OIv.js → content-mapper-DLbXilBz.js} +2 -2
  150. package/dist/cli/{db-DrBI_HNv.js → db-Bwrr3GHM.js} +2 -2
  151. package/dist/cli/{doctor-DkOSLPEQ.js → doctor-CKt5Yyl4.js} +184 -142
  152. package/dist/cli/{gen-CFkYUnWq.js → gen-CeG6lbka.js} +13 -13
  153. package/dist/cli/index.d.ts +1 -1
  154. package/dist/cli/index.js +7 -7
  155. package/dist/cli/{init-CHj9ad4S.js → init-DrQlf9RL.js} +6 -6
  156. package/dist/cli/{live-DGdLR41j.js → live-BvWGM4c3.js} +2 -2
  157. package/dist/cli/{mcp-BZno503V.js → mcp-BrOnGB15.js} +2 -2
  158. package/dist/cli/{metadata-BfgHMe4q.js → metadata-BNSdPuKp.js} +3 -3
  159. package/dist/cli/{migration-safety-BnnXPAro.js → migration-safety-NtB3dsRU.js} +2 -2
  160. package/dist/cli/{module-migration-O_IxewFs.js → module-migration-mKhX88V_.js} +1 -1
  161. package/dist/cli/{print-DosQIFSy.js → print-Dh8iuPK3.js} +1 -1
  162. package/dist/cli/{remove-DK2G_KHm.js → remove-DfFXVBRr.js} +5 -5
  163. package/dist/cli/{render-5y5a1QZr.js → render-ChIwdIOJ.js} +10 -4
  164. package/dist/cli/{run-Bs4OKdDI.js → run-CLSHSVYo.js} +7 -7
  165. package/dist/cli/{run-MRET30vh.js → run-D48ZEU58.js} +24 -24
  166. package/dist/cli/{seed-Cz8PcXeT.js → seed-CG-pA-5N.js} +2 -2
  167. package/dist/cli/seed-CUxW5Dks.js +1 -0
  168. package/dist/cli/{shared-BLqbvY2x.js → shared-D0XBFSlz.js} +1 -1
  169. package/dist/cli/{snapshot-uTUlEzY2.js → snapshot-C6vh_n3t.js} +3 -3
  170. package/dist/cli/{source-D2gJHKwC.js → source-BZbEK5if.js} +1 -1
  171. package/dist/cli/{source-args-IpJRJO5t.js → source-args-MTLYpifA.js} +1 -1
  172. package/dist/cli/{spec-Cm2einTO.js → spec-B4LhpI6t.js} +2 -2
  173. package/dist/cli/{spec-DUjOtciN.js → spec-C-dhdKwa.js} +1 -1
  174. package/dist/cli/{sql-layout-lUWenjJw.js → sql-layout-26LSoifK.js} +2 -2
  175. package/dist/cli/{sync-CZMRB3aU.js → sync-CHGMZCJ5.js} +2 -2
  176. package/dist/cli/{upgrade-BFEIMC7U.js → upgrade-C0dVsqNX.js} +3 -3
  177. package/dist/cli/{upgrade-fVsJniXm.js → upgrade-GB9rqUGT.js} +2 -2
  178. package/dist/cli/{version-B2Dr6VmJ.js → version-T507a49w.js} +1 -1
  179. package/dist/client/index.d.ts +5 -5
  180. package/dist/client/native/index.d.ts +4 -4
  181. package/dist/{composite-CfYyU3vs.d.ts → composite-B7f1MMgr.d.ts} +3 -3
  182. package/dist/config/index.d.ts +3 -3
  183. package/dist/config/index.js +4 -4
  184. package/dist/{config-DWGgUQCh.js → config-BVNNJwGC.js} +7 -6
  185. package/dist/{config-CcehOvbz.js → config-CIBc79_8.js} +1 -1
  186. package/dist/{context-8kb8m5uO.d.ts → context-CKCgjEDF.d.ts} +9 -2
  187. package/dist/{controller-BW-5Opig.d.ts → controller-CJUXhshv.d.ts} +1 -1
  188. package/dist/{conversion-3iv2r7YC.d.ts → conversion-DgHdDlTK.d.ts} +1 -1
  189. package/dist/create/index.d.ts +2 -2
  190. package/dist/create/index.js +5 -5
  191. package/dist/{define-C5AcEkEJ.d.ts → define-Cgru0_kF.d.ts} +1 -1
  192. package/dist/{define-block-C1RHXz7L.d.ts → define-block-Xxw8Hroe.d.ts} +1 -1
  193. package/dist/edge/index.d.ts +5 -5
  194. package/dist/{entitlements-sO977DO-.d.ts → entitlements-B0jmjNLD.d.ts} +1 -1
  195. package/dist/{executor-BcNWcD-4.d.ts → executor-BWFfz0ik.d.ts} +2 -2
  196. package/dist/expo/index.d.ts +2 -2
  197. package/dist/{extension-B-lajjex.js → extension-DTaHjwdc.js} +3 -2
  198. package/dist/{extension-B0EjCYhO.js → extension-mGylYROs.js} +2 -10
  199. package/dist/{field-errors-Dt86dCKk.d.ts → field-errors-DqlebtTE.d.ts} +6 -6
  200. package/dist/{framework-BGdZVyPL.d.ts → framework-CF6zFU7a.d.ts} +3 -3
  201. package/dist/hono/index.d.ts +4 -4
  202. package/dist/{index-CcAmFNVi.d.ts → index-B8YjrfVl.d.ts} +2 -2
  203. package/dist/{index-CENWq3zb.d.ts → index-BCeTYhFk.d.ts} +1 -1
  204. package/dist/{index-Craf712U.d.ts → index-ClMN0f98.d.ts} +9 -9
  205. package/dist/{index-DZKCc2WM.d.ts → index-DUxXdQN_.d.ts} +3 -3
  206. package/dist/{index-Cc4mIQS8.d.ts → index-Dbb7BQdi.d.ts} +9 -4
  207. package/dist/{index-CTu-3fJB.d.ts → index-lB-8iPmY.d.ts} +3 -3
  208. package/dist/index.d.ts +1 -1
  209. package/dist/{instances-BHjCZoF8.js → instances-QOzIz9-q.js} +1 -1
  210. package/dist/list/index.d.ts +1 -1
  211. package/dist/{list-query-DYhgRTd5.d.ts → list-query-DxjuIHEL.d.ts} +1 -1
  212. package/dist/mapper/bin.js +6 -6
  213. package/dist/mcp/index.d.ts +4 -4
  214. package/dist/mcp/sdk/index.d.ts +2 -2
  215. package/dist/next/index.d.ts +14 -14
  216. package/dist/{operations-CSc_IsHO.d.ts → operations-Dc07aV_H.d.ts} +1 -1
  217. package/dist/{options-DChZoVfs.d.ts → options-B_NrjVDt.d.ts} +1 -0
  218. package/dist/{options-B2swWnJW.js → options-CCUaRLgd.js} +2 -1
  219. package/dist/{options-CM6-18FQ.d.ts → options-CDSCkYxu.d.ts} +1 -0
  220. package/dist/{options-C-dQHH5-.js → options-tSsUF0-7.js} +2 -1
  221. package/dist/orpc/index.d.ts +4 -4
  222. package/dist/otel/index.js +4 -4
  223. package/dist/{ports-mObLgH1z.d.ts → ports-DnpAuTvB.d.ts} +1 -1
  224. package/dist/powersync/index.d.ts +2 -2
  225. package/dist/preset/index.d.ts +3 -3
  226. package/dist/preset/index.js +3 -3
  227. package/dist/{preset-CsHnIBJF.js → preset-BIANzB5p.js} +2 -2
  228. package/dist/{push-token-BSSvsWXZ.d.ts → push-token-C_mFkYfq.d.ts} +1 -1
  229. package/dist/query/index.d.ts +1 -1
  230. package/dist/react/index.d.ts +5 -5
  231. package/dist/react/native/index.d.ts +1 -1
  232. package/dist/react/server.d.ts +6 -6
  233. package/dist/react-router/index.d.ts +3 -3
  234. package/dist/realtime/index.d.ts +3 -3
  235. package/dist/{record-form-D9ILuVtA.d.ts → record-form-xWvVcb86.d.ts} +1 -1
  236. package/dist/records/index.d.ts +7 -7
  237. package/dist/{resource-execute-Cpnob1Vj.d.ts → resource-execute-DqWfEc56.d.ts} +1 -1
  238. package/dist/{resource-types-pMeLs68X.d.ts → resource-types-BIoz_ElD.d.ts} +1 -1
  239. package/dist/{resources-7iq2-5_A.d.ts → resources-Bt2PDKE7.d.ts} +1 -1
  240. package/dist/server/index.d.ts +7 -7
  241. package/dist/{server-types-CK8mUIUT.d.ts → server-types-gR4Q1aM0.d.ts} +1 -1
  242. package/dist/{session-DWmFv3vB.d.ts → session-C1OuXbtN.d.ts} +1 -1
  243. package/dist/solid/index.d.ts +6 -6
  244. package/dist/solid-start/index.d.ts +3 -3
  245. package/dist/spec/index.d.ts +1 -1
  246. package/dist/sql/index.d.ts +5 -5
  247. package/dist/sql/index.js +3 -3
  248. package/dist/{sql-Dl3Alk43.js → sql-ClTmzHs8.js} +72 -31
  249. package/dist/sqlite/index.d.ts +1 -1
  250. package/dist/ssr/index.d.ts +1 -1
  251. package/dist/svelte/index.d.ts +6 -6
  252. package/dist/sveltekit/index.d.ts +4 -4
  253. package/dist/{tags-qvVk79pp.d.ts → tags-sM-CH9Mn.d.ts} +1 -1
  254. package/dist/tanstack-db/index.d.ts +1 -1
  255. package/dist/tanstack-start/index.d.ts +3 -3
  256. package/dist/{tenant-DOKIJI62.d.ts → tenant-DVvjw9H-.d.ts} +1 -1
  257. package/dist/testing/index.d.ts +7 -7
  258. package/dist/testing/index.js +3 -3
  259. package/dist/{timeline-CvTuXYvn.d.ts → timeline-BBfKuMVL.d.ts} +3 -3
  260. package/dist/{topic-CZXHhZye.d.ts → topic-BtLz-qTI.d.ts} +2 -2
  261. package/dist/{verify-CjvNLY7N.d.ts → verify-DEqY__0N.d.ts} +1 -1
  262. package/dist/vue/index.d.ts +6 -6
  263. package/dist/{watch-topic-BAxoPKZx.d.ts → watch-topic-tnfOTa3-.d.ts} +1 -1
  264. package/dist/yjs/index.d.ts +1 -1
  265. package/package.json +1 -1
  266. package/schemas/config-v1.json +22 -0
  267. package/schemas/doctor-report-v1.json +1 -0
  268. package/dist/cli/add-Bfb_ISrO.js +0 -1
  269. package/dist/cli/seed-D6XijwbR.js +0 -1
@@ -1,11 +1,11 @@
1
1
  import { b as DbError } from "../../result-DZeA5KS6.js";
2
2
  import { Ct as Events, _t as WorkflowRunEventData } from "../../events-vcqenSYU.js";
3
3
  import { a as dbTransport, o as rpcTransport, s as sqlTransport, t as BlockTransport } from "../../block-transport-DWZSJrwN.js";
4
- import { c as BlockOf } from "../../define-block-C1RHXz7L.js";
4
+ import { c as BlockOf } from "../../define-block-Xxw8Hroe.js";
5
5
  import { _ as WorkflowsHooks, a as WorkflowRunStatus, c as WorkflowScheduleInput, d as WorkflowStartTicket, f as WorkflowStarter, g as Workflows, h as WorkflowTickResult, i as WorkflowRunRecord, l as WorkflowStartCall, m as WorkflowTickOptions, n as WorkflowRun, o as WorkflowRunsQuery, s as WorkflowSchedule, u as WorkflowStartRequest, v as WorkflowsOptions, y as createWorkflows } from "../../workflows-B0ZPAQu0.js";
6
- import { p as SubscriptionStatus } from "../../topic-CZXHhZye.js";
7
- import { n as TopicPort } from "../../watch-topic-BAxoPKZx.js";
8
- import { n as Controller, t as AuthPort } from "../../controller-BW-5Opig.js";
6
+ import { p as SubscriptionStatus } from "../../topic-BtLz-qTI.js";
7
+ import { n as TopicPort } from "../../watch-topic-tnfOTa3-.js";
8
+ import { n as Controller, t as AuthPort } from "../../controller-CJUXhshv.js";
9
9
  //#region src/blocks/workflows/client.d.ts
10
10
  interface WorkflowRunsControllerOptions {
11
11
  readonly client: {
@@ -1,8 +1,8 @@
1
1
  import { n as CliError } from "./errors-BTe6A15O.js";
2
- import { T as providerLabel, _ as layoutFor, h as MEMBERSHIP_CLAIM_MODULES, v as providerOwnsMemberships } from "./module-migration-O_IxewFs.js";
2
+ import { T as providerLabel, _ as layoutFor, h as MEMBERSHIP_CLAIM_MODULES, v as providerOwnsMemberships } from "./module-migration-mKhX88V_.js";
3
3
  import { r as applyPlan } from "./files-CX71yBm8.js";
4
4
  import { n as addBlocksToJson, s as keyText, t as addBlocksToConfig } from "./config-edit-CrWfk8s3.js";
5
- import { a as write, i as unlistedModuleFiles, r as nextStep } from "./sync-CZMRB3aU.js";
5
+ import { a as write, i as unlistedModuleFiles, r as nextStep } from "./sync-CHGMZCJ5.js";
6
6
  import { basename, dirname } from "node:path";
7
7
  import { readFile } from "node:fs/promises";
8
8
  import { SQL_MODULES, resolveBlocks } from "better-supabase/sql";
@@ -1,22 +1,22 @@
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-B2Dr6VmJ.js";
3
+ import { t as VERSION } from "./version-T507a49w.js";
4
4
  import { a as parseNames, n as CliError } from "./errors-BTe6A15O.js";
5
5
  import { r as readIfExists, t as display } from "./io-DH1kcmmP.js";
6
- import { t as loadSnapshot } from "./snapshot-uTUlEzY2.js";
6
+ import { t as loadSnapshot } from "./snapshot-C6vh_n3t.js";
7
7
  import { t as isRecord } from "./guards-CUlDNYZs.js";
8
- import { a as toCatalog } from "./source-D2gJHKwC.js";
9
- import { f as dataMigration } from "./module-migration-O_IxewFs.js";
10
- import { a as findConfig, f as INTEGRATIONS, s as loadConfig } from "./config-9t5ec_N7.js";
8
+ import { a as toCatalog } from "./source-BZbEK5if.js";
9
+ import { f as dataMigration } from "./module-migration-mKhX88V_.js";
10
+ import { a as findConfig, f as INTEGRATIONS, s as loadConfig } from "./config-2rwFHbwj.js";
11
11
  import { i as changeLines, n as PLAN_ARGS, r as applyPlan, u as planResult } from "./files-CX71yBm8.js";
12
- import { a as wiringFiles, d as libEntry, f as needsLib, i as wiringChecklist, l as importFrom, n as latestMigrationVersion, o as wiringFor, p as resolveIntegrations, s as TEMPLATES, u as isIntegration } from "./migration-safety-BnnXPAro.js";
12
+ import { a as wiringFiles, d as libEntry, f as needsLib, i as wiringChecklist, l as importFrom, n as latestMigrationVersion, o as wiringFor, p as resolveIntegrations, s as TEMPLATES, u as isIntegration } from "./migration-safety-NtB3dsRU.js";
13
13
  import { n as installCommand, t as detectProject } from "./detect-D9JaAX20.js";
14
14
  import { d as setBlockInJson, f as setPathInConfig, h as setPresetInJson, m as setPresetInConfig, n as addBlocksToJson, p as setPathInJson, r as addBlocksToWiring, t as addBlocksToConfig, u as setBlockInConfig } from "./config-edit-CrWfk8s3.js";
15
- import { t as syncModules } from "./sync-CZMRB3aU.js";
16
- import { t as addModules } from "./add-I8OW-qJH.js";
17
- import { n as ident } from "./live-DGdLR41j.js";
18
- import { t as blockNames } from "./blocks-xk-SE8gS.js";
19
- import { i as sourceArgs, n as SOURCE_ARGS } from "./source-args-IpJRJO5t.js";
15
+ import { t as syncModules } from "./sync-CHGMZCJ5.js";
16
+ import { t as addModules } from "./add-BinNYhFD.js";
17
+ import { n as ident } from "./live-BvWGM4c3.js";
18
+ import { t as blockNames } from "./blocks-DSgTifw0.js";
19
+ import { i as sourceArgs, n as SOURCE_ARGS } from "./source-args-MTLYpifA.js";
20
20
  import { existsSync } from "node:fs";
21
21
  import { dirname, join, posix, resolve } from "node:path";
22
22
  import { readFile } from "node:fs/promises";
@@ -405,6 +405,8 @@ function proposeAdoption(block, tables, options = {}) {
405
405
  if (Object.keys(mapped).length > 0) entryColumns[logical] = mapped;
406
406
  }
407
407
  const current = options.blocks?.[block];
408
+ const governed = current?.ownTablePolicies === void 0 ? [...chosen.values()].filter((table) => table !== null && (table.policies ?? []).some((policy) => policy.permissive && !policy.name.startsWith("bsb_"))).map((table) => `${table.schema}.${table.name}`) : [];
409
+ if (governed.length > 0) warnings.push(`${governed.join(", ")} already ${governed.length === 1 ? "has" : "have"} permissive policies of your own. To keep the block's bsb_ policies off ${governed.length === 1 ? "it" : "them"}, set blocks.${block}.ownTablePolicies: "app"; otherwise the block adds a policy for each command yours don't cover, and doctor (BS347) reports one that is wider than yours.`);
408
410
  const entry = {
409
411
  ...current,
410
412
  tables: entryTables,
@@ -0,0 +1 @@
1
+ export { t as addCommand } from "./add-DMcrsWjC.js";
@@ -1,10 +1,10 @@
1
1
  import { p as commandMeta, r as defineCliCommand } from "./command-CQ61x6gN.js";
2
2
  import { n as CliError, r as errorText } from "./errors-BTe6A15O.js";
3
3
  import { i as isLocalDatabaseUrl, r as databaseHost } from "./agent-CbuPvI2x.js";
4
- import { l as stdinDatabaseUrl, n as databaseUrl } from "./config-9t5ec_N7.js";
4
+ import { l as stdinDatabaseUrl, n as databaseUrl } from "./config-2rwFHbwj.js";
5
5
  import { t as connect } from "./db-CQCLx7cx.js";
6
- import { n as ident } from "./live-DGdLR41j.js";
7
- import { r as STACK_ARG, t as DB_URL_STDIN_ARG } from "./source-args-IpJRJO5t.js";
6
+ import { n as ident } from "./live-BvWGM4c3.js";
7
+ import { r as STACK_ARG, t as DB_URL_STDIN_ARG } from "./source-args-MTLYpifA.js";
8
8
  //#region src/cli/commands/backfill.ts
9
9
  const DEFAULT_BATCH = 1e3;
10
10
  const ARGS = {
package/dist/cli/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { i as run } from "./run-MRET30vh.js";
2
+ import { i as run } from "./run-D48ZEU58.js";
3
3
  import { t as colorEnabled } from "./style-Bm2X5JrN.js";
4
4
  import { existsSync } from "node:fs";
5
5
  import { basename } from "node:path";
@@ -1,7 +1,7 @@
1
1
  import { p as commandMeta, r as defineCliCommand } from "./command-CQ61x6gN.js";
2
2
  import { n as CliError } from "./errors-BTe6A15O.js";
3
3
  import { t as SQL_ARGS } from "./args-UEwg0l-N.js";
4
- import { n as listModules, t as printModule } from "./print-DosQIFSy.js";
4
+ import { n as listModules, t as printModule } from "./print-Dh8iuPK3.js";
5
5
  import { t as decodePresetInput } from "./preset-BwmIfFnh.js";
6
6
  import { BLOCK_CATEGORIES } from "better-supabase/blocks";
7
7
  import { PRESET_CATALOG, PRESET_NAMES, glueCommand } from "better-supabase/preset";
@@ -1 +1 @@
1
- export { n as blocksListCommand, r as blocksSearchCommand, i as blocksViewCommand } from "./blocks-xk-SE8gS.js";
1
+ export { n as blocksListCommand, r as blocksSearchCommand, i as blocksViewCommand } from "./blocks-DSgTifw0.js";
@@ -1,4 +1,4 @@
1
- import { t as VERSION } from "./version-B2Dr6VmJ.js";
1
+ import { t as VERSION } from "./version-T507a49w.js";
2
2
  import { dirname, resolve } from "node:path";
3
3
  import { createHash } from "node:crypto";
4
4
  import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
@@ -4,7 +4,7 @@ import { n as CliError } from "./errors-BTe6A15O.js";
4
4
  import { t as migrateCliCall } from "./moved-CsfDQcyk.js";
5
5
  import { t as isRecord$1 } from "./guards-CUlDNYZs.js";
6
6
  import { a as changedFiles, i as changeLines, r as applyPlan, u as planResult } from "./files-CX71yBm8.js";
7
- import { i as schemasDirOf, n as migrationsDir, o as writtenByBlocks } from "./sql-layout-lUWenjJw.js";
7
+ import { i as schemasDirOf, n as migrationsDir, o as writtenByBlocks } from "./sql-layout-26LSoifK.js";
8
8
  import { a as configObject, c as mask, f as setPathInConfig, g as skipSpace, h as setPresetInJson, i as closingIndex, l as properties, m as setPresetInConfig, o as indentAt, p as setPathInJson, t as addBlocksToConfig, v as codeRanges } from "./config-edit-CrWfk8s3.js";
9
9
  import { i as legacyPrefixNames, n as LEGACY_PREFIXES, t as LEGACY_CLAIMS } from "./legacy-prefix-DkTA3Rhx.js";
10
10
  import { a as REVIEW_0_15, c as renameSubpaths, r as PLUGIN_IMPORT_RENAMES, s as SUBPATH_RENAMES_0_15, t as BLOCK_EXPORT_RENAMES } from "./codemod-block-renames-BuSaTE_G.js";
@@ -778,6 +778,7 @@ const blockEntries = {
778
778
  "user",
779
779
  "none"
780
780
  ])),
781
+ ownTablePolicies: optional(picklist(["block", "app"])),
781
782
  functions: optional(stringRecord),
782
783
  permissions: optional(stringRecord),
783
784
  names: optional(union([entityName, record(string(), union([entityName, strictObject({
@@ -1261,7 +1262,8 @@ const FLAT = {
1261
1262
  "tenant",
1262
1263
  "user",
1263
1264
  "none"
1264
- ]))
1265
+ ])),
1266
+ ownTablePolicies: optional(picklist(["block", "app"]))
1265
1267
  })),
1266
1268
  seed: optional(strictObject({
1267
1269
  entry: optional(string()),
@@ -1 +1 @@
1
- export { t as applyEnvironment, n as databaseUrl, r as defaultConfig, i as discoverConfig, a as findConfig, o as importExport, s as loadConfig, c as readSupabasePort, l as stdinDatabaseUrl } from "./config-9t5ec_N7.js";
1
+ export { t as applyEnvironment, n as databaseUrl, r as defaultConfig, i as discoverConfig, a as findConfig, o as importExport, s as loadConfig, c as readSupabasePort, l as stdinDatabaseUrl } from "./config-2rwFHbwj.js";
@@ -1,6 +1,6 @@
1
1
  import { r as readIfExists } from "./io-DH1kcmmP.js";
2
- import { t as CACHE_DIR } from "./cache-AznIssjI.js";
3
- import { x as installedVersion } from "./snapshot-uTUlEzY2.js";
2
+ import { t as CACHE_DIR } from "./cache-oU0yHKf0.js";
3
+ import { x as installedVersion } from "./snapshot-C6vh_n3t.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";
@@ -2,11 +2,11 @@ import { p as commandMeta, r as defineCliCommand } from "./command-CQ61x6gN.js";
2
2
  import { n as CliError, r as errorText } from "./errors-BTe6A15O.js";
3
3
  import { i as isLocalDatabaseUrl, r as databaseHost } from "./agent-CbuPvI2x.js";
4
4
  import { t as display } from "./io-DH1kcmmP.js";
5
- import { l as stdinDatabaseUrl, n as databaseUrl } from "./config-9t5ec_N7.js";
5
+ import { l as stdinDatabaseUrl, n as databaseUrl } from "./config-2rwFHbwj.js";
6
6
  import { d as readSupabaseToml, f as schemaPaths, n as declarativeSchemasDir, p as sqlWorkflow } from "./supabase-toml-CncmQbO0.js";
7
7
  import { r as supabaseCli } from "./exec--Q1ZEWUW.js";
8
8
  import { t as connect } from "./db-CQCLx7cx.js";
9
- import { r as STACK_ARG, t as DB_URL_STDIN_ARG } from "./source-args-IpJRJO5t.js";
9
+ import { r as STACK_ARG, t as DB_URL_STDIN_ARG } from "./source-args-MTLYpifA.js";
10
10
  import { a as migrationFiles, i as isShadowFailure, o as migrationVersion, r as inStackDiff, t as MIGRATION_HEADER } from "./in-stack-diff-DQTW53Vf.js";
11
11
  import { dirname, join, resolve } from "node:path";
12
12
  import { mkdir, readFile, writeFile } from "node:fs/promises";
@@ -1,41 +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-B2Dr6VmJ.js";
3
+ import { t as VERSION } from "./version-T507a49w.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-AznIssjI.js";
7
+ import { t as CACHE_DIR } from "./cache-oU0yHKf0.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-uTUlEzY2.js";
10
- import { d as configFor, r as renderFiles, u as notNullTag } from "./render-5y5a1QZr.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-C6vh_n3t.js";
10
+ import { d as configFor, r as renderFiles, u as notNullTag } from "./render-ChIwdIOJ.js";
11
11
  import { t as isRecord } from "./guards-CUlDNYZs.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
- import { l as stdinDatabaseUrl, n as databaseUrl } from "./config-9t5ec_N7.js";
12
+ import { i as request } from "./source-BZbEK5if.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-mKhX88V_.js";
14
+ import { l as stdinDatabaseUrl, n as databaseUrl } from "./config-2rwFHbwj.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-DCrz6OIv.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-DLbXilBz.js";
20
20
  import { c as insideRoot, i as changeLines, r as applyPlan } from "./files-CX71yBm8.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";
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-CLSHSVYo.js";
22
+ import { n as migrationsDir, r as moduleLayoutFor, t as blockDeclaredTables } from "./sql-layout-26LSoifK.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-D0XBFSlz.js";
24
+ import { o as wiringFor, r as configInstances, t as MIGRATION_SAFETY_RULES } from "./migration-safety-NtB3dsRU.js";
25
25
  import { t as orphanedBlockFiles } from "./orphans-BAboqyVM.js";
26
- import { i as reservedRoles, n as ident$1, r as literal$1, t as LIVE_RULES } from "./live-DGdLR41j.js";
27
- import { a as sourceFlags, n as SOURCE_ARGS } from "./source-args-IpJRJO5t.js";
26
+ import { i as reservedRoles, n as ident$1, r as literal$1, t as LIVE_RULES } from "./live-BvWGM4c3.js";
27
+ import { a as sourceFlags, n as SOURCE_ARGS } from "./source-args-MTLYpifA.js";
28
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";
29
29
  import { n as PLATFORM_SCHEMAS } from "./in-stack-diff-DQTW53Vf.js";
30
30
  import { i as staleVariables, r as stackEnvValues, t as PREFIX_NAMES } from "./stack-env-6hS-WEmh.js";
31
31
  import { a as readSharedMemory, n as listStacks, t as branchName } from "./stacks-BYlQ96WS.js";
32
- import { i as refuseWithMetadata, r as readMetadataSnapshot } from "./metadata-BfgHMe4q.js";
32
+ import { i as refuseWithMetadata, r as readMetadataSnapshot } from "./metadata-BNSdPuKp.js";
33
33
  import { existsSync } from "node:fs";
34
34
  import { dirname, resolve } from "node:path";
35
35
  import { createHash } from "node:crypto";
36
36
  import { glob, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
37
37
  import { DEFAULT_ACTIVE_TENANT, tenantClaimPaths } from "better-supabase/config";
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
+ import { SECRET_COLUMNS, SQL_MODULES, TENANT_SCOPE_POLICY, adoptedTables, adoptedViews, appTablePolicyNotes, 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";
39
39
  import { defineBucket, parseSize } from "better-supabase/storage";
40
40
  //#region src/cli/doctor/env.ts
41
41
  const PUBLIC_PREFIXES = [
@@ -141,6 +141,166 @@ const ENV_RULES = [
141
141
  }
142
142
  ];
143
143
  //#endregion
144
+ //#region src/cli/doctor/module-files.ts
145
+ /** The `blocks` files as this release renders them, next to what is on disk. */
146
+ async function moduleFiles(context) {
147
+ if (context.config.blockNames.length === 0 && Object.keys(context.config.appTables).length === 0) return [];
148
+ const access = accessModule(context);
149
+ if (access.kind === "invalid") return [];
150
+ const readSets = context.readSets;
151
+ const skipped = readSets !== void 0 && "skipped" in readSets;
152
+ let rendered;
153
+ try {
154
+ rendered = renderBlocks(context.config.blockNames, await moduleLayoutFor(context.config, {
155
+ names: context.config.blockNames,
156
+ testsDir: context.config.sql.testsDir,
157
+ readSets: skipped ? [] : readSets,
158
+ entitlementsProvider: entitlementsModule(context),
159
+ accessProvider: access.kind === "provider" ? access.access : void 0,
160
+ permissionCatalog: permissionCatalogKeys(context)
161
+ }));
162
+ } catch {
163
+ return [];
164
+ }
165
+ const files = rendered.filter((file) => !(skipped && file.module === "read-sets"));
166
+ if (workflowOf(context) === "migrations") {
167
+ const latest = await latestMigration(context.config, MODULES_SUFFIX);
168
+ const versions = migrationModules(latest?.text ?? "");
169
+ const path = latest?.path ?? `${migrationsDir(context.config)}/<stamp>_better_supabase_modules.sql`;
170
+ return Promise.all(files.map(async (file) => {
171
+ if (file.kind === "test") return fileState(context, file);
172
+ const installed = versions.get(file.instance ?? file.module);
173
+ return {
174
+ file,
175
+ path,
176
+ installed,
177
+ current: latest === void 0 ? void 0 : migrationHolds(latest.text, file.contents) ? file.contents : latest.text,
178
+ behind: file.kind === "schema" && installed !== void 0 && installed < (moduleFileVersion(file.contents)?.version ?? 1)
179
+ };
180
+ }));
181
+ }
182
+ return Promise.all(files.map((file) => fileState(context, file)));
183
+ }
184
+ async function fileState(context, file) {
185
+ const current = await readFile(resolve(context.config.root, file.path), "utf-8").catch(() => void 0);
186
+ const installed = current === void 0 ? void 0 : moduleFileVersion(current)?.version ?? 1;
187
+ return {
188
+ file,
189
+ path: file.path,
190
+ current,
191
+ installed,
192
+ behind: installed !== void 0 && installed < (moduleFileVersion(file.contents)?.version ?? 1)
193
+ };
194
+ }
195
+ //#endregion
196
+ //#region src/cli/doctor/app-table-policies.ts
197
+ /**
198
+ * Block policies (`bsb_*`, permissive) on the app's tables that grant a command
199
+ * more than the app's own permissive policies do. Postgres ORs permissive
200
+ * policies, so a block policy whose condition no app policy repeats can open
201
+ * rows the app's policies keep closed. A command the app has no policy for is
202
+ * the block's to grant.
203
+ */
204
+ function widenedAppTablePolicies(context) {
205
+ const tables = adoptedTables(context.config.blocks, appTablesOf(context));
206
+ if (tables.length === 0) return [];
207
+ const modules = /* @__PURE__ */ new Map();
208
+ for (const table of tables) {
209
+ if (context.config.blocks[table.module]?.ownTablePolicies === "app") continue;
210
+ const target = `${table.schema}.${table.table}`;
211
+ modules.set(target, (modules.get(target) ?? /* @__PURE__ */ new Set()).add(table.module));
212
+ }
213
+ return catalogOf(context).tables.flatMap((table) => {
214
+ const target = qualified(table);
215
+ const owners = modules.get(target);
216
+ if (owners === void 0) return [];
217
+ const permissive = table.policies.filter((policy) => policy.permissive);
218
+ const own = permissive.filter((policy) => !policy.name.startsWith(BLOCK_PREFIX));
219
+ const blocks = [...owners].map((module) => `blocks.${module}`).join(" or ");
220
+ return permissive.filter((policy) => policy.name.startsWith(BLOCK_PREFIX)).flatMap((policy) => {
221
+ const widened = widenedCommands(policy, own);
222
+ if (widened.length === 0) return [];
223
+ const reason = `no policy of the app's for ${widened.join(", ")} reaches its roles with a condition it repeats (alone or with more "and" operands), so it can open rows the app's policies keep closed`;
224
+ return [{
225
+ message: `${blocks} adds policy ${policy.name} on ${target}, and ${reason}. Postgres ORs permissive policies; doctor compares conditions as text and can't prove that one implies another. If the block's condition is what the app means, repeat it in the app's policy; otherwise narrow the permission key it checks, drop ${policy.name} in a schema file that runs after the block's, or set ownTablePolicies: "app" on the block (or in database.sql) so the app's policies alone govern the table.`,
226
+ target: `${target}.${policy.name}`,
227
+ object: {
228
+ kind: "policy",
229
+ schema: table.schema,
230
+ table: table.name,
231
+ name: policy.name
232
+ }
233
+ }];
234
+ });
235
+ });
236
+ }
237
+ async function appTablesWithoutPolicies(context) {
238
+ const states = await moduleFiles(context);
239
+ const left = /* @__PURE__ */ new Map();
240
+ for (const { file } of states) {
241
+ if (file.kind !== "schema") continue;
242
+ for (const note of appTablePolicyNotes(file.contents)) {
243
+ const entry = left.get(note.table) ?? {
244
+ blocks: /* @__PURE__ */ new Set(),
245
+ commands: /* @__PURE__ */ new Set()
246
+ };
247
+ entry.blocks.add(`blocks.${file.instance ?? file.module}`);
248
+ for (const command of note.commands) entry.commands.add(command);
249
+ left.set(note.table, entry);
250
+ }
251
+ }
252
+ if (left.size === 0) return [];
253
+ return catalogOf(context).tables.flatMap((table) => {
254
+ const target = qualified(table);
255
+ const entry = left.get(target);
256
+ if (entry === void 0) return [];
257
+ const missing = [...entry.commands].filter((command) => !table.policies.some((policy) => policy.permissive && (policy.command === "all" || policy.command === command)));
258
+ if (missing.length === 0) return [];
259
+ return [{
260
+ message: `${[...entry.blocks].join(" and ")} leaves the policies on ${target} to the app's (ownTablePolicies "app"), and ${target} ${table.rls ? "has row level security on" : "has row level security off, which the block's file turns on,"} but no permissive policy for ${missing.join(", ")}, which the block's own policies would have granted. Postgres then denies those commands to every caller, so the block's functions that run as the caller and its TypeScript API find no rows for them. Add the app's policy for each command the app uses, or set ownTablePolicies to "block" for this block.`,
261
+ target,
262
+ object: {
263
+ kind: "table",
264
+ schema: table.schema,
265
+ name: table.name
266
+ },
267
+ ...missing.includes("select") ? {} : { severity: "info" }
268
+ }];
269
+ });
270
+ }
271
+ const KEPT_TRIGGER = /^-- (\S+) keeps updated_at current with its own trigger (\S+)\.$/gm;
272
+ /**
273
+ * App tables whose own trigger keeps `updated_at` current, so the block skipped
274
+ * its `bsb_updated_at` trigger there.
275
+ */
276
+ async function keptUpdatedAtTriggers(context) {
277
+ return (await moduleFiles(context)).flatMap(({ file }) => file.kind === "schema" ? [...file.contents.matchAll(KEPT_TRIGGER)].map(([, target = "", trigger = ""]) => {
278
+ const dot = target.indexOf(".");
279
+ return {
280
+ message: `blocks.${file.instance ?? file.module} runs over ${target}, which keeps updated_at current with its own trigger ${trigger}, so the block adds no bsb_updated_at trigger there. Keep ${trigger} firing on update; if you drop it, run \`better-supabase upgrade\` to add the block's.`,
281
+ target,
282
+ object: {
283
+ kind: "table",
284
+ schema: target.slice(0, dot),
285
+ name: target.slice(dot + 1)
286
+ }
287
+ };
288
+ }) : []);
289
+ }
290
+ /**
291
+ * Whether a deprecated table or column name belongs to the app: the app's
292
+ * tables keep the app's names, as custom blocks' tables do.
293
+ */
294
+ function keepsAppsName(context) {
295
+ const adopted = context.config.blockNames.some((name) => moduleDeprecations().some((entry) => entry.module === name && (entry.kind === "table" || entry.kind === "column"))) ? adoptedTables(context.config.blocks, appTablesOf(context)) : [];
296
+ return (entry) => {
297
+ if (entry.kind !== "table" && entry.kind !== "column") return false;
298
+ if ((context.config.blocks[entry.module]?.mode ?? "managed") !== "managed") return true;
299
+ const name = entry.kind === "table" ? entry.symbol.slice(entry.symbol.lastIndexOf(".") + 1) : entry.symbol.slice(0, entry.symbol.indexOf("."));
300
+ return adopted.some((table) => table.module === entry.module && (name === table.logical || name === table.table || name === SQL_MODULES[table.module]?.names?.tables[table.logical]?.name));
301
+ };
302
+ }
303
+ //#endregion
144
304
  //#region src/cli/doctor/adoption.ts
145
305
  const tagText = (notNull) => notNull === true ? "@notNull" : `@notNull(${notNull.join(", ")})`;
146
306
  const sameNotNull = (a, b) => a === true || b === true ? a === b : a !== void 0 && a.length === b.length && a.every((name) => b.includes(name));
@@ -273,6 +433,13 @@ const ADOPTION_RULES = [
273
433
  }));
274
434
  }
275
435
  },
436
+ {
437
+ code: "BS350",
438
+ severity: "warning",
439
+ title: "App table governs its policies but lacks one for a command",
440
+ description: "A block runs over a table of the app's with `ownTablePolicies: \"app\"`, so it adds none of its `bsb_` policies there, and the table has no permissive policy for a command one of those policies would have granted. With row level security on, or off (the block's file turns it on), Postgres denies that command to every caller, so the block's functions that run as the caller and its TypeScript API find no rows for it. A missing `select` policy is a warning, a missing write policy is info. Add the app's own policy for each command the app uses, or set `ownTablePolicies` back to `block` for the block.",
441
+ check: appTablesWithoutPolicies
442
+ },
276
443
  {
277
444
  code: "BS341",
278
445
  severity: "warning",
@@ -1209,131 +1376,6 @@ function skippedForMetadata(snapshot, rule, help) {
1209
1376
  };
1210
1377
  }
1211
1378
  //#endregion
1212
- //#region src/cli/doctor/module-files.ts
1213
- /** The `blocks` files as this release renders them, next to what is on disk. */
1214
- async function moduleFiles(context) {
1215
- if (context.config.blockNames.length === 0 && Object.keys(context.config.appTables).length === 0) return [];
1216
- const access = accessModule(context);
1217
- if (access.kind === "invalid") return [];
1218
- const readSets = context.readSets;
1219
- const skipped = readSets !== void 0 && "skipped" in readSets;
1220
- let rendered;
1221
- try {
1222
- rendered = renderBlocks(context.config.blockNames, await moduleLayoutFor(context.config, {
1223
- names: context.config.blockNames,
1224
- testsDir: context.config.sql.testsDir,
1225
- readSets: skipped ? [] : readSets,
1226
- entitlementsProvider: entitlementsModule(context),
1227
- accessProvider: access.kind === "provider" ? access.access : void 0,
1228
- permissionCatalog: permissionCatalogKeys(context)
1229
- }));
1230
- } catch {
1231
- return [];
1232
- }
1233
- const files = rendered.filter((file) => !(skipped && file.module === "read-sets"));
1234
- if (workflowOf(context) === "migrations") {
1235
- const latest = await latestMigration(context.config, MODULES_SUFFIX);
1236
- const versions = migrationModules(latest?.text ?? "");
1237
- const path = latest?.path ?? `${migrationsDir(context.config)}/<stamp>_better_supabase_modules.sql`;
1238
- return Promise.all(files.map(async (file) => {
1239
- if (file.kind === "test") return fileState(context, file);
1240
- const installed = versions.get(file.instance ?? file.module);
1241
- return {
1242
- file,
1243
- path,
1244
- installed,
1245
- current: latest === void 0 ? void 0 : migrationHolds(latest.text, file.contents) ? file.contents : latest.text,
1246
- behind: file.kind === "schema" && installed !== void 0 && installed < (moduleFileVersion(file.contents)?.version ?? 1)
1247
- };
1248
- }));
1249
- }
1250
- return Promise.all(files.map((file) => fileState(context, file)));
1251
- }
1252
- async function fileState(context, file) {
1253
- const current = await readFile(resolve(context.config.root, file.path), "utf-8").catch(() => void 0);
1254
- const installed = current === void 0 ? void 0 : moduleFileVersion(current)?.version ?? 1;
1255
- return {
1256
- file,
1257
- path: file.path,
1258
- current,
1259
- installed,
1260
- behind: installed !== void 0 && installed < (moduleFileVersion(file.contents)?.version ?? 1)
1261
- };
1262
- }
1263
- //#endregion
1264
- //#region src/cli/doctor/app-table-policies.ts
1265
- /**
1266
- * Block policies (`bsb_*`, permissive) on the app's tables that grant a command
1267
- * more than the app's own permissive policies do. Postgres ORs permissive
1268
- * policies, so a block policy whose condition no app policy repeats can open
1269
- * rows the app's policies keep closed. A command the app has no policy for is
1270
- * the block's to grant.
1271
- */
1272
- function widenedAppTablePolicies(context) {
1273
- const tables = adoptedTables(context.config.blocks, appTablesOf(context));
1274
- if (tables.length === 0) return [];
1275
- const modules = /* @__PURE__ */ new Map();
1276
- for (const table of tables) {
1277
- const target = `${table.schema}.${table.table}`;
1278
- modules.set(target, (modules.get(target) ?? /* @__PURE__ */ new Set()).add(table.module));
1279
- }
1280
- return catalogOf(context).tables.flatMap((table) => {
1281
- const target = qualified(table);
1282
- const owners = modules.get(target);
1283
- if (owners === void 0) return [];
1284
- const permissive = table.policies.filter((policy) => policy.permissive);
1285
- const own = permissive.filter((policy) => !policy.name.startsWith(BLOCK_PREFIX));
1286
- const blocks = [...owners].map((module) => `blocks.${module}`).join(" or ");
1287
- return permissive.filter((policy) => policy.name.startsWith(BLOCK_PREFIX)).flatMap((policy) => {
1288
- const widened = widenedCommands(policy, own);
1289
- if (widened.length === 0) return [];
1290
- const reason = `no policy of the app's for ${widened.join(", ")} reaches its roles with a condition it repeats (alone or with more "and" operands), so it can open rows the app's policies keep closed`;
1291
- return [{
1292
- message: `${blocks} adds policy ${policy.name} on ${target}, and ${reason}. Postgres ORs permissive policies; doctor compares conditions as text and can't prove that one implies another. If the block's condition is what the app means, repeat it in the app's policy; otherwise narrow the permission key it checks, or drop ${policy.name} in a schema file that runs after the block's.`,
1293
- target: `${target}.${policy.name}`,
1294
- object: {
1295
- kind: "policy",
1296
- schema: table.schema,
1297
- table: table.name,
1298
- name: policy.name
1299
- }
1300
- }];
1301
- });
1302
- });
1303
- }
1304
- const KEPT_TRIGGER = /^-- (\S+) keeps updated_at current with its own trigger (\S+)\.$/gm;
1305
- /**
1306
- * App tables whose own trigger keeps `updated_at` current, so the block skipped
1307
- * its `bsb_updated_at` trigger there.
1308
- */
1309
- async function keptUpdatedAtTriggers(context) {
1310
- return (await moduleFiles(context)).flatMap(({ file }) => file.kind === "schema" ? [...file.contents.matchAll(KEPT_TRIGGER)].map(([, target = "", trigger = ""]) => {
1311
- const dot = target.indexOf(".");
1312
- return {
1313
- message: `blocks.${file.instance ?? file.module} runs over ${target}, which keeps updated_at current with its own trigger ${trigger}, so the block adds no bsb_updated_at trigger there. Keep ${trigger} firing on update; if you drop it, run \`better-supabase upgrade\` to add the block's.`,
1314
- target,
1315
- object: {
1316
- kind: "table",
1317
- schema: target.slice(0, dot),
1318
- name: target.slice(dot + 1)
1319
- }
1320
- };
1321
- }) : []);
1322
- }
1323
- /**
1324
- * Whether a deprecated table or column name belongs to the app: the app's
1325
- * tables keep the app's names, as custom blocks' tables do.
1326
- */
1327
- function keepsAppsName(context) {
1328
- const adopted = context.config.blockNames.some((name) => moduleDeprecations().some((entry) => entry.module === name && (entry.kind === "table" || entry.kind === "column"))) ? adoptedTables(context.config.blocks, appTablesOf(context)) : [];
1329
- return (entry) => {
1330
- if (entry.kind !== "table" && entry.kind !== "column") return false;
1331
- if ((context.config.blocks[entry.module]?.mode ?? "managed") !== "managed") return true;
1332
- const name = entry.kind === "table" ? entry.symbol.slice(entry.symbol.lastIndexOf(".") + 1) : entry.symbol.slice(0, entry.symbol.indexOf("."));
1333
- return adopted.some((table) => table.module === entry.module && (name === table.logical || name === table.table || name === SQL_MODULES[table.module]?.names?.tables[table.logical]?.name));
1334
- };
1335
- }
1336
- //#endregion
1337
1379
  //#region src/cli/doctor/attachment-subjects.ts
1338
1380
  /**
1339
1381
  * The attachments subjects as the block resolves them, with the per-subject
@@ -2093,7 +2135,7 @@ const MODULE_RULES = [
2093
2135
  code: "BS347",
2094
2136
  severity: "warning",
2095
2137
  title: "Block policy widens an app table's access",
2096
- description: "A block runs over a table of the app's and adds its own permissive policy there, named `bsb_<table>_<command>` so it never replaces one of the app's. Postgres ORs permissive policies, so when the app has its own policies for that command and none has the same condition (or `true`) for the same roles, the block's policy can let a user reach rows the app's policies keep closed. A block condition that is the app's, or one of its `or` operands, with more `and` operands is narrower and isn't reported, nor is a command the app has no policy for, which is the block's to grant. Doctor compares the conditions as text. When an app policy covers the block's in this sense, `upgrade` leaves the block's policy out. Repeat the block's condition in the app's policy when it is what the app means; otherwise narrow the permission key the block checks, or drop the `bsb_` policy in a schema file that runs after the block's.",
2138
+ description: "A block runs over a table of the app's and adds its own permissive policy there, named `bsb_<table>_<command>` so it never replaces one of the app's. Postgres ORs permissive policies, so when the app has its own policies for that command and none has the same condition (or `true`) for the same roles, the block's policy can let a user reach rows the app's policies keep closed. A block condition that is the app's, or one of its `or` operands, with more `and` operands is narrower and isn't reported, nor is a command the app has no policy for, which is the block's to grant. Doctor compares the conditions as text. When an app policy covers the block's in this sense, `upgrade` leaves the block's policy out. Repeat the block's condition in the app's policy when it is what the app means; otherwise narrow the permission key the block checks, drop the `bsb_` policy in a schema file that runs after the block's, or set `ownTablePolicies: \"app\"` on the block (or in `database.sql`) so the app's policies alone govern the table and the block adds none there.",
2097
2139
  check: widenedAppTablePolicies
2098
2140
  },
2099
2141
  {
@@ -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-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
- import { d as GEN_TASKS, p as isGenTask } from "./config-9t5ec_N7.js";
4
+ import { u as catalogFingerprint } from "./cache-oU0yHKf0.js";
5
+ import { a as serializeSnapshot, g as serializeGenerator, h as restrictSchemas, o as snapshotFile, r as openSource, t as loadSnapshot } from "./snapshot-C6vh_n3t.js";
6
+ import { f as dataMigration } from "./module-migration-mKhX88V_.js";
7
+ import { d as GEN_TASKS, p as isGenTask } from "./config-2rwFHbwj.js";
8
8
  import { c as insideRoot, r as applyPlan, u as planResult } from "./files-CX71yBm8.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
- 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-BfgHMe4q.js";
9
+ import { n as runGen } from "./run-CLSHSVYo.js";
10
+ import { t as syncModules } from "./sync-CHGMZCJ5.js";
11
+ import { t as addModules } from "./add-BinNYhFD.js";
12
+ import { n as listModules, t as printModule } from "./print-Dh8iuPK3.js";
13
+ import { a as sourceFlags, i as sourceArgs, n as SOURCE_ARGS } from "./source-args-MTLYpifA.js";
14
+ import { a as runMetadataGen, n as checkMetadataFlags, t as EMITS } from "./metadata-BNSdPuKp.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-Cm2einTO.js";
17
- import { t as runSeed } from "./seed-Cz8PcXeT.js";
18
- import { t as upgrade } from "./upgrade-BFEIMC7U.js";
16
+ import { c as watchLoop, o as parseInterval, r as specOptionsFromConfig, s as stampFiles, t as runSpec } from "./spec-B4LhpI6t.js";
17
+ import { t as runSeed } from "./seed-CG-pA-5N.js";
18
+ import { t as upgrade } from "./upgrade-C0dVsqNX.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.16.0";
801
+ export declare const VERSION = "0.17.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 };