better-supabase 0.23.0 → 0.28.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 (364) hide show
  1. package/dist/{access-sql-bjWFUWlk.js → access-sql-CTDNuxRv.js} +177 -12
  2. package/dist/{ai-schedules-7uQNMXve.d.ts → ai-schedules-yGZH-vQb.d.ts} +1 -1
  3. package/dist/ai-sdk/agents/index.d.ts +2 -2
  4. package/dist/ai-sdk/batches/index.d.ts +1 -1
  5. package/dist/ai-sdk/index.d.ts +1 -1
  6. package/dist/ai-sdk/mcp/index.d.ts +3 -3
  7. package/dist/{api-CHObZL7m.d.ts → api-B1OkIWdx.d.ts} +3 -3
  8. package/dist/{api-keys-D5k63K6y.d.ts → api-keys-ClhKBDcc.d.ts} +1 -1
  9. package/dist/{app-tables-CJO6pWwy.d.ts → app-tables-62GqZIhd.d.ts} +1 -1
  10. package/dist/{approvals-Dh9dUXrN.d.ts → approvals-C5fmPLsH.d.ts} +1 -1
  11. package/dist/astro/index.d.ts +5 -5
  12. package/dist/{authorization-Dtwpjeuz.d.ts → authorization-BCG1v0iC.d.ts} +73 -15
  13. package/dist/{authorization-hooks-D_pwXlBs.d.ts → authorization-hooks-DtzreCAq.d.ts} +1 -1
  14. package/dist/{automations-FCnWy387.js → automations-8L3NEuoq.js} +4 -1
  15. package/dist/{availability-vguUvEK2.d.ts → availability-BdeKCHpl.d.ts} +10 -0
  16. package/dist/better-result/index.d.ts +2 -2
  17. package/dist/{bind-DaoTunvE.d.ts → bind-C54jD0r3.d.ts} +4 -4
  18. package/dist/{block-env-DUyo2I5O.d.ts → block-env-CM-LFfj4.d.ts} +4 -4
  19. package/dist/blocks/access-requests/index.d.ts +2 -2
  20. package/dist/blocks/activities/index.d.ts +3 -3
  21. package/dist/blocks/agents/index.d.ts +2 -2
  22. package/dist/blocks/ai-cache/index.d.ts +1 -1
  23. package/dist/blocks/ai-chat/index.d.ts +5 -5
  24. package/dist/blocks/ai-files/index.d.ts +1 -1
  25. package/dist/blocks/ai-keys/index.d.ts +3 -3
  26. package/dist/blocks/ai-schedules/index.d.ts +2 -2
  27. package/dist/blocks/announcements/index.d.ts +5 -5
  28. package/dist/blocks/api-keys/index.d.ts +5 -5
  29. package/dist/blocks/approvals/index.d.ts +3 -3
  30. package/dist/blocks/assets/index.d.ts +2 -2
  31. package/dist/blocks/assignment/index.d.ts +3 -3
  32. package/dist/blocks/attachments/index.d.ts +3 -3
  33. package/dist/blocks/audit/index.d.ts +7 -7
  34. package/dist/blocks/automations/index.d.ts +5 -5
  35. package/dist/blocks/billable-time/index.d.ts +2 -2
  36. package/dist/blocks/billing/index.d.ts +5 -5
  37. package/dist/blocks/bookings/index.d.ts +6 -6
  38. package/dist/blocks/bulk/index.d.ts +2 -2
  39. package/dist/blocks/calendar/index.d.ts +46 -13
  40. package/dist/blocks/calendar/index.js +130 -30
  41. package/dist/blocks/catalog/index.d.ts +2 -2
  42. package/dist/blocks/channels/index.d.ts +3 -3
  43. package/dist/blocks/collections/index.d.ts +3 -3
  44. package/dist/blocks/comments/index.d.ts +5 -5
  45. package/dist/blocks/compliance/index.d.ts +2 -2
  46. package/dist/blocks/connectors/index.d.ts +3 -3
  47. package/dist/blocks/contacts/index.d.ts +3 -3
  48. package/dist/blocks/content/index.d.ts +2 -2
  49. package/dist/blocks/contracts/index.d.ts +2 -2
  50. package/dist/blocks/courses/index.d.ts +2 -2
  51. package/dist/blocks/created-by/index.d.ts +1 -1
  52. package/dist/blocks/custom-fields/index.d.ts +2 -2
  53. package/dist/blocks/custom-fields/index.js +1 -1
  54. package/dist/blocks/data-lifecycle/index.d.ts +4 -4
  55. package/dist/blocks/deals/index.d.ts +3 -3
  56. package/dist/blocks/dispatch/index.d.ts +2 -2
  57. package/dist/blocks/documents/index.d.ts +2 -2
  58. package/dist/blocks/domains/index.d.ts +2 -2
  59. package/dist/blocks/donations/index.d.ts +2 -2
  60. package/dist/blocks/drive/index.d.ts +4 -4
  61. package/dist/blocks/employees/index.d.ts +21 -6
  62. package/dist/blocks/employees/index.js +37 -2
  63. package/dist/blocks/enrichment/index.d.ts +3 -3
  64. package/dist/blocks/enrollments/index.d.ts +2 -2
  65. package/dist/blocks/entitlements/index.d.ts +3 -3
  66. package/dist/blocks/expenses/index.d.ts +2 -2
  67. package/dist/blocks/field-history/index.d.ts +1 -1
  68. package/dist/blocks/flags/index.d.ts +2 -2
  69. package/dist/blocks/forecasts/index.d.ts +3 -3
  70. package/dist/blocks/forms/index.d.ts +3 -3
  71. package/dist/blocks/goals/index.d.ts +1 -1
  72. package/dist/blocks/guests/index.d.ts +2 -2
  73. package/dist/blocks/hiring/index.d.ts +13 -6
  74. package/dist/blocks/hiring/index.js +15 -4
  75. package/dist/blocks/identities/index.d.ts +2 -2
  76. package/dist/blocks/imports/index.d.ts +2 -2
  77. package/dist/blocks/inbox/index.d.ts +6 -6
  78. package/dist/blocks/incidents/index.d.ts +2 -2
  79. package/dist/blocks/index.d.ts +4 -4
  80. package/dist/blocks/inventory/index.d.ts +2 -2
  81. package/dist/blocks/invoices/index.d.ts +3 -3
  82. package/dist/blocks/knowledge/index.d.ts +1 -1
  83. package/dist/blocks/lead-scoring/index.d.ts +1 -1
  84. package/dist/blocks/leases/index.d.ts +2 -2
  85. package/dist/blocks/leave/index.d.ts +2 -2
  86. package/dist/blocks/ledger/index.d.ts +2 -2
  87. package/dist/blocks/mail-sync/index.d.ts +3 -3
  88. package/dist/blocks/memberships/index.d.ts +1 -1
  89. package/dist/blocks/memory/index.d.ts +1 -1
  90. package/dist/blocks/messaging/index.d.ts +7 -7
  91. package/dist/blocks/metrics/index.d.ts +2 -2
  92. package/dist/blocks/mfa/index.d.ts +2 -2
  93. package/dist/blocks/moderation/index.d.ts +2 -2
  94. package/dist/blocks/notifications/index.d.ts +7 -7
  95. package/dist/blocks/numbering/index.d.ts +2 -2
  96. package/dist/blocks/oauth-server/index.d.ts +2 -2
  97. package/dist/blocks/onboarding/index.d.ts +2 -2
  98. package/dist/blocks/orders/index.d.ts +3 -3
  99. package/dist/blocks/organizations/index.d.ts +4 -4
  100. package/dist/blocks/outbox/index.d.ts +2 -2
  101. package/dist/blocks/passes/index.d.ts +3 -3
  102. package/dist/blocks/permissions/index.d.ts +3 -3
  103. package/dist/blocks/pipelines/index.d.ts +3 -3
  104. package/dist/blocks/posts/index.d.ts +2 -2
  105. package/dist/blocks/profiles/index.d.ts +1 -1
  106. package/dist/blocks/promotions/index.d.ts +2 -2
  107. package/dist/blocks/push/index.d.ts +3 -3
  108. package/dist/blocks/queue/index.d.ts +1 -1
  109. package/dist/blocks/quotes/index.d.ts +3 -3
  110. package/dist/blocks/rank/index.d.ts +1 -1
  111. package/dist/blocks/reactions/index.d.ts +5 -5
  112. package/dist/blocks/relations/index.d.ts +2 -2
  113. package/dist/blocks/reminders/index.d.ts +4 -4
  114. package/dist/blocks/reviews/index.d.ts +2 -2
  115. package/dist/blocks/saved-views/index.d.ts +4 -4
  116. package/dist/blocks/scores/index.d.ts +2 -2
  117. package/dist/blocks/search/index.d.ts +4 -4
  118. package/dist/blocks/security-events/index.d.ts +3 -3
  119. package/dist/blocks/segments/index.d.ts +3 -3
  120. package/dist/blocks/sequences/index.d.ts +2 -2
  121. package/dist/blocks/service-accounts/index.d.ts +2 -2
  122. package/dist/blocks/sessions/index.d.ts +2 -2
  123. package/dist/blocks/settings/index.d.ts +3 -3
  124. package/dist/blocks/share-links/index.d.ts +2 -2
  125. package/dist/blocks/shipments/index.d.ts +2 -2
  126. package/dist/blocks/signatures/index.d.ts +2 -2
  127. package/dist/blocks/signing-keys/index.d.ts +2 -2
  128. package/dist/blocks/sla/index.d.ts +3 -3
  129. package/dist/blocks/sso/index.d.ts +3 -3
  130. package/dist/blocks/state-machine/index.d.ts +2 -2
  131. package/dist/blocks/subjects/index.d.ts +2 -2
  132. package/dist/blocks/tags/index.d.ts +3 -3
  133. package/dist/blocks/tasks/index.d.ts +6 -6
  134. package/dist/blocks/tasks/index.js +1 -1
  135. package/dist/blocks/teams/index.d.ts +2 -2
  136. package/dist/blocks/templates/index.d.ts +4 -4
  137. package/dist/blocks/time-tracking/index.d.ts +10 -5
  138. package/dist/blocks/time-tracking/index.js +16 -9
  139. package/dist/blocks/timeline/index.d.ts +4 -4
  140. package/dist/blocks/trash/index.d.ts +2 -2
  141. package/dist/blocks/undo/index.d.ts +2 -2
  142. package/dist/blocks/updated-at/index.d.ts +1 -1
  143. package/dist/blocks/usage/index.d.ts +2 -2
  144. package/dist/blocks/vercel-marketplace/index.d.ts +2 -2
  145. package/dist/blocks/versions/index.d.ts +2 -2
  146. package/dist/blocks/waitlist/index.d.ts +2 -2
  147. package/dist/blocks/webhooks/index.d.ts +6 -6
  148. package/dist/blocks/workflow-editor/index.d.ts +7 -7
  149. package/dist/blocks/workflows/index.d.ts +5 -5
  150. package/dist/{bookings-BpCNphYp.d.ts → bookings-CVw5-Q0Z.d.ts} +1 -1
  151. package/dist/chat-sdk/index.d.ts +2 -2
  152. package/dist/cli/{add-DVHniZOO.js → add-BKcE_g9D.js} +2 -2
  153. package/dist/cli/{add-C7lKQNBL.js → add-DUyg9qna.js} +40 -15
  154. package/dist/cli/add-pDOlqWUa.js +1 -0
  155. package/dist/cli/{backfill-Lrn-Qp5X.js → backfill-r9RELEEh.js} +4 -4
  156. package/dist/cli/bin.js +1 -1
  157. package/dist/cli/{blocks-BKNd886C.js → blocks-DTOFdrxL.js} +1 -1
  158. package/dist/cli/{blocks-2Yw9t-_U.js → blocks-k1OG8XDs.js} +2 -2
  159. package/dist/cli/{cache-ByhPVMo-.js → cache-Czfw7Iow.js} +1 -1
  160. package/dist/cli/{codemod-C0eXpzFu.js → codemod-ClmbiLuL.js} +3 -3
  161. package/dist/cli/{command-BWEEXmtz.js → command-CVzTJSLp.js} +31 -0
  162. package/dist/cli/{completion-8EDK21xj.js → completion-CNCqE-Gb.js} +1 -1
  163. package/dist/cli/{completion-BfnKI4QZ.js → completion-Dpk6vh0p.js} +2 -2
  164. package/dist/cli/{completion-Bt7LMypX.js → completion-DxEXxFpz.js} +2 -2
  165. package/dist/cli/{config-CeaQMrvS.js → config-D2YUlzrl.js} +1 -1
  166. package/dist/cli/{config-WKDixoGK.js → config-EjNj3HfT.js} +1 -1
  167. package/dist/cli/{config-BVfeG3A5.js → config-KvV-sLZL.js} +290 -10
  168. package/dist/cli/{content-mapper-qH-_YQ8H.js → content-mapper-ez_mT0d4.js} +2 -2
  169. package/dist/cli/{db-DwjyUbAh.js → db-uYN6O5Eg.js} +38 -14
  170. package/dist/cli/{doctor-BnxkqXGA.js → doctor-BD9oo4MG.js} +31 -28
  171. package/dist/cli/{env-DMgjB_4y.js → env-BK0xKMeU.js} +1 -2
  172. package/dist/cli/{env-C-Bl6Awn.js → env-Bat6ogep.js} +1 -1
  173. package/dist/cli/env-Cy2lWBRC.js +1 -0
  174. package/dist/cli/{env-BCgVZkcb.js → env-DEAtgGoj.js} +2 -2
  175. package/dist/cli/{exec--Q1ZEWUW.js → exec-Ca5s-ygi.js} +1 -1
  176. package/dist/cli/{gen-aERmP3Sw.js → gen-8Ya8n2sA.js} +16 -16
  177. package/dist/cli/in-stack-diff-Cp-tVPj2.js +186 -0
  178. package/dist/cli/index.d.ts +1 -2
  179. package/dist/cli/index.js +8 -8
  180. package/dist/cli/{init-DWUqVSVW.js → init-DgL3sDfQ.js} +118 -11
  181. package/dist/cli/{keys-CbaL0lnw.js → keys-CsanNk-2.js} +1 -1
  182. package/dist/cli/{live-KcdTBUij.js → live-CMMEct_F.js} +2 -2
  183. package/dist/cli/{mcp-Dsjjo-LT.js → mcp-DEHtzAkq.js} +4 -4
  184. package/dist/cli/{metadata-DWQSIZ59.js → metadata-BZh-cOzC.js} +3 -3
  185. package/dist/cli/migrate-sVs1QYTM.js +306 -0
  186. package/dist/cli/{migration-safety-Cy7xlU4G.js → migration-safety-ClnYNMdq.js} +2 -2
  187. package/dist/cli/migrations-DWh38tO9.js +117 -0
  188. package/dist/cli/{module-migration-C6NLY9iZ.js → module-migration-CXfRJIV4.js} +2 -2
  189. package/dist/cli/{moved-DVwgE8lV.js → moved-Cnb4fp49.js} +1 -1
  190. package/dist/cli/{parse-B079x40m.js → parse-BWM6IGhF.js} +1 -1
  191. package/dist/cli/powersync-DURhWDVc.js +1 -0
  192. package/dist/cli/{powersync-CE_hQdgc.js → powersync-Dnyr-Wy5.js} +4 -3
  193. package/dist/cli/{print-Cy_ram9N.js → print-DJrSr56b.js} +2 -2
  194. package/dist/cli/{migrations-CUjNXokR.js → providers-CpaISitn.js} +4 -116
  195. package/dist/cli/{remove-DmwjzqaW.js → remove-ChaieK3t.js} +6 -6
  196. package/dist/cli/{render-CF09FCra.js → render-DUNJ4Pss.js} +8 -5
  197. package/dist/cli/{run-BYpZ8FjF.js → run-ChCQPYOh.js} +41 -39
  198. package/dist/cli/{run-lh-chAJW.js → run-Cl9COGuy.js} +10 -10
  199. package/dist/cli/{run-DmOTMa44.js → run-CxFDjL1Q.js} +4 -4
  200. package/dist/cli/seed-BJ7c-ktX.js +1 -0
  201. package/dist/cli/{seed-BMynpMPy.js → seed-BzVLTdRl.js} +3 -3
  202. package/dist/cli/{shared-D05A6t1e.js → shared-5uqc1GBj.js} +1 -1
  203. package/dist/cli/{skills-FXAVPLzp.js → skills-0gz_qjVb.js} +1 -1
  204. package/dist/cli/{snapshot-BITNbA5V.js → snapshot-DdAP7LWO.js} +3 -3
  205. package/dist/cli/{source-GGJHuzpH.js → source-2irbWSck.js} +1 -1
  206. package/dist/cli/{source-args-CDmmFmFG.js → source-args-DAcQt-Mh.js} +1 -1
  207. package/dist/cli/{spec-BGcRdlhN.js → spec-B7n4Rthp.js} +3 -3
  208. package/dist/cli/{spec-BjxXWaNQ.js → spec-_MS0ym5r.js} +1 -1
  209. package/dist/cli/{sql-layout-BoD5ynN9.js → sql-layout-DYKkQw1k.js} +21 -7
  210. package/dist/cli/{stack-DgASZP0K.js → stack-CteM33gC.js} +3 -3
  211. package/dist/cli/{stack-status-B_Ipd_-z.js → stack-status-BkkYRlXG.js} +1 -1
  212. package/dist/cli/{stacks-BYlQ96WS.js → stacks-CiDBH1dB.js} +1 -1
  213. package/dist/cli/{sync-_QlsTmqu.js → sync-DnSOrQuA.js} +4 -3
  214. package/dist/cli/table-DeH8X0qz.js +89 -0
  215. package/dist/cli/{upgrade-Cwhb1M7O.js → upgrade-CWdrC-K3.js} +5 -4
  216. package/dist/cli/{upgrade-n9ar1kc4.js → upgrade-cMy5fKkg.js} +3 -3
  217. package/dist/cli/{version-RSpJIWDd.js → version-C5RAWmrD.js} +1 -1
  218. package/dist/client/index.d.ts +5 -5
  219. package/dist/client/native/index.d.ts +4 -4
  220. package/dist/{cloud-event-CzZTJkXv.d.ts → cloud-event-DcJwder2.d.ts} +1 -1
  221. package/dist/{composite-ChzHhSB0.d.ts → composite-CWJvZgni.d.ts} +6 -6
  222. package/dist/config/index.d.ts +3 -3
  223. package/dist/config/index.js +4 -4
  224. package/dist/{config-RwpFcPq8.js → config-CTeR7XHK.js} +6 -5
  225. package/dist/{config-vHLJ8SKf.js → config-CvJHIy5q.js} +4 -3
  226. package/dist/{connectors-Fud4amxp.d.ts → connectors-CHGiffYH.d.ts} +1 -1
  227. package/dist/{context-CMf4OKpN.d.ts → context-BFEX0b7H.d.ts} +109 -4
  228. package/dist/{controller-BGto_kYM.d.ts → controller-Cl6HmMBk.d.ts} +1 -1
  229. package/dist/{conversion-DBgMck5U.d.ts → conversion-DlfStnln.d.ts} +1 -1
  230. package/dist/create/index.d.ts +62 -3
  231. package/dist/create/index.js +67 -4
  232. package/dist/create/lite/index.d.ts +140 -3
  233. package/dist/create/lite/index.js +399 -47
  234. package/dist/credentials/index.d.ts +3 -3
  235. package/dist/{define-Lf6rI2QN.d.ts → define-BLP6XtoL.d.ts} +1 -1
  236. package/dist/{define-block-DCAiOrNX.d.ts → define-block-DibVN37N.d.ts} +4 -4
  237. package/dist/edge/index.d.ts +8 -8
  238. package/dist/elysia/index.d.ts +1 -1
  239. package/dist/{ended-gUsMZVNg.d.ts → ended-B8RyuUXF.d.ts} +1 -1
  240. package/dist/{entitlements-CIhVQ-0u.d.ts → entitlements-Y-n4RGAd.d.ts} +2 -2
  241. package/dist/eve/index.d.ts +2 -2
  242. package/dist/{event-calendar-DCufbihU.d.ts → event-calendar-DVLs2wUO.d.ts} +1 -1
  243. package/dist/events/index.d.ts +3 -3
  244. package/dist/{events-vcqenSYU.d.ts → events-Cc9DDQWH.d.ts} +2 -0
  245. package/dist/{executor-DNK401lZ.d.ts → executor-C-Ox9eKq.d.ts} +1 -1
  246. package/dist/{executor-aFV7nEBs.d.ts → executor-DNPm13a9.d.ts} +2 -2
  247. package/dist/expo/index.d.ts +3 -3
  248. package/dist/{field-errors-BDhPaO0a.d.ts → field-errors-Btn3czyz.d.ts} +7 -7
  249. package/dist/{framework-DKA3fTHl.d.ts → framework-GlxXiotm.d.ts} +6 -6
  250. package/dist/h3/index.d.ts +1 -1
  251. package/dist/h3/v1/index.d.ts +1 -1
  252. package/dist/hono/index.d.ts +8 -8
  253. package/dist/{index-CFWlHuVY.d.ts → index-8wOL81rB.d.ts} +1 -1
  254. package/dist/{index-ClvuSZEz.d.ts → index-BfYDY6eh.d.ts} +3 -3
  255. package/dist/{index-ujNqgZ6B.d.ts → index-C0_cweyT.d.ts} +11 -11
  256. package/dist/{index--OhYKouV.d.ts → index-CAY7rIQs.d.ts} +3 -3
  257. package/dist/{index-CG9rA8H8.d.ts → index-C_qlBJ3k.d.ts} +2 -2
  258. package/dist/{index-iRkFvJ7J.d.ts → index-D1ckLbUM.d.ts} +1 -1
  259. package/dist/{index-lV43eM34.d.ts → index-DPMVWm_Z.d.ts} +4 -4
  260. package/dist/{index-4MStWaeF.d.ts → index-k-SyCzcQ.d.ts} +105 -120
  261. package/dist/index.d.ts +2 -2
  262. package/dist/{instances-BPJSESPx.js → instances-C7qUTjhJ.js} +85 -6
  263. package/dist/{kit-CVgQCIBO.d.ts → kit-Dxx3MT8m.d.ts} +3 -3
  264. package/dist/list/index.d.ts +1 -1
  265. package/dist/{list-query-XYfUZb0j.d.ts → list-query-XHoYDlRN.d.ts} +1 -1
  266. package/dist/mapper/bin.js +7 -7
  267. package/dist/mcp/index.d.ts +5 -5
  268. package/dist/mcp/sdk/index.d.ts +5 -5
  269. package/dist/nestjs/index.d.ts +2 -2
  270. package/dist/next/client/index.d.ts +1 -1
  271. package/dist/next/index.d.ts +21 -21
  272. package/dist/node/index.d.ts +2 -2
  273. package/dist/{operations-qSBBV5vl.d.ts → operations-DE7SOBw-.d.ts} +1 -1
  274. package/dist/{options-D4ADKTKo.js → options-B5E2MGIz.js} +6 -1
  275. package/dist/options-C4LuqmdG.js +15 -0
  276. package/dist/{options-D2s7fT1s.js → options-COo7_3MX.js} +2 -1
  277. package/dist/{options-D32-YxnO.js → options-DhoLMknl.js} +3 -1
  278. package/dist/{options-BPp2zzsz.js → options-eTepQ1rZ.js} +2 -1
  279. package/dist/orpc/index.d.ts +7 -7
  280. package/dist/otel/index.d.ts +1 -1
  281. package/dist/otel/index.js +4 -4
  282. package/dist/{outbox-HxjZTfF6.d.ts → outbox-DxZgoKwp.d.ts} +2 -2
  283. package/dist/{pool-CrtT4dg-.d.ts → pool-wjbAMqc1.d.ts} +1 -1
  284. package/dist/{ports-DbHiNSAa.d.ts → ports-DP0bthUk.d.ts} +1 -1
  285. package/dist/postgres/index.d.ts +1 -1
  286. package/dist/powersync/index.d.ts +3 -3
  287. package/dist/preset/index.d.ts +3 -3
  288. package/dist/preset/index.js +3 -3
  289. package/dist/{preset-B1xXOJ0T.js → preset-DwuWNBip.js} +2 -2
  290. package/dist/{project-BM6QMtzV.js → project-Bo1vZqVs.js} +5 -5
  291. package/dist/{provider-CqwEOLCA.d.ts → provider-ClrIplXa.d.ts} +1 -1
  292. package/dist/{push-token-BwF1fyjA.d.ts → push-token-v3xCcVU7.d.ts} +1 -1
  293. package/dist/query/index.d.ts +1 -1
  294. package/dist/react/index.d.ts +7 -7
  295. package/dist/react/native/index.d.ts +1 -1
  296. package/dist/react/server.d.ts +8 -8
  297. package/dist/react/session.d.ts +2 -2
  298. package/dist/react-router/index.d.ts +5 -5
  299. package/dist/realtime/index.d.ts +4 -4
  300. package/dist/realtime/index.js +1 -1
  301. package/dist/{record-form-BbZpwsEi.d.ts → record-form-D2-F4IwS.d.ts} +1 -1
  302. package/dist/records/index.d.ts +7 -7
  303. package/dist/{refresh-DT_ICaK-.d.ts → refresh-CCKB1Wa6.d.ts} +1 -1
  304. package/dist/{refusal-OrlI3g4H.d.ts → refusal-D_tklIEb.d.ts} +2 -2
  305. package/dist/{resolve-CXX6DHv3.d.ts → resolve-Bj1qD7Dy.d.ts} +1 -1
  306. package/dist/{resolved-names-WzRYhUez.js → resolved-names-iLBOUaib.js} +2 -2
  307. package/dist/{resource-execute-CUG6xUuh.d.ts → resource-execute-BSTIfp1D.d.ts} +1 -1
  308. package/dist/{resource-types-DjZ91WKA.d.ts → resource-types-D5WEvYtV.d.ts} +2 -2
  309. package/dist/{resources-6Ncdt9XT.d.ts → resources-CsZ7RhZC.d.ts} +1 -1
  310. package/dist/{respond-oZeJ342J.d.ts → respond-BzRG-0qc.d.ts} +1 -1
  311. package/dist/server/index.d.ts +20 -20
  312. package/dist/{server-types-BH6AjDBN.d.ts → server-types-BlDiY-ya.d.ts} +8 -8
  313. package/dist/{session-Y5SSYO2C.d.ts → session-BGP98Rgj.d.ts} +5 -5
  314. package/dist/{session-status-qQLm7jzh.d.ts → session-status-C4t7kbSn.d.ts} +2 -2
  315. package/dist/{sign-in-BAjR49fq.d.ts → sign-in-CAadgm33.d.ts} +2 -2
  316. package/dist/solid/index.d.ts +9 -9
  317. package/dist/solid-start/index.d.ts +5 -5
  318. package/dist/spec/index.d.ts +1 -1
  319. package/dist/sql/index.d.ts +5 -5
  320. package/dist/sql/index.js +5 -5
  321. package/dist/{sql-CNH8kjLS.js → sql-B7vBP9g0.js} +6248 -2092
  322. package/dist/sqlite/index.d.ts +1 -1
  323. package/dist/ssr/index.d.ts +5 -5
  324. package/dist/storage/index.js +1 -1
  325. package/dist/{subject-readers-8GySC9Z8.d.ts → subject-readers-DJbzlm8a.d.ts} +1 -1
  326. package/dist/{subjects-NomQg6Eg.d.ts → subjects-BYCL-6hA.d.ts} +15 -1
  327. package/dist/{support-B4ZBVxt3.d.ts → support-D7CMbhRT.d.ts} +4 -4
  328. package/dist/{support-view-BYOgwXsJ.d.ts → support-view-CIDXF3_H.d.ts} +1 -1
  329. package/dist/svelte/index.d.ts +8 -8
  330. package/dist/sveltekit/index.d.ts +6 -6
  331. package/dist/{tags-Cjtcp5cN.d.ts → tags-Dg4Ywmqp.d.ts} +1 -1
  332. package/dist/tanstack-db/index.d.ts +1 -1
  333. package/dist/tanstack-start/index.d.ts +5 -5
  334. package/dist/{tenant-D4BA7XQ-.d.ts → tenant-CyLEXgot.d.ts} +2 -2
  335. package/dist/testing/index.d.ts +16 -16
  336. package/dist/testing/index.js +2 -2
  337. package/dist/{timeline-CEzj9v1z.d.ts → timeline-Cjl-1hiA.d.ts} +3 -3
  338. package/dist/{topic-utZqhw96.d.ts → topic-B_DGdAEs.d.ts} +3 -3
  339. package/dist/{topic-F0FKzJyQ.js → topic-DnsNG4Kj.js} +1 -1
  340. package/dist/{types-yj8VF4oY.d.ts → types-BdaBfYIw.d.ts} +2 -2
  341. package/dist/{types-DLnBJ3ST.d.ts → types-DF8JYEf5.d.ts} +2 -2
  342. package/dist/{types-EO2crSX_.d.ts → types-DR1MHh7N.d.ts} +1 -1
  343. package/dist/{vault-O-YlAyHb.d.ts → vault-BghaujrZ.d.ts} +1 -1
  344. package/dist/vercel-connect/index.d.ts +1 -1
  345. package/dist/{verify-B0KLBb3j.d.ts → verify-CI8LgSpv.d.ts} +1 -1
  346. package/dist/{view-DyFdMCqg.d.ts → view-BvNA7EOC.d.ts} +1 -1
  347. package/dist/vue/index.d.ts +9 -9
  348. package/dist/{watch-topic-B1UCoQfz.d.ts → watch-topic-1zIAtiNM.d.ts} +1 -1
  349. package/dist/workflow-sdk/builder/index.d.ts +3 -3
  350. package/dist/workflow-sdk/index.d.ts +1 -1
  351. package/dist/workflow-sdk/world/index.d.ts +1 -1
  352. package/dist/workflow-sdk/world/index.js +1 -1
  353. package/dist/{workflow-sdk-B3Ss55Fy.d.ts → workflow-sdk-BNsZrcVg.d.ts} +1 -1
  354. package/dist/{workflow-sdk-CE8sEK57.js → workflow-sdk-CaEw822d.js} +25 -4
  355. package/dist/yjs/index.d.ts +1 -1
  356. package/dist/yjs/index.js +1 -1
  357. package/package.json +11 -1
  358. package/schemas/config-v1.json +95 -1
  359. package/dist/cli/add-vZRn-uH0.js +0 -1
  360. package/dist/cli/env-xhwXk5Ri.js +0 -1
  361. package/dist/cli/in-stack-diff-DQTW53Vf.js +0 -257
  362. package/dist/cli/powersync-BOhjVQCb.js +0 -1
  363. package/dist/cli/seed-CO3j_bly.js +0 -1
  364. package/dist/options-DztCKw_f.js +0 -8
@@ -1,5 +1,5 @@
1
- import { y as appDefaultError } from "../../instances-BPJSESPx.js";
2
- import { n as loadProject } from "../../project-BM6QMtzV.js";
1
+ import { y as appDefaultError } from "../../instances-C7qUTjhJ.js";
2
+ import { n as loadProject } from "../../project-Bo1vZqVs.js";
3
3
  import { n as loadLite, t as LITE_INSTALL } from "../../runtime-CoKxZibd.js";
4
4
  import { t as defineApi } from "../../api-3C0AWFeP.js";
5
5
  //#region src/create/lite/apply.ts
@@ -192,54 +192,54 @@ function catalogQuery(schemas = ["public"]) {
192
192
  )
193
193
  ) as catalog`;
194
194
  }
195
- function isRecord(value) {
195
+ function isRecord$1(value) {
196
196
  return typeof value === "object" && value !== null && !Array.isArray(value);
197
197
  }
198
- function str(value) {
198
+ function str$1(value) {
199
199
  return typeof value === "string" ? value : null;
200
200
  }
201
201
  function strings(value) {
202
202
  return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
203
203
  }
204
- function records(value) {
205
- return Array.isArray(value) ? value.filter((item) => isRecord(item)) : [];
204
+ function records$1(value) {
205
+ return Array.isArray(value) ? value.filter((item) => isRecord$1(item)) : [];
206
206
  }
207
207
  function readColumn(row) {
208
208
  return {
209
- name: str(row["name"]) ?? "",
210
- type: str(row["type"]) ?? "",
209
+ name: str$1(row["name"]) ?? "",
210
+ type: str$1(row["type"]) ?? "",
211
211
  nullable: row["nullable"] !== false,
212
- default: str(row["default"]),
213
- identity: str(row["identity"]),
212
+ default: str$1(row["default"]),
213
+ identity: str$1(row["identity"]),
214
214
  generated: row["generated"] === true,
215
- comment: str(row["comment"]),
216
- udt: str(row["udt"]) ?? "",
215
+ comment: str$1(row["comment"]),
216
+ udt: str$1(row["udt"]) ?? "",
217
217
  array: row["array"] === true,
218
218
  enumValues: strings(row["enumValues"])
219
219
  };
220
220
  }
221
221
  function readConstraint(row) {
222
- const type = str(row["type"]);
222
+ const type = str$1(row["type"]);
223
223
  return {
224
- name: str(row["name"]) ?? "",
224
+ name: str$1(row["name"]) ?? "",
225
225
  type: type === "p" || type === "u" ? type : "f",
226
226
  columns: strings(row["columns"]),
227
- refSchema: str(row["refSchema"]),
228
- refTable: str(row["refTable"]),
227
+ refSchema: str$1(row["refSchema"]),
228
+ refTable: str$1(row["refTable"]),
229
229
  refColumns: Array.isArray(row["refColumns"]) ? strings(row["refColumns"]) : null,
230
- onDelete: str(row["onDelete"])
230
+ onDelete: str$1(row["onDelete"])
231
231
  };
232
232
  }
233
233
  function readTable(row) {
234
234
  return {
235
- schema: str(row["schema"]) ?? "public",
236
- name: str(row["name"]) ?? "",
237
- kind: str(row["kind"]) ?? "r",
235
+ schema: str$1(row["schema"]) ?? "public",
236
+ name: str$1(row["name"]) ?? "",
237
+ kind: str$1(row["kind"]) ?? "r",
238
238
  rls: row["rls"] === true,
239
- comment: str(row["comment"]),
240
- columns: records(row["columns"]).map((each) => readColumn(each)),
241
- constraints: records(row["constraints"]).map((each) => readConstraint(each)),
242
- indexes: records(row["indexes"]).map((each) => ({
239
+ comment: str$1(row["comment"]),
240
+ columns: records$1(row["columns"]).map((each) => readColumn(each)),
241
+ constraints: records$1(row["constraints"]).map((each) => readConstraint(each)),
242
+ indexes: records$1(row["indexes"]).map((each) => ({
243
243
  columns: strings(each["columns"]),
244
244
  plain: each["plain"] === true
245
245
  })),
@@ -250,11 +250,11 @@ function readTable(row) {
250
250
  /** Reads the one row `catalogQuery` returns; the JSON may arrive as text. */
251
251
  function readCatalog(rows) {
252
252
  const [row] = rows;
253
- const cell = isRecord(row) ? row["catalog"] : void 0;
253
+ const cell = isRecord$1(row) ? row["catalog"] : void 0;
254
254
  const catalog = typeof cell === "string" ? JSON.parse(cell) : cell;
255
- if (!isRecord(catalog)) throw new TypeError("The catalog query returned an unexpected result.");
255
+ if (!isRecord$1(catalog)) throw new TypeError("The catalog query returned an unexpected result.");
256
256
  return {
257
- tables: records(catalog["tables"]).map((each) => readTable(each)),
257
+ tables: records$1(catalog["tables"]).map((each) => readTable(each)),
258
258
  functions: strings(catalog["functions"])
259
259
  };
260
260
  }
@@ -292,7 +292,7 @@ function rungOf(table) {
292
292
  if (!table.rls) return "open";
293
293
  return table.policies === 0 ? "locked" : "protected";
294
294
  }
295
- const qualified = (table) => `${table.schema}.${table.name}`;
295
+ const qualified$1 = (table) => `${table.schema}.${table.name}`;
296
296
  /** A table the design can model: `public`, a single `id` key, no generated id. */
297
297
  function idOf(table) {
298
298
  const keys = table.constraints.filter((each) => each.type === "p");
@@ -331,7 +331,7 @@ function modelTable(table, modeled, preserved) {
331
331
  });
332
332
  else preserved.push({
333
333
  kind: "foreign_key",
334
- name: `${qualified(table)}(${constraint.columns.join(", ")})`,
334
+ name: `${qualified$1(table)}(${constraint.columns.join(", ")})`,
335
335
  reason: `References ${target}, which a design can't express.`
336
336
  });
337
337
  }
@@ -342,7 +342,7 @@ function modelTable(table, modeled, preserved) {
342
342
  if (type === void 0 || column.generated) {
343
343
  preserved.push({
344
344
  kind: "column",
345
- name: `${qualified(table)}.${column.name}`,
345
+ name: `${qualified$1(table)}.${column.name}`,
346
346
  reason: column.generated ? "A generated column is kept as it is." : `The type ${column.type} is kept as it is.`
347
347
  });
348
348
  continue;
@@ -354,7 +354,7 @@ function modelTable(table, modeled, preserved) {
354
354
  if (appDefaultError({ type }, value) === void 0) fallback = value;
355
355
  else preserved.push({
356
356
  kind: "default",
357
- name: `${qualified(table)}.${column.name}`,
357
+ name: `${qualified$1(table)}.${column.name}`,
358
358
  reason: `The default ${column.default} is kept as it is.`
359
359
  });
360
360
  }
@@ -372,7 +372,7 @@ function modelTable(table, modeled, preserved) {
372
372
  for (const index of table.indexes) if (index.plain && index.columns.every((name) => names.has(name))) indexes.push([...index.columns]);
373
373
  else preserved.push({
374
374
  kind: "index",
375
- name: `${qualified(table)}(${index.columns.join(", ")})`,
375
+ name: `${qualified$1(table)}(${index.columns.join(", ")})`,
376
376
  reason: "An expression, partial or non-btree index is kept as it is."
377
377
  });
378
378
  return {
@@ -396,23 +396,23 @@ function designFromCatalog(catalog, issues = []) {
396
396
  if (table.kind === "v" || table.kind === "m") {
397
397
  preserved.push({
398
398
  kind: "view",
399
- name: qualified(table),
399
+ name: qualified$1(table),
400
400
  reason: "A view is kept as it is."
401
401
  });
402
402
  return false;
403
403
  }
404
404
  if (table.name.startsWith(BLOCK_PREFIX)) {
405
- blockOwned.push(qualified(table));
405
+ blockOwned.push(qualified$1(table));
406
406
  return false;
407
407
  }
408
408
  return true;
409
409
  });
410
- const modeled = new Set(candidates.filter((table) => table.schema === "public" && idOf(table) !== void 0).map((table) => qualified(table)));
410
+ const modeled = new Set(candidates.filter((table) => table.schema === "public" && idOf(table) !== void 0).map((table) => qualified$1(table)));
411
411
  for (const table of candidates) {
412
- const model = modeled.has(qualified(table)) ? modelTable(table, modeled, preserved) : void 0;
412
+ const model = modeled.has(qualified$1(table)) ? modelTable(table, modeled, preserved) : void 0;
413
413
  if (model === void 0) preserved.push({
414
414
  kind: "table",
415
- name: qualified(table),
415
+ name: qualified$1(table),
416
416
  reason: table.schema === "public" ? "It has no single uuid or bigint id key, so it is kept as it is." : "Only the public schema is modeled."
417
417
  });
418
418
  else appTables[table.name] = model;
@@ -429,7 +429,7 @@ function designFromCatalog(catalog, issues = []) {
429
429
  source: "verifier",
430
430
  path: "",
431
431
  table: table.name,
432
- message: `${qualified(table)} has row level security off, so the Data API exposes every row.`
432
+ message: `${qualified$1(table)} has row level security off, so the Data API exposes every row.`
433
433
  });
434
434
  else if (table.policies === 0) verifier.push({
435
435
  code: "verify_no_policies",
@@ -437,16 +437,16 @@ function designFromCatalog(catalog, issues = []) {
437
437
  source: "verifier",
438
438
  path: "",
439
439
  table: table.name,
440
- message: `${qualified(table)} has row level security on and no policies, so only the service role can read it.`
440
+ message: `${qualified$1(table)} has row level security on and no policies, so only the service role can read it.`
441
441
  });
442
442
  if (table.triggers > 0) preserved.push({
443
443
  kind: "trigger",
444
- name: qualified(table),
444
+ name: qualified$1(table),
445
445
  reason: `${String(table.triggers)} trigger(s) are kept as they are.`
446
446
  });
447
447
  if (table.policies > 0) preserved.push({
448
448
  kind: "policy",
449
- name: qualified(table),
449
+ name: qualified$1(table),
450
450
  reason: `${String(table.policies)} polic${table.policies === 1 ? "y is" : "ies are"} kept as ${table.policies === 1 ? "it is" : "they are"}.`
451
451
  });
452
452
  }
@@ -876,13 +876,13 @@ const ROLES = /* @__PURE__ */ new Set([
876
876
  "authenticated",
877
877
  "service_role"
878
878
  ]);
879
- function roleOf(persona) {
879
+ function roleOf$1(persona) {
880
880
  return persona.role ?? (persona.sub === void 0 ? "anon" : "authenticated");
881
881
  }
882
- function claimsOf(persona) {
882
+ function claimsOf$1(persona) {
883
883
  return {
884
884
  ...persona.claims,
885
- role: roleOf(persona),
885
+ role: roleOf$1(persona),
886
886
  ...persona.sub === void 0 ? {} : { sub: persona.sub }
887
887
  };
888
888
  }
@@ -906,7 +906,7 @@ var Queue = class {
906
906
  };
907
907
  async function asPersona(driver, queue, persona, sql, params) {
908
908
  return queue.run(async () => {
909
- const role = roleOf(persona);
909
+ const role = roleOf$1(persona);
910
910
  if (!ROLES.has(role)) return {
911
911
  ok: false,
912
912
  error: {
@@ -921,7 +921,7 @@ async function asPersona(driver, queue, persona, sql, params) {
921
921
  set_config('request.jwt.claim.sub', $3, true),
922
922
  set_config('request.jwt.claim.role', $1, true)`, [
923
923
  role,
924
- JSON.stringify(claimsOf(persona)),
924
+ JSON.stringify(claimsOf$1(persona)),
925
925
  persona.sub ?? ""
926
926
  ]);
927
927
  const rows = rowsOf(await driver.query(sql, params));
@@ -1070,6 +1070,358 @@ async function designDataApi(preset, design = {}, options = {}) {
1070
1070
  }
1071
1071
  }
1072
1072
  //#endregion
1073
+ //#region src/create/lite/verify.ts
1074
+ const MATRIX_COMMANDS = [
1075
+ "select",
1076
+ "insert",
1077
+ "update",
1078
+ "delete"
1079
+ ];
1080
+ /**
1081
+ * One query that returns the security facts as JSON: row level security and
1082
+ * grants of each table, its policies, and the functions' `search_path`.
1083
+ */
1084
+ function verifyQuery(schemas = ["public"]) {
1085
+ const list = schemas.map((name) => `'${name.replaceAll("'", "''")}'`).join(", ");
1086
+ return `select json_build_object(
1087
+ 'tables', (
1088
+ select coalesce(json_agg(t order by t.schema, t.name), '[]'::json) from (
1089
+ select n.nspname as schema, c.relname as name,
1090
+ c.relrowsecurity as rls, c.relforcerowsecurity as force,
1091
+ (select coalesce(json_agg(json_build_object(
1092
+ 'name', p.polname,
1093
+ 'command', case p.polcmd when 'r' then 'select' when 'a' then 'insert'
1094
+ when 'w' then 'update' when 'd' then 'delete' else 'all' end,
1095
+ 'permissive', p.polpermissive,
1096
+ 'roles', (select coalesce(json_agg(case when r.oid = 0 then 'public' else r.rolname end), '[]'::json)
1097
+ from unnest(p.polroles) as u(oid)
1098
+ left join pg_roles r on r.oid = u.oid),
1099
+ 'using', pg_get_expr(p.polqual, p.polrelid),
1100
+ 'check', pg_get_expr(p.polwithcheck, p.polrelid)
1101
+ )), '[]'::json)
1102
+ from pg_policy p where p.polrelid = c.oid) as policies,
1103
+ (select coalesce(json_agg(json_build_object(
1104
+ 'grantee', case when a.grantee = 0 then 'public' else (select rolname from pg_roles where oid = a.grantee) end,
1105
+ 'privilege', a.privilege_type
1106
+ )), '[]'::json)
1107
+ from aclexplode(c.relacl) a) as grants
1108
+ from pg_class c
1109
+ join pg_namespace n on n.oid = c.relnamespace
1110
+ where n.nspname in (${list}) and c.relkind in ('r', 'p')
1111
+ ) t
1112
+ ),
1113
+ 'functions', (
1114
+ select coalesce(json_agg(json_build_object(
1115
+ 'schema', n.nspname, 'name', p.proname, 'definer', p.prosecdef,
1116
+ 'searchPath', coalesce(exists (select 1 from unnest(p.proconfig) as c(setting) where c.setting like 'search_path=%'), false)
1117
+ ) order by n.nspname, p.proname), '[]'::json)
1118
+ from pg_proc p join pg_namespace n on n.oid = p.pronamespace
1119
+ where n.nspname in (${list}) and p.prokind in ('f', 'p')
1120
+ )
1121
+ ) as catalog`;
1122
+ }
1123
+ function isRecord(value) {
1124
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1125
+ }
1126
+ function str(value) {
1127
+ return typeof value === "string" ? value : "";
1128
+ }
1129
+ function records(value) {
1130
+ return Array.isArray(value) ? value.filter((item) => isRecord(item)) : [];
1131
+ }
1132
+ function commandOf(value) {
1133
+ switch (value) {
1134
+ case "select":
1135
+ case "insert":
1136
+ case "update":
1137
+ case "delete": return value;
1138
+ default: return "all";
1139
+ }
1140
+ }
1141
+ function readPolicy(row) {
1142
+ return {
1143
+ name: str(row["name"]),
1144
+ command: commandOf(row["command"]),
1145
+ permissive: row["permissive"] !== false,
1146
+ roles: Array.isArray(row["roles"]) ? row["roles"].filter((item) => typeof item === "string") : [],
1147
+ using: typeof row["using"] === "string" ? row["using"] : null,
1148
+ check: typeof row["check"] === "string" ? row["check"] : null
1149
+ };
1150
+ }
1151
+ /** Reads the row `verifyQuery` returns; the JSON may arrive as text. */
1152
+ function readSecurityCatalog(rows) {
1153
+ const [row] = rows;
1154
+ const cell = isRecord(row) ? row["catalog"] : void 0;
1155
+ const parsed = typeof cell === "string" ? JSON.parse(cell) : cell;
1156
+ const catalog = isRecord(parsed) ? parsed : {};
1157
+ return {
1158
+ tables: records(catalog["tables"]).map((table) => ({
1159
+ schema: str(table["schema"]),
1160
+ name: str(table["name"]),
1161
+ rls: table["rls"] === true,
1162
+ force: table["force"] === true,
1163
+ policies: records(table["policies"]).map((each) => readPolicy(each)),
1164
+ grants: records(table["grants"]).map((grant) => ({
1165
+ grantee: str(grant["grantee"]),
1166
+ privilege: str(grant["privilege"])
1167
+ }))
1168
+ })),
1169
+ functions: records(catalog["functions"]).map((fn) => ({
1170
+ schema: str(fn["schema"]),
1171
+ name: str(fn["name"]),
1172
+ definer: fn["definer"] === true,
1173
+ searchPath: fn["searchPath"] === true
1174
+ }))
1175
+ };
1176
+ }
1177
+ const qualified = (table) => `${table.schema}.${table.name}`;
1178
+ /** An expression that admits every row: `true`, in any amount of parentheses. */
1179
+ function isTrue(expression) {
1180
+ if (expression === null) return false;
1181
+ let text = expression.replaceAll(/\s+/gu, "").toLowerCase();
1182
+ while (text.startsWith("(") && text.endsWith(")")) text = text.slice(1, -1);
1183
+ return text === "true";
1184
+ }
1185
+ const WRITES = /* @__PURE__ */ new Set([
1186
+ "INSERT",
1187
+ "UPDATE",
1188
+ "DELETE",
1189
+ "TRUNCATE"
1190
+ ]);
1191
+ function appliesTo(policy, role) {
1192
+ return policy.roles.includes(role) || policy.roles.includes("public");
1193
+ }
1194
+ function covers(policy, command) {
1195
+ return policy.command === "all" || policy.command === command;
1196
+ }
1197
+ function hasPrivilege(table, role, command) {
1198
+ const wanted = command.toUpperCase();
1199
+ return table.grants.some((grant) => grant.privilege === wanted && (grant.grantee === role || grant.grantee === "public"));
1200
+ }
1201
+ function expressionOf(policy, command) {
1202
+ return command === "insert" ? policy.check : policy.using;
1203
+ }
1204
+ function reachOf(table, role, command) {
1205
+ if (!hasPrivilege(table, role, command)) return "denied";
1206
+ if (!table.rls) return "open";
1207
+ const applicable = table.policies.filter((policy) => appliesTo(policy, role) && covers(policy, command));
1208
+ const permissive = applicable.filter((policy) => policy.permissive);
1209
+ if (permissive.length === 0) return "denied";
1210
+ const restrictive = applicable.filter((policy) => !policy.permissive);
1211
+ return permissive.some((policy) => isTrue(expressionOf(policy, command))) && restrictive.every((policy) => isTrue(expressionOf(policy, command))) ? "open" : "policy";
1212
+ }
1213
+ /**
1214
+ * The role by command by table matrix: how far `anon` and `authenticated` reach
1215
+ * with each command on each table (ADR 0105). The service role bypasses row
1216
+ * level security, so it has no row.
1217
+ */
1218
+ function accessMatrix(catalog) {
1219
+ const roles = ["anon", "authenticated"];
1220
+ return catalog.tables.flatMap((table) => roles.flatMap((role) => MATRIX_COMMANDS.map((command) => ({
1221
+ table: qualified(table),
1222
+ role,
1223
+ command,
1224
+ reach: reachOf(table, role, command)
1225
+ }))));
1226
+ }
1227
+ function issue(code, severity, table, message) {
1228
+ return {
1229
+ code,
1230
+ severity,
1231
+ source: "verifier",
1232
+ path: "",
1233
+ table,
1234
+ message
1235
+ };
1236
+ }
1237
+ function tableIssues(table, options) {
1238
+ const name = qualified(table);
1239
+ const issues = [];
1240
+ const exposed = table.grants.some((grant) => grant.grantee === "anon" || grant.grantee === "authenticated" || grant.grantee === "public");
1241
+ if (!table.rls && exposed) issues.push(issue("verify_rls_off", "error", name, `${name} has row level security off and is granted to a client role`));
1242
+ if (options.force?.includes(name) === true && !table.force) issues.push(issue("verify_force_off", "error", name, `${name} must force row level security so its owner is bound by the policies`));
1243
+ if (options.tenantScoped?.includes(name) === true && !table.policies.some((policy) => !policy.permissive && policy.name.startsWith("bsb_tenant_scope"))) issues.push(issue("verify_scope_missing", "error", name, `${name} has no restrictive bsb_tenant_scope policy`));
1244
+ for (const policy of table.policies) if (policy.permissive && (isTrue(policy.using) || isTrue(policy.check)) && policy.command !== "select") issues.push(issue("verify_policy_true", "error", name, `${name}: policy ${policy.name} lets ${policy.roles.join(", ")} ${policy.command} every row`));
1245
+ for (const grant of table.grants) {
1246
+ if (grant.grantee === "anon" && WRITES.has(grant.privilege)) issues.push(issue("verify_anon_write", "error", name, `${name}: anon holds ${grant.privilege}`));
1247
+ if (grant.grantee === "public") issues.push(issue("verify_public_grant", "warning", name, `${name}: PUBLIC holds ${grant.privilege}`));
1248
+ }
1249
+ return issues;
1250
+ }
1251
+ /**
1252
+ * Checks the facts a policy file can't show on its own: row level security on
1253
+ * every exposed table, no permissive write policy that is only `true`, no write
1254
+ * grant to `anon`, nothing granted to `PUBLIC`, `search_path` on every security
1255
+ * definer function, and, when asked, forced row level security and a
1256
+ * restrictive tenant scope. A permissive `select` policy of `true` for `anon`
1257
+ * is an error too. Findings are `Issue`s with `source: "verifier"`.
1258
+ */
1259
+ function verifyCatalog(catalog, options = {}) {
1260
+ const issues = catalog.tables.flatMap((table) => tableIssues(table, options));
1261
+ for (const cell of accessMatrix(catalog)) if (cell.role === "anon" && cell.command === "select") {
1262
+ const table = catalog.tables.find((each) => qualified(each) === cell.table);
1263
+ if (cell.reach === "open" && table?.rls === true && table.policies.some((policy) => policy.permissive)) issues.push(issue("verify_anon_reads_all", "error", cell.table, `${cell.table}: anon reads every row`));
1264
+ }
1265
+ for (const fn of catalog.functions) if (fn.definer && !fn.searchPath) issues.push(issue("verify_definer_search_path", "error", `${fn.schema}.${fn.name}`, `${fn.schema}.${fn.name} is security definer without a search_path`));
1266
+ return issues;
1267
+ }
1268
+ /**
1269
+ * Applies the files to an in-memory PGlite database, reads its catalog and
1270
+ * returns `verifyCatalog`'s findings with the matrix. Throws when
1271
+ * `@supabase/lite` isn't installed.
1272
+ */
1273
+ async function verifyFiles(files, options = {}) {
1274
+ const runtime = options.runtime ?? await loadLite();
1275
+ if (runtime === void 0) throw new Error(LITE_INSTALL);
1276
+ const connection = await runtime.createPgliteConnection();
1277
+ try {
1278
+ const { driver } = connection;
1279
+ await driver.exec(SUPABASE_PRELUDE);
1280
+ await applyFiles(driver, files);
1281
+ const { rows } = await driver.query(verifyQuery(options.schemas));
1282
+ const catalog = readSecurityCatalog(rows);
1283
+ return {
1284
+ issues: verifyCatalog(catalog, options),
1285
+ matrix: accessMatrix(catalog)
1286
+ };
1287
+ } finally {
1288
+ await connection.close();
1289
+ }
1290
+ }
1291
+ //#endregion
1292
+ //#region src/create/lite/matrix-tests.ts
1293
+ const MATRIX_PERSONAS = [
1294
+ "anon",
1295
+ "signed-in",
1296
+ "member-a",
1297
+ "member-b",
1298
+ "support",
1299
+ "service"
1300
+ ];
1301
+ const DEFAULT_SUBS = {
1302
+ anon: "00000000-0000-4000-8000-0000000000e0",
1303
+ "signed-in": "00000000-0000-4000-8000-0000000000e1",
1304
+ "member-a": "00000000-0000-4000-8000-0000000000e2",
1305
+ "member-b": "00000000-0000-4000-8000-0000000000e3",
1306
+ support: "00000000-0000-4000-8000-0000000000e4",
1307
+ service: "00000000-0000-4000-8000-0000000000e5"
1308
+ };
1309
+ /** The database role a persona runs as. */
1310
+ function roleOf(persona) {
1311
+ switch (persona) {
1312
+ case "anon": return "anon";
1313
+ case "service": return "service_role";
1314
+ case "signed-in":
1315
+ case "member-a":
1316
+ case "member-b":
1317
+ case "support": return "authenticated";
1318
+ default: return persona;
1319
+ }
1320
+ }
1321
+ function quoteLiteral(value) {
1322
+ return `'${value.replaceAll("'", "''")}'`;
1323
+ }
1324
+ function quoteTable(table) {
1325
+ return table.split(".").map((part) => `"${part.replaceAll("\"", "\"\"")}"`).join(".");
1326
+ }
1327
+ /** The statement a persona runs to try `command` on `table`. */
1328
+ function statementOf(command, table) {
1329
+ const target = quoteTable(table);
1330
+ switch (command) {
1331
+ case "select": return `select count(*) from ${target}`;
1332
+ case "insert": return `insert into ${target} default values`;
1333
+ case "update": return `select 1 from ${target} where false for update`;
1334
+ case "delete": return `delete from ${target} where false`;
1335
+ default: return command;
1336
+ }
1337
+ }
1338
+ /**
1339
+ * The helper each file defines: runs a statement in a savepoint and returns
1340
+ * `denied` for a missing privilege or a row level security violation (SQLSTATE
1341
+ * 42501), `rows:<n>` when it ran, and `error:<sqlstate>` otherwise, so a
1342
+ * constraint error on an allowed insert is not mistaken for a denial.
1343
+ */
1344
+ const ATTEMPT = `create function extensions.bsb_attempt(statement text) returns text
1345
+ language plpgsql as $attempt$
1346
+ declare n bigint;
1347
+ begin
1348
+ execute statement;
1349
+ get diagnostics n = row_count;
1350
+ return 'rows:' || n;
1351
+ exception
1352
+ when insufficient_privilege then return 'denied';
1353
+ when others then return 'error:' || sqlstate;
1354
+ end $attempt$;
1355
+ grant execute on function extensions.bsb_attempt(text) to anon, authenticated, service_role;`;
1356
+ function claimsOf(persona, setup) {
1357
+ const sub = setup.sub ?? DEFAULT_SUBS[persona];
1358
+ return JSON.stringify({
1359
+ sub,
1360
+ role: roleOf(persona),
1361
+ ...persona === "anon" ? {} : { aud: "authenticated" },
1362
+ ...setup.claims
1363
+ });
1364
+ }
1365
+ function assertionsOf(persona, cells) {
1366
+ const role = roleOf(persona);
1367
+ if (role === "service_role") return [...new Set(cells.map((cell) => cell.table))].map((table) => ({ sql: `select extensions.isnt(extensions.bsb_attempt(${quoteLiteral(statementOf("select", table))}), 'denied', ${quoteLiteral(`service_role reads ${table}`)});` }));
1368
+ return cells.filter((cell) => cell.role === role).flatMap((cell) => {
1369
+ const statement = quoteLiteral(statementOf(cell.command, cell.table));
1370
+ const label = `${persona} ${cell.command} ${cell.table}`;
1371
+ switch (cell.reach) {
1372
+ case "denied": return [{ sql: `select extensions.ok(extensions.bsb_attempt(${statement}) in ('denied', 'rows:0'), ${quoteLiteral(`${label} reaches no row`)});` }];
1373
+ case "open": return [{ sql: `select extensions.isnt(extensions.bsb_attempt(${statement}), 'denied', ${quoteLiteral(`${label} is not denied`)});` }];
1374
+ case "policy": return cell.command === "insert" ? [] : [{ sql: `select extensions.isnt(extensions.bsb_attempt(${statement}), 'denied', ${quoteLiteral(`${label} is decided by a policy`)});` }];
1375
+ default: return cell.reach;
1376
+ }
1377
+ });
1378
+ }
1379
+ function fileOf(persona, cells, options) {
1380
+ const setup = options.setup?.[persona] ?? {};
1381
+ const assertions = assertionsOf(persona, cells);
1382
+ const role = roleOf(persona);
1383
+ const directory = options.directory ?? "supabase/tests/database";
1384
+ const name = persona.replaceAll("-", "_");
1385
+ const lines = [
1386
+ `-- Generated access matrix for the ${persona} persona (ADR 0105).`,
1387
+ `-- Each assertion holds the table's reach for ${role} against the catalog the matrix read.`,
1388
+ "begin;",
1389
+ "create extension if not exists pgtap with schema extensions;",
1390
+ `select extensions.plan(${Math.max(assertions.length, 1)});`,
1391
+ "",
1392
+ ATTEMPT,
1393
+ "",
1394
+ ...setup.setup === void 0 ? [] : [setup.setup, ""],
1395
+ `select set_config('request.jwt.claims', ${quoteLiteral(claimsOf(persona, setup))}, true);`,
1396
+ `set local role ${role};`,
1397
+ "",
1398
+ ...assertions.length === 0 ? ["select extensions.pass('nothing to check');"] : assertions.map((each) => each.sql),
1399
+ "",
1400
+ "select * from extensions.finish();",
1401
+ "rollback;",
1402
+ ""
1403
+ ];
1404
+ return {
1405
+ path: `${directory}/access_matrix_${name}.test.sql`,
1406
+ module: "access-matrix",
1407
+ contents: lines.join("\n")
1408
+ };
1409
+ }
1410
+ /**
1411
+ * One pgTAP file per persona from the access matrix (ADR 0105): anon, a signed
1412
+ * in user without a membership, a member of tenant A and of tenant B, a
1413
+ * read-only support session and the service role. A cell that reaches no row
1414
+ * must not return one, an open cell must not be denied, and the service role is
1415
+ * never stopped by row level security. Memberships belong to the app, so a
1416
+ * persona's rows and claims come from `options.setup`.
1417
+ */
1418
+ function accessMatrixTests(matrix, options = {}) {
1419
+ const personas = options.personas ?? MATRIX_PERSONAS;
1420
+ const known = new Set(MATRIX_COMMANDS);
1421
+ const cells = matrix.filter((cell) => known.has(cell.command));
1422
+ return personas.map((persona) => fileOf(persona, cells, options));
1423
+ }
1424
+ //#endregion
1073
1425
  //#region src/create/lite/index.ts
1074
1426
  /**
1075
1427
  * Applies the files `previewFiles` returns to an in-memory PGlite database and
@@ -1107,4 +1459,4 @@ async function sqlIssues(files) {
1107
1459
  return (await validateDesign(files)).issues;
1108
1460
  }
1109
1461
  //#endregion
1110
- export { SUPABASE_PRELUDE, designDataApi, designFromCatalog, importFilesOf, importProject, openSandbox, schemaMetaFromCatalog, sqlIssues, validateDesign };
1462
+ export { MATRIX_COMMANDS, MATRIX_PERSONAS, SUPABASE_PRELUDE, accessMatrix, accessMatrixTests, catalogQuery, designDataApi, designFromCatalog, importFilesOf, importProject, openSandbox, readCatalog, readSecurityCatalog, schemaMetaFromCatalog, sqlIssues, validateDesign, verifyCatalog, verifyFiles, verifyQuery };
@@ -1,8 +1,8 @@
1
1
  import { t as AsyncResult } from "../result-DZeA5KS6.js";
2
- import { Ct as Events, P as CredentialEventData } from "../events-vcqenSYU.js";
3
- import { a as CredentialSubject, c as SetCredentialOptions, d as foreignCredentialRef, f as subjectFor, i as CredentialRef, l as StartAuthorizationOptions, n as CredentialCapabilities, o as CredentialToken, p as tenantCredentialRef, r as CredentialProvider, s as GetTokenOptions, t as CompleteAuthorizationOptions, u as credentialRefInTenant } from "../provider-CqwEOLCA.js";
2
+ import { Ct as Events, P as CredentialEventData } from "../events-Cc9DDQWH.js";
3
+ import { a as CredentialSubject, c as SetCredentialOptions, d as foreignCredentialRef, f as subjectFor, i as CredentialRef, l as StartAuthorizationOptions, n as CredentialCapabilities, o as CredentialToken, p as tenantCredentialRef, r as CredentialProvider, s as GetTokenOptions, t as CompleteAuthorizationOptions, u as credentialRefInTenant } from "../provider-ClrIplXa.js";
4
4
  import { a as dbTransport, o as rpcTransport, s as sqlTransport, t as BlockTransport } from "../block-transport-DWZSJrwN.js";
5
- import { a as vaultCredentials, i as VaultInboundScheme, n as VaultCredentials, r as VaultCredentialsOptions, t as VaultCredentialRef } from "../vault-O-YlAyHb.js";
5
+ import { a as vaultCredentials, i as VaultInboundScheme, n as VaultCredentials, r as VaultCredentialsOptions, t as VaultCredentialRef } from "../vault-BghaujrZ.js";
6
6
  //#region src/credentials/compose.d.ts
7
7
  /**
8
8
  * One provider over several: each call goes to the provider whose `name` is the
@@ -2,7 +2,7 @@
2
2
  import { T as ErrorMapper, b as DbError, p as ThrowMapper, t as AsyncResult } from "./result-DZeA5KS6.js";
3
3
  import { t as StandardSchemaV1 } from "./standard-DBV730sF.js";
4
4
  import { Bt as Executor, Ct as ApplyExtension, Ft as RequestContext, It as WithExtension, K as Insert, O as AnyFunctions, St as AnyPlugin, Tt as ExtensionOf, Z as PrimaryKeyValue, a as CountMode, at as Schema, dt as TableMeta, ht as Update, it as Row, k as AnyModels, m as Operation, mt as UniqueWhere, nt as Relations, ot as SchemaMeta, pt as UniqueKeyName, st as Simplify, tt as RelationTypes, ut as TableKey } from "./types-DFdg_4yN.js";
5
- import { a as EventHandler, c as MutationNotice, d as RpcNotice, o as EventHub, s as EventName } from "./events-vcqenSYU.js";
5
+ import { a as EventHandler, c as MutationNotice, d as RpcNotice, o as EventHub, s as EventName } from "./events-Cc9DDQWH.js";
6
6
  import { n as Logger } from "./logger-DWVYUmwi.js";
7
7
  import { j as StorageApi, n as Bucket, r as BucketClient } from "./bucket-vc-QRrva.js";
8
8
  import { h as FilterQuery } from "./filter-query-BXLs72G9.js";
@@ -3,9 +3,9 @@ import { T as ErrorMapper, b as DbError, f as Result, t as AsyncResult } from ".
3
3
  import { t as StandardSchemaV1$1 } from "./standard-DBV730sF.js";
4
4
  import { r as FieldsOf } from "./block-fields-BE7pInWZ.js";
5
5
  import { $ as RecordRef } from "./types-DFdg_4yN.js";
6
- import { Ct as Events, D as BlockEventPattern, T as BlockEvent, bt as EventMap, k as BlockEventsMatching, o as EventHub, wt as MergedEventMap, xt as EventMapOf } from "./events-vcqenSYU.js";
6
+ import { Ct as Events, D as BlockEventPattern, T as BlockEvent, bt as EventMap, k as BlockEventsMatching, o as EventHub, wt as MergedEventMap, xt as EventMapOf } from "./events-Cc9DDQWH.js";
7
7
  import { n as Logger } from "./logger-DWVYUmwi.js";
8
- import { i as CredentialRef, o as CredentialToken, r as CredentialProvider } from "./provider-CqwEOLCA.js";
8
+ import { i as CredentialRef, o as CredentialToken, r as CredentialProvider } from "./provider-ClrIplXa.js";
9
9
  import { a as BlockTenantOptions, n as BlockOptions, r as BlockTemporalOptions } from "./block-helpers-CRpAHrp_.js";
10
10
  import { r as DbTransportSource, t as BlockTransport } from "./block-transport-DWZSJrwN.js";
11
11
  import { a as BlockTransportMiddleware, n as BlockHooks } from "./block-hooks-DZN2w69m.js";
@@ -13,10 +13,10 @@ import { f as AiFiles, y as UploadClaimStorage } from "./types-Dr9wZgNy.js";
13
13
  import { g as JobHandler } from "./types-Czq9Xtpa.js";
14
14
  import { t as BlockOptionsSchema } from "./options-BTmaRzx2.js";
15
15
  import { t as Author } from "./block-authors-DzXLUiIq.js";
16
- import { d as BlockInstanceSurface } from "./define-Lf6rI2QN.js";
16
+ import { d as BlockInstanceSurface } from "./define-BLP6XtoL.js";
17
17
  import { A as TtlPreset, C as TransformOptions, j as StorageApi, l as ImageTransform } from "./bucket-vc-QRrva.js";
18
18
  import { i as FieldSpec, n as TableSchema, o as TableSchemaSpec } from "./table-schema-BlF6k62Q.js";
19
- import { i as EventSink } from "./cloud-event-CzZTJkXv.js";
19
+ import { i as EventSink } from "./cloud-event-DcJwder2.js";
20
20
  import { g as Workflows } from "./workflows-B0ZPAQu0.js";
21
21
  import { StandardSchemaV1 } from "@standard-schema/spec";
22
22
  //#region src/core/entity-naming.d.ts