better-supabase 0.45.0 → 0.46.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 (471) hide show
  1. package/dist/{access-sql-BHat-brX.js → access-sql-8In-gFRf.js} +15 -2
  2. package/dist/{adapter-C0C4jIwI.js → adapter-t7V4k_rU.js} +10 -7
  3. package/dist/{agents-DxhGxwDS.d.ts → agents-D81UAnah.d.ts} +1 -1
  4. package/dist/{ai-chat-LHWztFya.d.ts → ai-chat-BBJvSano.d.ts} +1 -1
  5. package/dist/{ai-schedules-BP0PBKhY.d.ts → ai-schedules-D9mYwQdO.d.ts} +5 -2
  6. package/dist/ai-sdk/agents/index.d.ts +6 -6
  7. package/dist/ai-sdk/batches/index.d.ts +1 -1
  8. package/dist/ai-sdk/chat/index.d.ts +2 -2
  9. package/dist/ai-sdk/embeddings/index.d.ts +2 -2
  10. package/dist/ai-sdk/index.d.ts +2 -2
  11. package/dist/ai-sdk/mcp/index.d.ts +3 -3
  12. package/dist/ai-sdk/memory/index.d.ts +2 -2
  13. package/dist/ai-sdk/memory/index.js +1 -1
  14. package/dist/ai-sdk/workflow/index.d.ts +3 -3
  15. package/dist/{api-CgO8Gin7.d.ts → api-Bxhw2FD2.d.ts} +4 -4
  16. package/dist/{api-DXCaMM2S.js → api-DzqXnR6X.js} +1 -1
  17. package/dist/{api-keys-DINjcAaY.d.ts → api-keys-ClEIzcc3.d.ts} +1 -1
  18. package/dist/{app-tables-Dg9lERHb.d.ts → app-tables-HqT8E90s.d.ts} +1 -1
  19. package/dist/{approvals-CoBe9E2b.d.ts → approvals-lmHzZSgF.d.ts} +1 -1
  20. package/dist/{assistant-DMaZZFps.d.ts → assistant-ewdCgSQn.d.ts} +2 -2
  21. package/dist/astro/index.d.ts +5 -5
  22. package/dist/astro/index.js +4 -4
  23. package/dist/{authorization-CcWVJSsN.d.ts → authorization-CFs44tM2.d.ts} +145 -19
  24. package/dist/{authorization-hooks-u2Z18CAM.d.ts → authorization-hooks-yUgoV4Q7.d.ts} +1 -1
  25. package/dist/better-result/index.d.ts +2 -2
  26. package/dist/{bind-BieIoT6r.d.ts → bind-CUxWEh27.d.ts} +4 -4
  27. package/dist/{block-env-YzSHv579.d.ts → block-env-DddTzDut.d.ts} +4 -4
  28. package/dist/{block-subjects-CTIsFATg.js → block-subjects-y1RNnlLz.js} +1 -1
  29. package/dist/{block-tables-D-UjSTXa.d.ts → block-tables-BNwRNU_D.d.ts} +1 -1
  30. package/dist/blocks/access-requests/index.d.ts +2 -2
  31. package/dist/blocks/activities/index.d.ts +3 -3
  32. package/dist/blocks/agents/index.d.ts +3 -3
  33. package/dist/blocks/ai-cache/index.d.ts +1 -1
  34. package/dist/blocks/ai-chat/index.d.ts +6 -6
  35. package/dist/blocks/ai-files/index.d.ts +1 -1
  36. package/dist/blocks/ai-keys/index.d.ts +3 -3
  37. package/dist/blocks/ai-schedules/index.d.ts +2 -2
  38. package/dist/blocks/announcements/index.d.ts +5 -5
  39. package/dist/blocks/api-keys/index.d.ts +2 -2
  40. package/dist/blocks/approvals/index.d.ts +3 -3
  41. package/dist/blocks/assets/index.d.ts +2 -2
  42. package/dist/blocks/assignment/index.d.ts +3 -3
  43. package/dist/blocks/attachments/index.d.ts +46 -4
  44. package/dist/blocks/attachments/index.js +55 -3
  45. package/dist/blocks/audit/index.d.ts +7 -7
  46. package/dist/blocks/audit/index.js +1 -1
  47. package/dist/blocks/automations/index.d.ts +18 -16
  48. package/dist/blocks/billable-time/index.d.ts +2 -2
  49. package/dist/blocks/billing/index.d.ts +5 -5
  50. package/dist/blocks/bookings/index.d.ts +3 -3
  51. package/dist/blocks/bulk/index.d.ts +2 -2
  52. package/dist/blocks/calendar/index.d.ts +3 -3
  53. package/dist/blocks/catalog/index.d.ts +2 -2
  54. package/dist/blocks/channels/index.d.ts +3 -3
  55. package/dist/blocks/collections/index.d.ts +3 -3
  56. package/dist/blocks/comments/index.d.ts +5 -5
  57. package/dist/blocks/compliance/index.d.ts +11 -11
  58. package/dist/blocks/connectors/index.d.ts +3 -3
  59. package/dist/blocks/contacts/index.d.ts +4 -4
  60. package/dist/blocks/content/index.d.ts +2 -2
  61. package/dist/blocks/contracts/index.d.ts +2 -2
  62. package/dist/blocks/courses/index.d.ts +2 -2
  63. package/dist/blocks/created-by/index.d.ts +1 -1
  64. package/dist/blocks/custom-fields/index.d.ts +2 -2
  65. package/dist/blocks/data-lifecycle/index.d.ts +25 -8
  66. package/dist/blocks/data-lifecycle/index.js +16 -2
  67. package/dist/blocks/deals/index.d.ts +3 -3
  68. package/dist/blocks/dispatch/index.d.ts +2 -2
  69. package/dist/blocks/documents/index.d.ts +2 -2
  70. package/dist/blocks/domains/index.d.ts +2 -2
  71. package/dist/blocks/donations/index.d.ts +2 -2
  72. package/dist/blocks/drive/index.d.ts +221 -8
  73. package/dist/blocks/drive/index.js +269 -19
  74. package/dist/blocks/employees/index.d.ts +4 -4
  75. package/dist/blocks/enrichment/index.d.ts +3 -3
  76. package/dist/blocks/enrollments/index.d.ts +2 -2
  77. package/dist/blocks/entitlements/index.d.ts +3 -3
  78. package/dist/blocks/expenses/index.d.ts +2 -2
  79. package/dist/blocks/field-history/index.d.ts +3 -3
  80. package/dist/blocks/flags/index.d.ts +2 -2
  81. package/dist/blocks/forecasts/index.d.ts +3 -3
  82. package/dist/blocks/forms/index.d.ts +3 -3
  83. package/dist/blocks/goals/index.d.ts +1 -1
  84. package/dist/blocks/guests/index.d.ts +2 -2
  85. package/dist/blocks/hiring/index.d.ts +3 -3
  86. package/dist/blocks/identities/index.d.ts +2 -2
  87. package/dist/blocks/imports/index.d.ts +2 -2
  88. package/dist/blocks/inbox/index.d.ts +6 -6
  89. package/dist/blocks/incidents/index.d.ts +2 -2
  90. package/dist/blocks/index.d.ts +155 -5
  91. package/dist/blocks/index.js +19 -1
  92. package/dist/blocks/inventory/index.d.ts +2 -2
  93. package/dist/blocks/invoices/index.d.ts +4 -3
  94. package/dist/blocks/invoices/index.js +3 -2
  95. package/dist/blocks/knowledge/index.d.ts +3 -3
  96. package/dist/blocks/knowledge/index.js +1 -1
  97. package/dist/blocks/lead-scoring/index.d.ts +1 -1
  98. package/dist/blocks/leases/index.d.ts +2 -2
  99. package/dist/blocks/leave/index.d.ts +2 -2
  100. package/dist/blocks/ledger/index.d.ts +2 -2
  101. package/dist/blocks/mail-sync/index.d.ts +3 -3
  102. package/dist/blocks/memberships/index.d.ts +1 -1
  103. package/dist/blocks/memory/index.d.ts +3 -3
  104. package/dist/blocks/memory/index.js +1 -1
  105. package/dist/blocks/messaging/index.d.ts +7 -7
  106. package/dist/blocks/metrics/index.d.ts +2 -2
  107. package/dist/blocks/mfa/index.d.ts +2 -2
  108. package/dist/blocks/moderation/index.d.ts +2 -2
  109. package/dist/blocks/notifications/index.d.ts +13 -9
  110. package/dist/blocks/notifications/index.js +2 -0
  111. package/dist/blocks/numbering/index.d.ts +2 -2
  112. package/dist/blocks/oauth-server/index.d.ts +2 -2
  113. package/dist/blocks/onboarding/index.d.ts +2 -2
  114. package/dist/blocks/orders/index.d.ts +3 -3
  115. package/dist/blocks/organizations/index.d.ts +4 -4
  116. package/dist/blocks/outbox/index.d.ts +2 -2
  117. package/dist/blocks/passes/index.d.ts +2 -2
  118. package/dist/blocks/permissions/index.d.ts +5 -4
  119. package/dist/blocks/permissions/index.js +3 -2
  120. package/dist/blocks/pipelines/index.d.ts +3 -3
  121. package/dist/blocks/posts/index.d.ts +2 -2
  122. package/dist/blocks/profiles/index.d.ts +1 -1
  123. package/dist/blocks/promotions/index.d.ts +2 -2
  124. package/dist/blocks/push/index.d.ts +4 -4
  125. package/dist/blocks/qualifications/index.d.ts +256 -0
  126. package/dist/blocks/qualifications/index.js +303 -0
  127. package/dist/blocks/queue/index.d.ts +8 -103
  128. package/dist/blocks/queue/index.js +9 -3
  129. package/dist/blocks/quotes/index.d.ts +3 -3
  130. package/dist/blocks/rank/index.d.ts +1 -1
  131. package/dist/blocks/reactions/index.d.ts +5 -5
  132. package/dist/blocks/relations/index.d.ts +2 -2
  133. package/dist/blocks/reminders/index.d.ts +3 -3
  134. package/dist/blocks/reviews/index.d.ts +2 -2
  135. package/dist/blocks/risks/index.d.ts +303 -0
  136. package/dist/blocks/risks/index.js +376 -0
  137. package/dist/blocks/saved-views/index.d.ts +6 -6
  138. package/dist/blocks/scores/index.d.ts +2 -2
  139. package/dist/blocks/search/index.d.ts +4 -4
  140. package/dist/blocks/security-events/index.d.ts +3 -3
  141. package/dist/blocks/segments/index.d.ts +4 -4
  142. package/dist/blocks/sequences/index.d.ts +2 -2
  143. package/dist/blocks/service-accounts/index.d.ts +3 -3
  144. package/dist/blocks/sessions/index.d.ts +2 -2
  145. package/dist/blocks/settings/index.d.ts +3 -3
  146. package/dist/blocks/share-links/index.d.ts +29 -4
  147. package/dist/blocks/share-links/index.js +37 -4
  148. package/dist/blocks/shifts/index.d.ts +334 -0
  149. package/dist/blocks/shifts/index.js +451 -0
  150. package/dist/blocks/shipments/index.d.ts +3 -3
  151. package/dist/blocks/signatures/index.d.ts +2 -2
  152. package/dist/blocks/signing-keys/index.d.ts +2 -2
  153. package/dist/blocks/sla/index.d.ts +3 -3
  154. package/dist/blocks/sso/index.d.ts +3 -3
  155. package/dist/blocks/state-machine/index.d.ts +2 -2
  156. package/dist/blocks/subjects/index.d.ts +13 -5
  157. package/dist/blocks/subjects/index.js +114 -5
  158. package/dist/blocks/tags/index.d.ts +3 -3
  159. package/dist/blocks/tasks/index.d.ts +5 -5
  160. package/dist/blocks/teams/index.d.ts +2 -2
  161. package/dist/blocks/templates/index.d.ts +5 -5
  162. package/dist/blocks/time-tracking/index.d.ts +3 -3
  163. package/dist/blocks/timeline/index.d.ts +6 -6
  164. package/dist/blocks/timeline/index.js +1 -1
  165. package/dist/blocks/trash/index.d.ts +2 -2
  166. package/dist/blocks/undo/index.d.ts +2 -2
  167. package/dist/blocks/updated-at/index.d.ts +1 -1
  168. package/dist/blocks/usage/index.d.ts +2 -2
  169. package/dist/blocks/vercel-marketplace/index.d.ts +2 -2
  170. package/dist/blocks/versions/index.d.ts +2 -2
  171. package/dist/blocks/waitlist/index.d.ts +2 -2
  172. package/dist/blocks/webhooks/index.d.ts +6 -6
  173. package/dist/blocks/webhooks/index.js +2 -1
  174. package/dist/blocks/workflow-editor/index.d.ts +8 -8
  175. package/dist/blocks/workflow-editor/index.js +1 -1
  176. package/dist/blocks/workflows/index.d.ts +6 -6
  177. package/dist/{cache-tags-DrywUP3I.d.ts → cache-tags-DDWP8yDs.d.ts} +2 -2
  178. package/dist/{channel-B_kufDZy.d.ts → channel-DW9iIWgu.d.ts} +3 -1
  179. package/dist/chat-sdk/index.d.ts +2 -2
  180. package/dist/claims/index.d.ts +5 -5
  181. package/dist/claims/index.js +1 -1
  182. package/dist/cli/{add-DcLNy2oN.js → add-B6TTIKos.js} +23 -5
  183. package/dist/cli/{add-B5Gq34wX.js → add-CYH9OE6d.js} +13 -13
  184. package/dist/cli/add-DsgNHrEH.js +1 -0
  185. package/dist/cli/{app-table-files-CcGWy0qX.js → app-table-files-Br1VQgjE.js} +3 -3
  186. package/dist/cli/{app-tables-RbPMD2M3.js → app-tables-FRO1l5rT.js} +2 -2
  187. package/dist/cli/{backfill-BJterqcQ.js → backfill-BgGBBidH.js} +4 -4
  188. package/dist/cli/bin.js +1 -1
  189. package/dist/cli/{blocks-DsAwI_4v.js → blocks-CX_172Ja.js} +1 -1
  190. package/dist/cli/{blocks-BBALfFv-.js → blocks-DZrlz-13.js} +2 -2
  191. package/dist/cli/{cache-DRb1xVPh.js → cache-BgiLj67N.js} +1 -1
  192. package/dist/cli/{codemod-Cpd4DnrL.js → codemod-C86T5p1T.js} +97 -13
  193. package/dist/cli/{command-67WobzTC.js → command-DtQ7P9XP.js} +6 -0
  194. package/dist/cli/{completion-C3nMZgUZ.js → completion-9tK4vX1l.js} +2 -2
  195. package/dist/cli/{completion-Dm0S3ub0.js → completion-DUnYq3GC.js} +2 -2
  196. package/dist/cli/{completion-DSrus7H1.js → completion-djG61QR0.js} +1 -1
  197. package/dist/cli/{config-CGVmcEZa.js → config-05wlBDsJ.js} +1 -1
  198. package/dist/cli/{config-Dy-BAGel.js → config-Cb4swJ2X.js} +32 -10
  199. package/dist/cli/{config-cbK-wiNs.js → config-CwcsseeT.js} +1 -1
  200. package/dist/cli/{content-mapper-D0riSMnP.js → content-mapper-DIO-tycM.js} +2 -2
  201. package/dist/cli/{db-BCVXzXDA.js → db-BND9MSu1.js} +3 -3
  202. package/dist/cli/{doctor-CHmX2gau.js → doctor-BqS2dAI-.js} +98 -21
  203. package/dist/cli/{env-CCT-dMFm.js → env-2zOK0skq.js} +1 -1
  204. package/dist/cli/env-NHlaYmXG.js +1 -0
  205. package/dist/cli/{gen-DB0svRc8.js → gen-CygGjwk4.js} +16 -16
  206. package/dist/cli/index.d.ts +1 -1
  207. package/dist/cli/index.js +8 -8
  208. package/dist/cli/{init-B4fQNe4C.js → init-BMDuL671.js} +10 -10
  209. package/dist/cli/{keys-Dj5sJNj7.js → keys-BUl10CEQ.js} +1 -1
  210. package/dist/cli/{live-Bft5EE70.js → live-BRhu6mk8.js} +2 -2
  211. package/dist/cli/{mcp-BKcS-LZw.js → mcp-DzfSUgqc.js} +3 -3
  212. package/dist/cli/{metadata-CgKNmMsc.js → metadata-Ao_uwhbL.js} +3 -3
  213. package/dist/cli/{migrate-ehxT23Gg.js → migrate-BySeyvYY.js} +2 -2
  214. package/dist/cli/{migration-safety-D2gG-dDs.js → migration-safety-CtSYqXjZ.js} +2 -2
  215. package/dist/cli/{migrations-CQ1Sgz_X.js → migrations-Cnf7TlYZ.js} +2 -2
  216. package/dist/cli/{module-migration-BOPJUkIX.js → module-migration-CKKOcrG0.js} +2 -2
  217. package/dist/cli/{moved-CY0yDtAr.js → moved-QZ-btdFz.js} +1 -1
  218. package/dist/cli/{parse-yAC-NFMq.js → parse-Bd_CRjbn.js} +1 -1
  219. package/dist/cli/{powersync-BTari5WF.js → powersync-BeeW0i26.js} +168 -67
  220. package/dist/cli/powersync-miOelRmt.js +1 -0
  221. package/dist/cli/{print-BMJnlJ8k.js → print-Sdb6L0v4.js} +2 -2
  222. package/dist/cli/{providers-BNZ-OqMI.js → providers-BlkYmOf-.js} +1 -1
  223. package/dist/cli/{prune-workflows-BG55npqs.js → prune-workflows-iRTaOxbs.js} +4 -4
  224. package/dist/cli/{remove-BIqGDE0A.js → remove-DvzSG08w.js} +6 -6
  225. package/dist/cli/{render-BIC4Wctz.js → render-svtBPq7R.js} +118 -18
  226. package/dist/cli/{run-C_slJx8m.js → run-BHhVGtd_.js} +46 -45
  227. package/dist/cli/{run-BJ4_rmHy.js → run-CnafzCVh.js} +14 -14
  228. package/dist/cli/{run-DX4X7xqV.js → run-WD6LyrAZ.js} +2 -2
  229. package/dist/cli/{seed-0r_0aD8_.js → seed-Bc_q0nFf.js} +12 -4
  230. package/dist/cli/seed-DT_k-CGR.js +1 -0
  231. package/dist/cli/{shared-DhpBDjRa.js → shared-By7_hqFX.js} +1 -1
  232. package/dist/cli/{skills-B5p6bDwe.js → skills-CvEA4xdj.js} +1 -1
  233. package/dist/cli/{snapshot-CMJksw-t.js → snapshot-T8fVRXqA.js} +3 -3
  234. package/dist/cli/{source-args-CgCX8KUJ.js → source-args-BiySywDB.js} +1 -1
  235. package/dist/cli/{source-CJilfcq-.js → source-xL7qYX0r.js} +1 -1
  236. package/dist/cli/{spec-CnjHA0br.js → spec-BH7BDCnA.js} +1 -1
  237. package/dist/cli/{spec-Br9cWMbU.js → spec-CU_OO1Gq.js} +3 -3
  238. package/dist/cli/{sql-layout-BCiEl_G5.js → sql-layout-C_-LNpAw.js} +2 -2
  239. package/dist/cli/{stack-CQXLe5j0.js → stack-DM3keIfh.js} +1 -1
  240. package/dist/cli/{sync-Bulv1zyy.js → sync-Bl4Kf4_T.js} +4 -4
  241. package/dist/cli/{table-BAR0cLmU.js → table-DocogEpr.js} +1 -1
  242. package/dist/cli/{upgrade-DTBvTAAV.js → upgrade-BLi83wT-.js} +5 -5
  243. package/dist/cli/{upgrade-C8fiTE3r.js → upgrade-kce809Am.js} +3 -3
  244. package/dist/cli/{version-hhuwVLKj.js → version-D8HDt2fH.js} +1 -1
  245. package/dist/client/index.d.ts +7 -6
  246. package/dist/client/index.js +2 -1
  247. package/dist/client/native/index.d.ts +6 -5
  248. package/dist/client/native/index.js +2 -1
  249. package/dist/{cloud-event-LTUGgt6D.d.ts → cloud-event-Dxy5EZVG.d.ts} +1 -1
  250. package/dist/commerce/index.d.ts +1 -1
  251. package/dist/{composite-BCUNxZCd.d.ts → composite-DNDFvcQc.d.ts} +6 -6
  252. package/dist/{composite-C3lLpMys.js → composite-c7POXFs3.js} +2 -2
  253. package/dist/config/index.d.ts +4 -4
  254. package/dist/config/index.js +4 -4
  255. package/dist/{config-HOXkrND2.js → config--zZjnkYA.js} +1 -1
  256. package/dist/{config-DA_R9O_y.js → config-CAbv8kRz.js} +21 -8
  257. package/dist/{connectors-DTxDzUzD.d.ts → connectors-BQtx-Llh.d.ts} +1 -1
  258. package/dist/{context-BJK9_ppk.d.ts → context-Lhw7PgdA.d.ts} +52 -8
  259. package/dist/contract/index.d.ts +8 -8
  260. package/dist/{controller-TplPQG5m.d.ts → controller-CouRuczb.d.ts} +1 -1
  261. package/dist/{controller-y1kSMuCU.js → controller-DxzV9X72.js} +1 -1
  262. package/dist/{conversion-DwDBNeWT.d.ts → conversion-G2ODS617.d.ts} +1 -1
  263. package/dist/create/index.d.ts +3 -3
  264. package/dist/create/index.js +3 -3
  265. package/dist/create/lite/index.d.ts +3 -3
  266. package/dist/create/lite/index.js +3 -3
  267. package/dist/credentials/index.d.ts +3 -3
  268. package/dist/{data-hooks-BToeAcQ_.js → data-hooks-DDEPFoWv.js} +44 -3
  269. package/dist/{define-DXQHQ2Qy.d.ts → db-blocks-Dgu-HpFb.d.ts} +296 -296
  270. package/dist/{define-block-tFQZ8936.d.ts → define-block-eiBbZ3mM.d.ts} +357 -357
  271. package/dist/{delegation-C2rLpkHO.js → delegation-C0EQp3ss.js} +1 -1
  272. package/dist/edge/index.d.ts +8 -8
  273. package/dist/edge/index.js +6 -6
  274. package/dist/elysia/index.d.ts +1 -1
  275. package/dist/elysia/index.js +1 -1
  276. package/dist/{email-BRm6wMWQ.d.ts → email-_X1-FD9h.d.ts} +1 -1
  277. package/dist/{embeddings-LhxY3bUD.d.ts → embeddings-DJs1UeQt.d.ts} +1 -1
  278. package/dist/{ended-CpyW7_0h.d.ts → ended-XY1q20JM.d.ts} +1 -1
  279. package/dist/{entitlements-SqfT4gk_.d.ts → entitlements-D_vas3Yl.d.ts} +2 -2
  280. package/dist/{envelope-CapD-JtH.js → envelope-CSb4c7xn.js} +1 -1
  281. package/dist/eve/index.d.ts +5 -5
  282. package/dist/eve/index.js +1 -1
  283. package/dist/{eve-DmbLji3M.d.ts → eve-Ck586Yfh.d.ts} +2 -2
  284. package/dist/events/index.d.ts +3 -3
  285. package/dist/{events-BrgD2StJ.d.ts → events-sK2YdMhE.d.ts} +37 -2
  286. package/dist/{executor-DlAtlYxY.d.ts → executor-DAQLygMX.d.ts} +2 -2
  287. package/dist/{executor-kfUaLlQr.d.ts → executor-h4VT8TNz.d.ts} +1 -1
  288. package/dist/expo/index.d.ts +5 -5
  289. package/dist/expo/index.js +3 -3
  290. package/dist/{field-errors-DyWpuH1q.d.ts → field-errors-BFLehpue.d.ts} +22 -10
  291. package/dist/flags-sdk/index.d.ts +1 -1
  292. package/dist/{framework-DydnLrMk.js → framework-DvtET86P.js} +1 -1
  293. package/dist/{framework-C8HFM1bX.d.ts → framework-v4jPUZJ-.d.ts} +7 -7
  294. package/dist/{gateway-DQirTFOg.d.ts → gateway-BEDpSlLD.d.ts} +1 -1
  295. package/dist/h3/index.d.ts +1 -1
  296. package/dist/h3/index.js +1 -1
  297. package/dist/h3/v1/index.d.ts +1 -1
  298. package/dist/h3/v1/index.js +1 -1
  299. package/dist/hono/index.d.ts +10 -10
  300. package/dist/hono/index.js +6 -6
  301. package/dist/{index-0erPlzHd.d.ts → index-BRFHDjCG.d.ts} +19 -5
  302. package/dist/{index-vGZZjCW7.d.ts → index-BoVZxiin.d.ts} +12 -12
  303. package/dist/{index-Brzh6XAW.d.ts → index-CJfDiWQf.d.ts} +4 -2
  304. package/dist/{index-BjN_IQQd.d.ts → index-Cc2q2eaq.d.ts} +18 -5
  305. package/dist/{index-DCyNdhEC.d.ts → index-D2gezcOV.d.ts} +3 -3
  306. package/dist/{index-CwDdMCdH.d.ts → index-D430cWV7.d.ts} +1 -1
  307. package/dist/{index-DcmDWojr.d.ts → index-DYSGzEkY.d.ts} +1 -1
  308. package/dist/{index-DkmorC1b.d.ts → index-eZ8oW-DV.d.ts} +4 -4
  309. package/dist/{index-Ddjcn6i7.d.ts → index-nfYh7R5C.d.ts} +5 -5
  310. package/dist/{index-x2YRPbXr.d.ts → index-wRn2y3XS.d.ts} +5 -5
  311. package/dist/index.d.ts +5 -4
  312. package/dist/index.js +3 -2
  313. package/dist/{instances-DGtu3S0m.js → instances-BUhbreNT.js} +1554 -225
  314. package/dist/{kit-C1GVbhtg.d.ts → kit-CmO46iau.d.ts} +3 -3
  315. package/dist/{knowledge-CCOSNGJp.d.ts → knowledge-BnKrvPT6.d.ts} +22 -4
  316. package/dist/{knowledge-CJnZOaix.js → knowledge-BxFkHBTc.js} +14 -3
  317. package/dist/list/index.d.ts +1 -1
  318. package/dist/{list-query-CF-5EUVX.d.ts → list-query-CnD6uNzs.d.ts} +1 -1
  319. package/dist/mapper/bin.js +7 -7
  320. package/dist/mcp/index.d.ts +3 -3
  321. package/dist/mcp/index.js +4 -4
  322. package/dist/mcp/sdk/index.d.ts +18 -7
  323. package/dist/mcp/sdk/index.js +21 -12
  324. package/dist/nestjs/index.d.ts +2 -2
  325. package/dist/nestjs/index.js +1 -1
  326. package/dist/next/client/index.d.ts +1 -1
  327. package/dist/next/index.d.ts +22 -22
  328. package/dist/next/index.js +7 -7
  329. package/dist/node/index.d.ts +2 -2
  330. package/dist/node/index.js +1 -1
  331. package/dist/{operations-CkgwsViz.d.ts → operations-kNq7cGI7.d.ts} +1 -1
  332. package/dist/{options-CJR59q8s.js → options-B1efbeOv.js} +5 -1
  333. package/dist/options-B3dQnXgp.js +6 -0
  334. package/dist/{options-ByxOMSXu.js → options-BEv5xfPg.js} +3 -1
  335. package/dist/options-BZ5TzeFN.js +12 -0
  336. package/dist/options-CKMLVUel.js +8 -0
  337. package/dist/options-CgIKw9s6.js +9 -0
  338. package/dist/options-D1-2o7kO.d.ts +43 -0
  339. package/dist/{options-CjocPkX1.js → options-EdzV163Y.js} +3 -0
  340. package/dist/orpc/index.d.ts +26 -15
  341. package/dist/orpc/index.js +29 -9
  342. package/dist/otel/index.d.ts +2 -2
  343. package/dist/otel/index.js +5 -5
  344. package/dist/{outbox-DL2737I0.d.ts → outbox-CcISFwgE.d.ts} +2 -2
  345. package/dist/{permissions-vbtGrV26.d.ts → permissions-XrrAYkXm.d.ts} +1 -1
  346. package/dist/{permissions-controller-B4uI5IPH.js → permissions-controller-DYm6sF8k.js} +6 -2
  347. package/dist/{pool-DfDolmmm.d.ts → pool-CQuNr7Nq.d.ts} +1 -1
  348. package/dist/{ports-ClyPs0q6.d.ts → ports-CvOsUmuD.d.ts} +1 -1
  349. package/dist/postgres/index.d.ts +1 -1
  350. package/dist/powersync/index.d.ts +55 -13
  351. package/dist/powersync/index.js +85 -11
  352. package/dist/preset/index.d.ts +3 -3
  353. package/dist/preset/index.js +3 -3
  354. package/dist/{preset-His18bto.js → preset-DFZn_TLi.js} +2 -2
  355. package/dist/{project-D81NwLP6.js → project-BwmNYaZt.js} +5 -5
  356. package/dist/{provider-DxJWo8yD.d.ts → provider-CgYoyX_d.d.ts} +1 -1
  357. package/dist/{push-token-DMOeO8cU.d.ts → push-token-taE-3JNT.d.ts} +1 -1
  358. package/dist/query/index.d.ts +2 -2
  359. package/dist/query/index.js +30 -2
  360. package/dist/rate-limit/index.d.ts +2 -0
  361. package/dist/rate-limit/index.js +1 -0
  362. package/dist/rate-limit-BJyp7iAx.d.ts +109 -0
  363. package/dist/rate-limit-DLZWqcIS.js +94 -0
  364. package/dist/rate-limit-DyQbVEBE.js +123 -0
  365. package/dist/rate-limit-lGysIP9Z.d.ts +79 -0
  366. package/dist/react/index.d.ts +8 -8
  367. package/dist/react/index.js +2 -2
  368. package/dist/react/native/index.d.ts +3 -3
  369. package/dist/react/native/index.js +2 -1
  370. package/dist/react/server.d.ts +8 -8
  371. package/dist/react/server.js +2 -2
  372. package/dist/react/session.d.ts +2 -2
  373. package/dist/{react-DkGGh9FE.js → react-AC0iYStn.js} +13 -6
  374. package/dist/react-router/index.d.ts +5 -5
  375. package/dist/react-router/index.js +4 -4
  376. package/dist/realtime/index.d.ts +4 -4
  377. package/dist/realtime/index.js +1 -1
  378. package/dist/{record-form-BRtDkhLZ.d.ts → record-form-BAIG-cdw.d.ts} +1 -1
  379. package/dist/{record-type-oQxekQTX.js → record-type-BID6K9Vk.js} +1 -1
  380. package/dist/records/index.d.ts +8 -8
  381. package/dist/records/index.js +4 -4
  382. package/dist/{refusal-DjCQCcCj.d.ts → refusal-D19i-uE3.d.ts} +2 -2
  383. package/dist/{refusal-B9w5Bapa.js → refusal-lgW07wlX.js} +1 -1
  384. package/dist/renames-BPU-FSIn.d.ts +36 -0
  385. package/dist/renames-BoN2IHI7.js +161 -0
  386. package/dist/{resolve-CKJMUYRc.d.ts → resolve-C_VNGFjz.d.ts} +1 -1
  387. package/dist/{resource-CrmhNagD.js → resource--iTRgH4N.js} +1 -1
  388. package/dist/{resource-execute-DZeWkyIU.d.ts → resource-execute-CoadG2g7.d.ts} +1 -1
  389. package/dist/{resource-types-D3gmBOeY.d.ts → resource-types-e7vzPJ7t.d.ts} +2 -2
  390. package/dist/{resources-CSjwmcFs.d.ts → resources-DSqe-GbC.d.ts} +1 -1
  391. package/dist/{resources-B2i_nIgJ.js → resources-DqEg3HBk.js} +1 -1
  392. package/dist/{respond-DxS_8bzC.d.ts → respond-C8rBdIBZ.d.ts} +1 -1
  393. package/dist/server/index.d.ts +22 -22
  394. package/dist/server/index.js +7 -7
  395. package/dist/{server-types-DCC-dWKF.d.ts → server-types-Djx3Eb2G.d.ts} +9 -9
  396. package/dist/{session-Ca4clB30.d.ts → session-BgxLbDYu.d.ts} +5 -5
  397. package/dist/{session-status-CYtwZBi5.d.ts → session-status-C4g0QoB_.d.ts} +2 -2
  398. package/dist/{sign-in-BUiy6unD.js → sign-in-Cl7vhgRn.js} +1 -1
  399. package/dist/solid/index.d.ts +11 -11
  400. package/dist/solid/index.js +3 -3
  401. package/dist/solid-start/index.d.ts +5 -5
  402. package/dist/solid-start/index.js +4 -4
  403. package/dist/spec/index.d.ts +2 -2
  404. package/dist/spec/index.js +2 -2
  405. package/dist/{spec-pins-Dd1Qj3Sj.js → spec-pins-C-1kGh8u.js} +1 -1
  406. package/dist/{spec-pins-CRJEZYBW.d.ts → spec-pins-DGbByPMT.d.ts} +1 -1
  407. package/dist/sql/index.d.ts +6 -6
  408. package/dist/sql/index.js +5 -5
  409. package/dist/{sql-D3ihagTr.js → sql-TpANPmq7.js} +8961 -2083
  410. package/dist/sqlite/index.d.ts +1 -1
  411. package/dist/ssr/index.d.ts +4 -4
  412. package/dist/storage/index.js +1 -1
  413. package/dist/{subject-readers-nnYmRpv8.d.ts → subject-readers-yxQ3r1qw.d.ts} +1 -1
  414. package/dist/{subjects-BGwLJ3IB.d.ts → subjects-BpUQpZhk.d.ts} +30 -2
  415. package/dist/subjects-D3BE9Q8J.d.ts +173 -0
  416. package/dist/{support-BzXcdRLG.d.ts → support-B1n33r32.d.ts} +4 -4
  417. package/dist/{support-view-DNZh8-wA.d.ts → support-view-CkN2Wr1r.d.ts} +1 -1
  418. package/dist/svelte/index.d.ts +10 -10
  419. package/dist/svelte/index.js +3 -3
  420. package/dist/sveltekit/index.d.ts +6 -6
  421. package/dist/sveltekit/index.js +4 -4
  422. package/dist/{tags-CpFIpRw8.d.ts → tags-BCjWVMKO.d.ts} +1 -1
  423. package/dist/tanstack-db/index.d.ts +1 -1
  424. package/dist/tanstack-start/index.d.ts +5 -5
  425. package/dist/tanstack-start/index.js +4 -4
  426. package/dist/{tenant-DyZZDYmm.d.ts → tenant-CBWFqFy0.d.ts} +1 -1
  427. package/dist/testing/index.d.ts +35 -31
  428. package/dist/testing/index.js +5 -4
  429. package/dist/{timeline-Bs-FGMIJ.js → timeline-B3pBRGv9.js} +1 -1
  430. package/dist/{timeline-Df8GMPkZ.d.ts → timeline-Cy7XP2pq.d.ts} +3 -3
  431. package/dist/{topic-BtoL1fKf.js → topic-BC3p90lS.js} +1 -1
  432. package/dist/{topic-B4fSui6P.d.ts → topic-BWJAJkF3.d.ts} +3 -3
  433. package/dist/{types-mYxPduXR.d.ts → types-B5qUEVWI.d.ts} +22 -16
  434. package/dist/{types-DJfGy-40.d.ts → types-B_2C7bqG.d.ts} +1 -1
  435. package/dist/{types-BeXhugiI.d.ts → types-Dlir1n-q.d.ts} +2 -2
  436. package/dist/{types-D6GlpLD9.d.ts → types-sBLcw65Z.d.ts} +2 -2
  437. package/dist/{vault-nYFV6WUD.d.ts → vault-BVLUu_Ph.d.ts} +1 -1
  438. package/dist/vercel-connect/index.d.ts +1 -1
  439. package/dist/vercel-sandbox/index.d.ts +1 -1
  440. package/dist/{verify-DxTccsBh.d.ts → verify-DlKjgAEj.d.ts} +1 -1
  441. package/dist/{view-DwXy8N6Y.d.ts → view-GSwP0y5o.d.ts} +1 -1
  442. package/dist/vue/index.d.ts +11 -11
  443. package/dist/vue/index.js +3 -3
  444. package/dist/{watch-topic-DShzD8ul.d.ts → watch-topic-BfaaK5SW.d.ts} +1 -1
  445. package/dist/{rate-limit-BJ4EMdAy.js → webhook-inbox-C94C_zIV.js} +3 -119
  446. package/dist/workflow-sdk/builder/index.d.ts +3 -3
  447. package/dist/workflow-sdk/builder/index.js +1 -1
  448. package/dist/workflow-sdk/index.d.ts +1 -1
  449. package/dist/workflow-sdk/index.js +1 -1
  450. package/dist/workflow-sdk/world/index.d.ts +1 -1
  451. package/dist/workflow-sdk/world/index.js +1 -1
  452. package/dist/{workflow-sdk-q2jnEaAJ.js → workflow-sdk-CZa83j_U.js} +1 -1
  453. package/dist/{workflow-sdk-ClwzLwNe.d.ts → workflow-sdk-DiDsEArJ.d.ts} +2 -2
  454. package/dist/{workflow-sdk-Bps7tpOv.js → workflow-sdk-DmHaJHUL.js} +170 -115
  455. package/dist/{workflows-ZGDa9twb.d.ts → workflows-D1Ax0qSC.d.ts} +4 -4
  456. package/dist/yjs/index.d.ts +1 -1
  457. package/dist/yjs/index.js +1 -1
  458. package/package.json +17 -1
  459. package/schemas/config-v1.json +201 -2
  460. package/schemas/doctor-report-v1.json +2 -0
  461. package/skills/better-supabase/SKILL.md +2 -1
  462. package/skills/better-supabase/references/ui-recipes.md +1062 -15
  463. package/skills/better-supabase-api/SKILL.md +1 -1
  464. package/dist/cli/add-D_JV6V6k.js +0 -1
  465. package/dist/cli/env-AFfMXxWw.js +0 -1
  466. package/dist/cli/powersync-B8GWjT_L.js +0 -1
  467. package/dist/cli/seed-DX1NTTOK.js +0 -1
  468. package/dist/rate-limit-C89Yzwd9.d.ts +0 -48
  469. package/dist/rate-limit-DXJbLVg0.js +0 -48
  470. package/dist/subjects-DgP5x73R.d.ts +0 -86
  471. package/dist/{kit-CB3AfM9W.js → kit-C-uC7_aG.js} +1 -1
@@ -1,15 +1,15 @@
1
1
  import { b as DbError, f as Result } from "../result-DTOQRyGY.js";
2
2
  import { O as AnyFunctions, k as AnyModels } from "../types-CF5j7kOm.js";
3
- import { r as AuthState } from "../resolve-CKJMUYRc.js";
3
+ import { r as AuthState } from "../resolve-C_VNGFjz.js";
4
4
  import { i as ProblemDetails } from "../problem-NGBjN-TO.js";
5
- import { t as BetterSupabase } from "../define-DXQHQ2Qy.js";
6
- import { l as ServerOptions, o as ServerContext, r as BetterServer } from "../server-types-DCC-dWKF.js";
7
- import { i as MiddlewareOptions, r as GuardOptions } from "../respond-DxS_8bzC.js";
8
- import { c as ResourceLoaderContext, i as AuthorizeOptions } from "../kit-C1GVbhtg.js";
9
- import { a as ResourceHandler } from "../resource-types-D3gmBOeY.js";
5
+ import { s as BetterSupabase } from "../db-blocks-Dgu-HpFb.js";
6
+ import { l as ServerOptions, o as ServerContext, r as BetterServer } from "../server-types-Djx3Eb2G.js";
7
+ import { i as MiddlewareOptions, r as GuardOptions } from "../respond-C8rBdIBZ.js";
8
+ import { c as ResourceLoaderContext, i as AuthorizeOptions } from "../kit-CmO46iau.js";
9
+ import { a as ResourceHandler } from "../resource-types-e7vzPJ7t.js";
10
10
  import { t as Validated } from "../shared-DsBcvj6q.js";
11
- import { i as RouteRateLimitRule, n as RateLimitVerdict, r as RateLimiter, t as RateLimitRouteOptions } from "../rate-limit-C89Yzwd9.js";
12
- import { t as Api } from "../api-CgO8Gin7.js";
11
+ import { a as RateLimitVerdict, c as RouteRateLimitRule, i as RateLimitRouteOptions, l as SingleRateLimitOptions, n as MultiRateLimiter, o as RateLimiter, r as RateLimitAllVerdict, s as RouteRateLimitHit, t as MultiRateLimitOptions } from "../rate-limit-lGysIP9Z.js";
12
+ import { t as Api } from "../api-Bxhw2FD2.js";
13
13
  import { AnyEntry, Contributions } from "@supabase/middleware";
14
14
  import { AnySchema, BuilderWithMiddlewares, DecoratedMiddleware, DecoratedProcedure, MetaPlugin, ORPCError, Schema } from "@orpc/server";
15
15
  /** The route `router()` gives one operation of the API model. */
@@ -136,6 +136,15 @@ export interface OrpcRateLimitInput<TContext extends OrpcRequestContext> {
136
136
  readonly path: readonly string[];
137
137
  readonly request: Request;
138
138
  }
139
+ /** What `rateLimit()` takes beyond the limiter options. */
140
+ export interface OrpcRateLimitOptions {
141
+ /**
142
+ * The error code a refused call throws. When the procedure declares it in its
143
+ * `errors`, the error comes from that declaration, so typed clients see it as
144
+ * defined. Default: `TOO_MANY_REQUESTS`.
145
+ */
146
+ readonly code?: string;
147
+ }
139
148
  /** The middleware `rateLimit()` returns; it adds nothing to `context`. */
140
149
  export type OrpcRateLimitMiddleware<TContext extends OrpcRequestContext> = DecoratedMiddleware<TContext, Record<never, never>, unknown, any, Record<never, never>>;
141
150
  /** Guard and authorize options of `middleware()` and `authed()`. */
@@ -176,13 +185,15 @@ export interface BetterOrpc<M extends AnyModels, F extends AnyFunctions, E, C =
176
185
  */
177
186
  fetchHandler(handler: OrpcFetchHandler, options?: OrpcFetchOptions): (request: Request, env?: unknown, executionContext?: OrpcExecutionContext) => Promise<Response>;
178
187
  /**
179
- * Counts a hit per call with a rate limiter, such as `createRateLimit()`.
180
- * `fetchHandler` adds the `RateLimit` (and with `rule`, `RateLimit-Policy`)
181
- * fields to the response; a refused call throws `TOO_MANY_REQUESTS` and the
182
- * response carries `Retry-After`. Use it after `middleware()` to key on
183
- * `context.auth`.
188
+ * Counts a hit per call with a rate limiter, such as `createRateLimit()`
189
+ * (`key` and `scope`) or its `checkAll` (`hits`, several limits in one round
190
+ * trip). The `RateLimit` (and with a rule, `RateLimit-Policy`) fields go to
191
+ * `context.resHeaders` under oRPC's `ResponseHeadersPlugin`, and otherwise
192
+ * `fetchHandler` adds them. A refused call throws `TOO_MANY_REQUESTS` (or
193
+ * `code`) and the response carries `Retry-After`. Use it after `middleware()`
194
+ * to key on `context.auth`.
184
195
  */
185
- rateLimit<TContext extends OrpcRequestContext = OrpcRequestContext>(options: RateLimitRouteOptions<OrpcRateLimitInput<TContext>>): OrpcRateLimitMiddleware<TContext>;
196
+ rateLimit<TContext extends OrpcRequestContext = OrpcRequestContext>(options: RateLimitRouteOptions<OrpcRateLimitInput<TContext>> & OrpcRateLimitOptions): OrpcRateLimitMiddleware<TContext>;
186
197
  /** A `Result` (or `AsyncResult`) as data, throwing an `ORPCError` on failure. */
187
198
  unwrap<T>(value: Result<T> | PromiseLike<Result<T>>): Promise<T>;
188
199
  /** Plain values pass through; thrown `DbException`s become `ORPCError`s. */
@@ -209,4 +220,4 @@ export interface BetterOrpc<M extends AnyModels, F extends AnyFunctions, E, C =
209
220
  export declare function orpcCode(error: DbError): string;
210
221
  /** ORPC integration: middleware adding the caller's repositories to `context`. */
211
222
  export declare function createOrpc<M extends AnyModels, D, F extends AnyFunctions, E, C = unknown, P = unknown, B = unknown>(betterSupabase: BetterSupabase<M, D, F, E, C, P, B>, options?: OrpcOptions): BetterOrpc<M, F, E, C, P, B>;
212
- export type { ApiRoute, ApiRouter, ApiRouterOptions, GuardOptions, MiddlewareOptions, OrpcHandlerLike, RateLimitRouteOptions, RateLimitVerdict, RateLimiter, RouteRateLimitRule, ToOrpcOptions };
223
+ export type { ApiRoute, ApiRouter, ApiRouterOptions, GuardOptions, MiddlewareOptions, MultiRateLimitOptions, MultiRateLimiter, OrpcHandlerLike, RateLimitAllVerdict, RateLimitRouteOptions, RateLimitVerdict, RateLimiter, RouteRateLimitHit, RouteRateLimitRule, SingleRateLimitOptions, ToOrpcOptions };
@@ -8,12 +8,12 @@ import { t as TABLE_VERBS } from "../resource-DQ4kIBpa.js";
8
8
  import { t as callWithInput } from "../block-method-DIbWG4Mj.js";
9
9
  import { t as tenantOf } from "../tenant-Beqd7TTq.js";
10
10
  import { i as toSession } from "../view-Ch0Qtr36.js";
11
- import { c as extendServer, n as flushEvents, s as createServer } from "../adapter-C0C4jIwI.js";
11
+ import { c as extendServer, n as flushEvents, s as createServer } from "../adapter-t7V4k_rU.js";
12
12
  import { r as refreshFor } from "../request-kind-tNDM5Z_o.js";
13
13
  import { r as checkPermission } from "../authorizer-BtIPDO-c.js";
14
- import { c as defaultExpose, p as settle, s as assertCookieRefresh, t as authorizeCaller, u as guard } from "../kit-CB3AfM9W.js";
15
- import { r as contextOf, t as defineResource } from "../resource-CrmhNagD.js";
16
- import { t as rateLimitGate } from "../rate-limit-DXJbLVg0.js";
14
+ import { c as defaultExpose, p as settle, s as assertCookieRefresh, t as authorizeCaller, u as guard } from "../kit-C-uC7_aG.js";
15
+ import { r as contextOf, t as defineResource } from "../resource--iTRgH4N.js";
16
+ import { t as rateLimitGate } from "../rate-limit-DLZWqcIS.js";
17
17
  import { bufferRequest, pipeline, seedContext } from "@supabase/middleware";
18
18
  import { COMMON_ERROR_STATUS_MAP, ORPCError, os } from "@orpc/server";
19
19
  // src/orpc/router.ts
@@ -204,6 +204,12 @@ function requestFromHeaders(headers, url = "http://localhost/") {
204
204
  built.set(headers, request);
205
205
  return request;
206
206
  }
207
+ /** `resHeaders` from oRPC's `ResponseHeadersPlugin`, when the handler uses it. */
208
+ function responseHeadersOf(context) {
209
+ if (!("resHeaders" in context)) return;
210
+ const { resHeaders } = context;
211
+ return resHeaders instanceof Headers ? resHeaders : void 0;
212
+ }
207
213
  /** The context's request, built from its headers when it has none. */
208
214
  function requestOf(context) {
209
215
  return "request" in context ? context.request : requestFromHeaders(context.headers, context.url);
@@ -215,6 +221,11 @@ function createOrpc(betterSupabase, options = {}) {
215
221
  const tenantClaim = claimsOf(betterSupabase.meta).tenant;
216
222
  const contexts = /* @__PURE__ */ new WeakMap();
217
223
  const limits = /* @__PURE__ */ new WeakMap();
224
+ const keptHeaders = (request) => {
225
+ const kept = limits.get(request) ?? new Headers();
226
+ limits.set(request, kept);
227
+ return kept;
228
+ };
218
229
  const toOrpcError = (error) => {
219
230
  const problem = toProblem(error, { expose });
220
231
  return new ORPCError(orpcCode(error), {
@@ -262,7 +273,17 @@ function createOrpc(betterSupabase, options = {}) {
262
273
  middleware,
263
274
  rateLimit(rateLimitOptions) {
264
275
  const gate = rateLimitGate(rateLimitOptions);
265
- return os.$context().middleware(async ({ context, path, next }) => {
276
+ const code = rateLimitOptions.code ?? "TOO_MANY_REQUESTS";
277
+ const refusal = (error, errors) => {
278
+ const fallback = toOrpcError(error);
279
+ if (error.code !== "rate_limited" || !(code in errors)) return fallback;
280
+ const declared = errors[code];
281
+ return declared === void 0 ? fallback : declared({
282
+ message: fallback.message,
283
+ data: fallback.data
284
+ });
285
+ };
286
+ return os.$context().middleware(async ({ context, path, next, errors }) => {
266
287
  const request = requestOf(context);
267
288
  const outcome = await gate({
268
289
  context,
@@ -270,10 +291,9 @@ function createOrpc(betterSupabase, options = {}) {
270
291
  request
271
292
  });
272
293
  if (outcome.kind === "skip") return next();
273
- const kept = limits.get(request) ?? new Headers();
274
- for (const [name, value] of outcome.headers) kept.set(name, value);
275
- limits.set(request, kept);
276
- if (outcome.kind === "deny") throw toOrpcError(outcome.error);
294
+ const target = responseHeadersOf(context) ?? keptHeaders(request);
295
+ for (const [name, value] of outcome.headers) target.set(name, value);
296
+ if (outcome.kind === "deny") throw refusal(outcome.error, errors);
277
297
  return next();
278
298
  });
279
299
  },
@@ -1,6 +1,6 @@
1
1
  import { Nt as Plugin } from "../types-CF5j7kOm.js";
2
- import { o as EventHub } from "../events-BrgD2StJ.js";
3
- import { t as SPEC_PINS } from "../spec-pins-CRJEZYBW.js";
2
+ import { o as EventHub } from "../events-sK2YdMhE.js";
3
+ import { t as SPEC_PINS } from "../spec-pins-DGbByPMT.js";
4
4
  import { Attributes, Meter, Tracer } from "@opentelemetry/api";
5
5
  export declare const INSTRUMENTATION_NAME = "better-supabase";
6
6
  /** OpenTelemetry semantic conventions version the attributes follow. */
@@ -1,5 +1,5 @@
1
1
  import { r as definePlugin } from "../plugin-Ca2qBiFZ.js";
2
- import { t as SPEC_PINS } from "../spec-pins-Dd1Qj3Sj.js";
2
+ import { t as SPEC_PINS } from "../spec-pins-C-1kGh8u.js";
3
3
  import { i as blockEventAttributes } from "../block-events-Bp6GPIBN.js";
4
4
  import { SpanKind, SpanStatusCode, context, metrics, propagation, trace } from "@opentelemetry/api";
5
5
  // src/otel/index.ts
@@ -39,9 +39,9 @@ function systemOf(executor) {
39
39
  * ```
40
40
  */
41
41
  function otel(options = {}) {
42
- const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.45.0");
42
+ const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.46.0");
43
43
  let histogram;
44
- if (options.metrics !== false) histogram = (options.meter ?? metrics.getMeter("better-supabase", "0.45.0")).createHistogram("db.client.operation.duration", {
44
+ if (options.metrics !== false) histogram = (options.meter ?? metrics.getMeter("better-supabase", "0.46.0")).createHistogram("db.client.operation.duration", {
45
45
  unit: "s",
46
46
  description: "Duration of database client operations.",
47
47
  advice: { explicitBucketBoundaries: [
@@ -218,7 +218,7 @@ function otel(options = {}) {
218
218
  * `betterSupabase.events`. Returns a function that stops listening.
219
219
  */
220
220
  function traceAuth(betterSupabase, options = {}) {
221
- const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.45.0");
221
+ const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.46.0");
222
222
  const offAuth = betterSupabase.events.on("auth", (event) => {
223
223
  const span = tracer.startSpan("auth.resolve", {
224
224
  kind: SpanKind.INTERNAL,
@@ -256,7 +256,7 @@ function traceAuth(betterSupabase, options = {}) {
256
256
  * an error status. Returns a function that stops listening.
257
257
  */
258
258
  function traceBlockEvents(betterSupabase, options = {}) {
259
- const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.45.0");
259
+ const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.46.0");
260
260
  return betterSupabase.events.on("block", (event) => {
261
261
  const attributes = {
262
262
  ...options.attributes,
@@ -4,8 +4,8 @@ import { n as Logger } from "./logger-0LfhvwE4.js";
4
4
  import { i as CursorPageOptions, n as BlockOptions } from "./block-helpers-DzIR3Ob8.js";
5
5
  import { n as BlockHooks } from "./block-hooks-D9NKzUqW.js";
6
6
  import { t as BlockProblemOptions } from "./problem-NGBjN-TO.js";
7
- import { i as EventSink, t as CloudEvent } from "./cloud-event-LTUGgt6D.js";
8
- import { g as SubscriberPolicy, i as AuthorizationHooks } from "./authorization-hooks-u2Z18CAM.js";
7
+ import { i as EventSink, t as CloudEvent } from "./cloud-event-Dxy5EZVG.js";
8
+ import { g as SubscriberPolicy, i as AuthorizationHooks } from "./authorization-hooks-yUgoV4Q7.js";
9
9
  /** One row of the outbox, as `outbox_claim` and `outbox_history` return it. */
10
10
  interface OutboxEvent {
11
11
  /** The cursor value: increases with every event. */
@@ -1,4 +1,4 @@
1
- import { o as ClaimsRecord, s as ClaimsSource } from "./entitlements-SqfT4gk_.js";
1
+ import { o as ClaimsRecord, s as ClaimsSource } from "./entitlements-D_vas3Yl.js";
2
2
  interface PermissionsOfOptions {
3
3
  /**
4
4
  * The claim holding `{ [tenantId]: string[] }`, as
@@ -1,11 +1,15 @@
1
+ import { s as currentPermissionKeys, u as upgradePermissionKey } from "./renames-BoN2IHI7.js";
1
2
  // src/blocks/permissions/permissions-controller.ts
3
+ const grants = (granted, wanted) => granted === "*" || granted === wanted || granted.endsWith(".*") && wanted.startsWith(granted.slice(0, -1));
2
4
  /**
3
5
  * Whether a granted key covers a wanted one: the same rule as the SQL
4
6
  * `permission_matches`, where `*` grants every key and `prefix.*` every key
5
- * under `prefix`.
7
+ * under `prefix`. A key the 0.46 convention renamed matches as its new keys on
8
+ * either side until the next minor, and a wanted one is logged once.
6
9
  */
7
10
  function permissionMatches(granted, wanted) {
8
- return granted === "*" || granted === wanted || granted.endsWith(".*") && wanted.startsWith(granted.slice(0, -1));
11
+ const wants = upgradePermissionKey(wanted);
12
+ return currentPermissionKeys(granted).some((each) => wants.some((key) => grants(each, key)));
9
13
  }
10
14
  /**
11
15
  * Whether `set` holds `key`. UX only: RLS and the SQL functions check the key
@@ -1,5 +1,5 @@
1
1
  import { Vt as Executor } from "./types-CF5j7kOm.js";
2
- import { o as EventHub } from "./events-BrgD2StJ.js";
2
+ import { o as EventHub } from "./events-sK2YdMhE.js";
3
3
  import { n as Logger } from "./logger-0LfhvwE4.js";
4
4
  import { n as SqlClient } from "./executor-rs231gO_.js";
5
5
  /** The part of a `pg` pool client `createPostgres` uses. */
@@ -1,5 +1,5 @@
1
1
  import { t as AsyncResult } from "./result-DTOQRyGY.js";
2
- import { n as TopicPort } from "./watch-topic-DShzD8ul.js";
2
+ import { n as TopicPort } from "./watch-topic-BfaaK5SW.js";
3
3
  import { SupabaseClient } from "@supabase/supabase-js";
4
4
  /**
5
5
  * A string store: `localStorage` on the web (`webStorage()`), AsyncStorage,
@@ -1,7 +1,7 @@
1
1
  import { E as RawDbError } from "../result-DTOQRyGY.js";
2
2
  import { m as Operation } from "../types-CF5j7kOm.js";
3
3
  import { n as SqlClient, r as postgresExecutor, t as PostgresExecutorOptions } from "../executor-rs231gO_.js";
4
- import { a as PostgresTimeouts, c as createPostgres, i as PostgresOptions, n as PgPool, o as SessionOptions, r as PgPoolClient, s as SqlClaims, t as BetterPostgres } from "../pool-DfDolmmm.js";
4
+ import { a as PostgresTimeouts, c as createPostgres, i as PostgresOptions, n as PgPool, o as SessionOptions, r as PgPoolClient, s as SqlClaims, t as BetterPostgres } from "../pool-CQuNr7Nq.js";
5
5
  import { t as Compiler } from "../compiler-CJorTlU7.js";
6
6
  /** Node-postgres error fields to the shape `mapDbError` reads. */
7
7
  export declare function fromPgError(error: unknown): RawDbError | undefined;
@@ -2,9 +2,9 @@ import { f as Result } from "../result-DTOQRyGY.js";
2
2
  import { Vt as Executor } from "../types-CF5j7kOm.js";
3
3
  import { t as BlockTransport } from "../block-transport-Do7J4MsA.js";
4
4
  import { C as UploadRouteOptions, E as uploadRoute, S as UploadRoute, T as uploadOutcome, _ as UploadConnectorOptions, b as UploadOutcome, c as LocalTablesOption, d as CreateUploadRepository, f as CrudEntryLike, g as UploadConnector, h as RejectedStore, m as RejectedChange, n as DataEngine, p as CrudQueueLike, s as LiveEngineOptions, v as UploadErrorContext, w as createUploadConnector, x as UploadRepository, y as UploadFunction } from "../data-engine-ZcGeVz1i.js";
5
- import { n as TopicPort } from "../watch-topic-DShzD8ul.js";
6
- import { t as AuthSnapshot } from "../bind-BieIoT6r.js";
7
- import { C as quoteSqliteIdent, S as likeToGlob, _ as SqliteQuery, a as postgrestTimestamp, b as SqliteValue, c as sqliteCompiler, d as SqliteDecode, f as SqliteInsertPlan, g as SqlitePlan, h as SqliteNested, i as fromSqliteError, l as SqliteColumn, m as SqliteKeys, n as SqliteDatabaseLike, o as CheckSqliteOptions, p as SqliteKeyedPlan, r as SqliteExecutorOptions, s as checkSqlite, t as SqliteContextLike, u as SqliteCompilerOptions, v as SqliteReturning, w as sqliteValue, x as compileSqlite, y as SqliteSelectPlan } from "../executor-DlAtlYxY.js";
5
+ import { n as TopicPort } from "../watch-topic-BfaaK5SW.js";
6
+ import { t as AuthSnapshot } from "../bind-CUxWEh27.js";
7
+ import { C as quoteSqliteIdent, S as likeToGlob, _ as SqliteQuery, a as postgrestTimestamp, b as SqliteValue, c as sqliteCompiler, d as SqliteDecode, f as SqliteInsertPlan, g as SqlitePlan, h as SqliteNested, i as fromSqliteError, l as SqliteColumn, m as SqliteKeys, n as SqliteDatabaseLike, o as CheckSqliteOptions, p as SqliteKeyedPlan, r as SqliteExecutorOptions, s as checkSqlite, t as SqliteContextLike, u as SqliteCompilerOptions, v as SqliteReturning, w as sqliteValue, x as compileSqlite, y as SqliteSelectPlan } from "../executor-DAQLygMX.js";
8
8
  /** The part of PowerSync's `SyncStatus` the engine reads. */
9
9
  interface SyncStatusLike {
10
10
  readonly connected: boolean;
@@ -209,7 +209,7 @@ interface AttachmentQueueRoute extends UploadFunction {
209
209
  */
210
210
  export declare function attachmentQueueRoute(repository: CreateUploadRepository<never, never>, options?: AttachmentQueueRouteOptions): AttachmentQueueRoute;
211
211
  /** The notification functions the local transport answers from SQLite. */
212
- type LocalNotificationFunction = "get_notification" | "list_notifications" | "notification_page" | "notification_counts" | "mark_notifications_read" | "mark_notifications_unread" | "dismiss_notifications";
212
+ type LocalNotificationFunction = "get_notification" | "list_notifications" | "notification_page" | "notification_counts" | "mark_notifications_read" | "mark_notifications_unread" | "dismiss_notifications" | "list_notification_preferences" | "set_notification_preference";
213
213
  interface PowerSyncNotificationsOptions {
214
214
  /**
215
215
  * Where every other function goes, and every call when `local` is `false`:
@@ -218,11 +218,13 @@ interface PowerSyncNotificationsOptions {
218
218
  readonly server: BlockTransport;
219
219
  /**
220
220
  * The synced table names, as `powersync streams` wrote them into the client
221
- * schema. Default `notification_recipients` and `notification_events`.
221
+ * schema. Default `notification_recipients`, `notification_events` and
222
+ * `notification_preferences`.
222
223
  */
223
224
  readonly tables?: {
224
225
  readonly recipients?: string;
225
226
  readonly events?: string;
227
+ readonly preferences?: string;
226
228
  };
227
229
  /**
228
230
  * The tenant column, when `config.tenancy` renames it. Default
@@ -235,9 +237,11 @@ interface PowerSyncNotificationsOptions {
235
237
  /**
236
238
  * A block transport for the notifications module on PowerSync: the feed, its
237
239
  * counts and marking read, unread or dismissed run on the synced tables, so the
238
- * inbox works offline. Writes go into PowerSync's upload queue, which
239
- * `notificationRecipientsRoute` replays on the server. Every other function
240
- * (sending, preferences, resolving) goes to `server`.
240
+ * inbox works offline. Listing preferences and turning a type on or off on a
241
+ * channel work offline too. Writes go into PowerSync's upload queue, which
242
+ * `notificationRecipientsRoute` and `notificationPreferencesRoute` replay on
243
+ * the server. Every other function (sending, resolving, removing a preference
244
+ * with `enabled: null`) goes to `server`.
241
245
  *
242
246
  * ```ts
243
247
  * const notifications = createNotifications({
@@ -281,6 +285,38 @@ interface NotificationRecipientWrites {
281
285
  * ```
282
286
  */
283
287
  export declare function notificationRecipientsRoute(notifications: NotificationRecipientWrites): UploadFunction;
288
+ /** The upload route's notifications client for preferences: the server one. */
289
+ interface NotificationPreferenceWrites {
290
+ setPreference(input: {
291
+ readonly type: string;
292
+ readonly channel: string;
293
+ readonly enabled: boolean | null;
294
+ readonly tenant?: string;
295
+ }): PromiseLike<Result<unknown>>;
296
+ }
297
+ /**
298
+ * The upload route for `notification_preferences`: replays a local preference
299
+ * change through `set_notification_preference`, which sets the caller as the
300
+ * owner and checks the organization. An update carries only `enabled`, so the
301
+ * route reads the type, channel and organization from the local row.
302
+ *
303
+ * ```ts
304
+ * createUploadConnector({
305
+ * tables: {
306
+ * notification_preferences: notificationPreferencesRoute(
307
+ * serverNotifications,
308
+ * powersync,
309
+ * ),
310
+ * },
311
+ * });
312
+ * ```
313
+ */
314
+ export declare function notificationPreferencesRoute(notifications: NotificationPreferenceWrites, database: PowerSyncDatabaseLike, options?: {
315
+ /** The synced table name. Default `notification_preferences`. */
316
+ readonly table?: string;
317
+ /** The tenant column. Default `organization_id`. */
318
+ readonly tenantColumn?: string;
319
+ }): UploadFunction;
284
320
  /**
285
321
  * A topic port for the notifications feed on PowerSync: the feed reads again
286
322
  * when the synced notification tables change, from a sync or a local write,
@@ -396,10 +432,8 @@ interface PowerSyncTeamsOptions {
396
432
  * });
397
433
  * ```
398
434
  *
399
- * The synced teams are the ones the signed-in user belongs to (the `powersync
400
- * streams` query filters by `auth.user_id()`), so `list` offline returns those,
401
- * not every team the user may read, and each team's `memberIds` holds only the
402
- * synced member rows.
435
+ * The synced teams are every team in the organizations the signed-in user is an
436
+ * active member of, with their members, the same rows RLS lets the user read.
403
437
  */
404
438
  export declare function powersyncTeamsTransport(database: PowerSyncDatabaseLike, options: PowerSyncTeamsOptions): BlockTransport;
405
439
  /** The upload routes' teams client: the server one, not the local transport. */
@@ -449,6 +483,12 @@ interface PowerSyncProfilesOptions {
449
483
  readonly table?: string;
450
484
  /** Function names, when the instance renames them (`blocks.<name>.entities`). */
451
485
  readonly functions?: Partial<Record<LocalProfileFunction, string>>;
486
+ /**
487
+ * The signed-in user's id, such as `() => session?.user.id`. The local reads
488
+ * pick that user's row, so a row another user left behind before the next
489
+ * sync is never returned. Without it, the transport reads the first row.
490
+ */
491
+ readonly userId?: () => string | null | undefined | PromiseLike<string | null | undefined>;
452
492
  }
453
493
  /**
454
494
  * A block transport for the profiles block on PowerSync: `profiles.mine()` and
@@ -460,6 +500,8 @@ interface PowerSyncProfilesOptions {
460
500
  * const profiles = createProfiles({
461
501
  * transport: powersyncProfilesTransport(powersync, {
462
502
  * server: rpcTransport(supabase),
503
+ * userId: async () =>
504
+ * (await supabase.auth.getSession()).data.session?.user.id,
463
505
  * }),
464
506
  * });
465
507
  * ```
@@ -487,4 +529,4 @@ interface ProfileWrites {
487
529
  * ```
488
530
  */
489
531
  export declare function profilesRoute(profiles: ProfileWrites): UploadFunction;
490
- export { type AttachmentPathRow, type AttachmentQueueRoute, type AttachmentQueueRouteOptions, type AuthSourceLike, type AuthSync, type CheckSqliteOptions, type CreateUploadRepository, type CrudEntryLike, type CrudQueueLike, type LocalMembershipFunction, type LocalNotificationFunction, type LocalProfileFunction, type LocalTeamFunction, type MembershipWrites, type NotificationRecipientWrites, type PowerSyncDatabaseLike, type PowerSyncEngineOptions, type PowerSyncExecutorOptions, type PowerSyncMembershipsOptions, type PowerSyncNotificationsOptions, type PowerSyncProfilesOptions, type PowerSyncTeamsOptions, type ProfileWrites, type RejectedChange, type RejectedStore, type SqliteColumn, type SqliteCompilerOptions, type SqliteContextLike, type SqliteDecode, type SqliteInsertPlan, type SqliteKeyedPlan, type SqliteKeys, type SqliteNested, type SqlitePlan, type SqliteQuery, type SqliteReturning, type SqliteSelectPlan, type SqliteValue, type SyncClaims, type SyncStatusLike, type SyncWithAuthOptions, type SyncedDatabaseLike, type TeamWrites, type UploadConnector, type UploadConnectorOptions, type UploadErrorContext, type UploadFunction, type UploadOutcome, type UploadRepository, type UploadRoute, type UploadRouteOptions, checkSqlite, compileSqlite, createUploadConnector, fromSqliteError, likeToGlob, postgrestTimestamp, quoteSqliteIdent, sqliteCompiler, sqliteValue, uploadOutcome, uploadRoute };
532
+ export { type AttachmentPathRow, type AttachmentQueueRoute, type AttachmentQueueRouteOptions, type AuthSourceLike, type AuthSync, type CheckSqliteOptions, type CreateUploadRepository, type CrudEntryLike, type CrudQueueLike, type LocalMembershipFunction, type LocalNotificationFunction, type LocalProfileFunction, type LocalTeamFunction, type MembershipWrites, type NotificationPreferenceWrites, type NotificationRecipientWrites, type PowerSyncDatabaseLike, type PowerSyncEngineOptions, type PowerSyncExecutorOptions, type PowerSyncMembershipsOptions, type PowerSyncNotificationsOptions, type PowerSyncProfilesOptions, type PowerSyncTeamsOptions, type ProfileWrites, type RejectedChange, type RejectedStore, type SqliteColumn, type SqliteCompilerOptions, type SqliteContextLike, type SqliteDecode, type SqliteInsertPlan, type SqliteKeyedPlan, type SqliteKeys, type SqliteNested, type SqlitePlan, type SqliteQuery, type SqliteReturning, type SqliteSelectPlan, type SqliteValue, type SyncClaims, type SyncStatusLike, type SyncWithAuthOptions, type SyncedDatabaseLike, type TeamWrites, type UploadConnector, type UploadConnectorOptions, type UploadErrorContext, type UploadFunction, type UploadOutcome, type UploadRepository, type UploadRoute, type UploadRouteOptions, checkSqlite, compileSqlite, createUploadConnector, fromSqliteError, likeToGlob, postgrestTimestamp, quoteSqliteIdent, sqliteCompiler, sqliteValue, uploadOutcome, uploadRoute };
@@ -442,7 +442,9 @@ const FUNCTIONS$3 = [
442
442
  "notification_counts",
443
443
  "mark_notifications_read",
444
444
  "mark_notifications_unread",
445
- "dismiss_notifications"
445
+ "dismiss_notifications",
446
+ "list_notification_preferences",
447
+ "set_notification_preference"
446
448
  ];
447
449
  /** Event columns the item reads by name; any other column becomes a field. */
448
450
  const EVENT_COLUMNS = /* @__PURE__ */ new Set([
@@ -463,9 +465,11 @@ const EVENT_COLUMNS = /* @__PURE__ */ new Set([
463
465
  /**
464
466
  * A block transport for the notifications module on PowerSync: the feed, its
465
467
  * counts and marking read, unread or dismissed run on the synced tables, so the
466
- * inbox works offline. Writes go into PowerSync's upload queue, which
467
- * `notificationRecipientsRoute` replays on the server. Every other function
468
- * (sending, preferences, resolving) goes to `server`.
468
+ * inbox works offline. Listing preferences and turning a type on or off on a
469
+ * channel work offline too. Writes go into PowerSync's upload queue, which
470
+ * `notificationRecipientsRoute` and `notificationPreferencesRoute` replay on
471
+ * the server. Every other function (sending, resolving, removing a preference
472
+ * with `enabled: null`) goes to `server`.
469
473
  *
470
474
  * ```ts
471
475
  * const notifications = createNotifications({
@@ -481,6 +485,7 @@ const EVENT_COLUMNS = /* @__PURE__ */ new Set([
481
485
  function powersyncNotificationsTransport(database, options) {
482
486
  const recipients = quoteSqliteIdent(options.tables?.recipients ?? "notification_recipients");
483
487
  const events = quoteSqliteIdent(options.tables?.events ?? "notification_events");
488
+ const preferences = quoteSqliteIdent(options.tables?.preferences ?? "notification_preferences");
484
489
  const tenant = options.tenantColumn ?? "organization_id";
485
490
  const tenantColumn = quoteSqliteIdent(tenant);
486
491
  const byName = new Map(FUNCTIONS$3.map((fn) => [options.functions?.[fn] ?? fn, fn]));
@@ -604,12 +609,40 @@ function powersyncNotificationsTransport(database, options) {
604
609
  case "mark_notifications_read": return mark("read_at = ?", 1, "rc.read_at IS NULL AND rc.dismissed_at IS NULL", args);
605
610
  case "mark_notifications_unread": return mark("read_at = NULL", 0, "rc.read_at IS NOT NULL AND rc.dismissed_at IS NULL", args);
606
611
  case "dismiss_notifications": return mark("dismissed_at = ?, read_at = coalesce(read_at, ?)", 2, "rc.dismissed_at IS NULL", { ids: args["ids"] });
612
+ case "list_notification_preferences": {
613
+ const scoped = typeof args["tenant"] === "string";
614
+ return (await database.getAll(`SELECT * FROM ${preferences}${scoped ? ` WHERE ${tenantColumn} IS NULL OR ${tenantColumn} = ?` : ""} ORDER BY ${tenantColumn} IS NOT NULL, ${tenantColumn}, type, channel`, scoped ? [args["tenant"]] : [])).map((row) => ({
615
+ type: row["type"],
616
+ channel: row["channel"],
617
+ enabled: row["enabled"] === 1 || row["enabled"] === true,
618
+ tenant: row[tenant] ?? null
619
+ }));
620
+ }
621
+ case "set_notification_preference": {
622
+ const scope = typeof args["tenant"] === "string" ? args["tenant"] : null;
623
+ const enabled = args["enabled"] === true ? 1 : 0;
624
+ await database.writeTransaction(async (tx) => {
625
+ const [found] = await tx.getAll(`SELECT id FROM ${preferences} WHERE type = ? AND channel = ? AND ${tenantColumn} IS ?`, [
626
+ args["type"],
627
+ args["channel"],
628
+ scope
629
+ ]);
630
+ await (found === void 0 ? tx.execute(`INSERT INTO ${preferences} (id, ${tenantColumn}, type, channel, enabled, created_at) VALUES (uuid(), ?, ?, ?, ?, ?)`, [
631
+ scope,
632
+ args["type"],
633
+ args["channel"],
634
+ enabled,
635
+ (/* @__PURE__ */ new Date()).toISOString()
636
+ ]) : tx.execute(`UPDATE ${preferences} SET enabled = ? WHERE id = ?`, [enabled, found.id]));
637
+ });
638
+ return null;
639
+ }
607
640
  default: throw new TypeError(`Unhandled notification function ${String(fn)}`);
608
641
  }
609
642
  };
610
643
  return { call(schema, fn, args) {
611
644
  const handled = byName.get(fn);
612
- return handled === void 0 ? options.server.call(schema, fn, args) : local(handled, args);
645
+ return handled === void 0 || handled === "set_notification_preference" && typeof args["enabled"] !== "boolean" ? options.server.call(schema, fn, args) : local(handled, args);
613
646
  } };
614
647
  }
615
648
  function counts(all, args) {
@@ -653,6 +686,43 @@ function notificationRecipientsRoute(notifications) {
653
686
  };
654
687
  }
655
688
  /**
689
+ * The upload route for `notification_preferences`: replays a local preference
690
+ * change through `set_notification_preference`, which sets the caller as the
691
+ * owner and checks the organization. An update carries only `enabled`, so the
692
+ * route reads the type, channel and organization from the local row.
693
+ *
694
+ * ```ts
695
+ * createUploadConnector({
696
+ * tables: {
697
+ * notification_preferences: notificationPreferencesRoute(
698
+ * serverNotifications,
699
+ * powersync,
700
+ * ),
701
+ * },
702
+ * });
703
+ * ```
704
+ */
705
+ function notificationPreferencesRoute(notifications, database, options = {}) {
706
+ const table = quoteSqliteIdent(options.table ?? "notification_preferences");
707
+ const tenant = options.tenantColumn ?? "organization_id";
708
+ return async (entry) => {
709
+ if (entry.op === "DELETE") return err(dbError("unsupported", "notification_preferences takes inserts and updates; remove a preference online with enabled: null"));
710
+ const [local] = entry.op === "PATCH" ? await database.getAll(`SELECT * FROM ${table} WHERE id = ?`, [entry.id]) : [];
711
+ const row = {
712
+ ...local,
713
+ ...entry.opData
714
+ };
715
+ const scope = row[tenant];
716
+ if (typeof row["type"] !== "string" || typeof row["channel"] !== "string") return err(dbError("unsupported", "notification_preferences: the change names no type and channel"));
717
+ return notifications.setPreference({
718
+ type: row["type"],
719
+ channel: row["channel"],
720
+ enabled: row["enabled"] === 1 || row["enabled"] === true,
721
+ ...typeof scope === "string" ? { tenant: scope } : {}
722
+ });
723
+ };
724
+ }
725
+ /**
656
726
  * A topic port for the notifications feed on PowerSync: the feed reads again
657
727
  * when the synced notification tables change, from a sync or a local write,
658
728
  * instead of on a Realtime broadcast.
@@ -829,10 +899,8 @@ const isRow$1 = (value) => typeof value === "object" && value !== null && !Array
829
899
  * });
830
900
  * ```
831
901
  *
832
- * The synced teams are the ones the signed-in user belongs to (the `powersync
833
- * streams` query filters by `auth.user_id()`), so `list` offline returns those,
834
- * not every team the user may read, and each team's `memberIds` holds only the
835
- * synced member rows.
902
+ * The synced teams are every team in the organizations the signed-in user is an
903
+ * active member of, with their members, the same rows RLS lets the user read.
836
904
  */
837
905
  function powersyncTeamsTransport(database, options) {
838
906
  const teams = quoteSqliteIdent(options.tables?.teams ?? "teams");
@@ -986,6 +1054,8 @@ const isRow = (value) => typeof value === "object" && value !== null && !Array.i
986
1054
  * const profiles = createProfiles({
987
1055
  * transport: powersyncProfilesTransport(powersync, {
988
1056
  * server: rpcTransport(supabase),
1057
+ * userId: async () =>
1058
+ * (await supabase.auth.getSession()).data.session?.user.id,
989
1059
  * }),
990
1060
  * });
991
1061
  * ```
@@ -998,7 +1068,11 @@ const isRow = (value) => typeof value === "object" && value !== null && !Array.i
998
1068
  function powersyncProfilesTransport(database, options) {
999
1069
  const table = quoteSqliteIdent(options.table ?? "profiles");
1000
1070
  const byName = new Map(FUNCTIONS.map((fn) => [options.functions?.[fn] ?? fn, fn]));
1001
- const mine = async () => (await database.getAll(`SELECT * FROM ${table} LIMIT 1`))[0];
1071
+ const mine = async () => {
1072
+ if (options.userId === void 0) return (await database.getAll(`SELECT * FROM ${table} LIMIT 1`))[0];
1073
+ const id = await options.userId();
1074
+ return id === null || id === void 0 ? void 0 : (await database.getAll(`SELECT * FROM ${table} WHERE id = ?`, [id]))[0];
1075
+ };
1002
1076
  const local = async (fn, args) => {
1003
1077
  switch (fn) {
1004
1078
  case "my_profile": {
@@ -1067,4 +1141,4 @@ function parsed(value) {
1067
1141
  return value;
1068
1142
  }
1069
1143
  }
1070
- export { attachmentQueueRoute, checkSqlite, claimsFingerprint, compileSqlite, createUploadConnector, fromSqliteError, likeToGlob, membershipsRoute, notificationRecipientsRoute, postgrestTimestamp, powersyncEngine, powersyncExecutor, powersyncMembershipsTransport, powersyncNotificationsTransport, powersyncProfilesTransport, powersyncTeamsTransport, powersyncTopicPort, profilesRoute, quoteSqliteIdent, sqliteCompiler, sqliteValue, syncWithAuth, teamMembersRoute, teamsRoute, uploadOutcome, uploadRoute };
1144
+ export { attachmentQueueRoute, checkSqlite, claimsFingerprint, compileSqlite, createUploadConnector, fromSqliteError, likeToGlob, membershipsRoute, notificationPreferencesRoute, notificationRecipientsRoute, postgrestTimestamp, powersyncEngine, powersyncExecutor, powersyncMembershipsTransport, powersyncNotificationsTransport, powersyncProfilesTransport, powersyncTeamsTransport, powersyncTopicPort, profilesRoute, quoteSqliteIdent, sqliteCompiler, sqliteValue, syncWithAuth, teamMembersRoute, teamsRoute, uploadOutcome, uploadRoute };
@@ -1,4 +1,4 @@
1
- import { $n as PresetGroup, Ai as PresetValueInfo, At as PresetConflict, Ci as PresetConventions, Ct as ConfigConventions, Di as PresetFramework, Dt as expandPreset, Ei as PresetFieldValue, Et as conventionConfig, Ft as presetBlockConflict, Gn as presetFromSpec, It as resolvePreset, Jn as DEFAULT_PRESET_NAME, Kn as presetOfSpec, Mi as presetField, Mt as ResolvedPreset, Ni as presetValueLabel, Nt as ResolvedPresetBlock, Oi as PresetPlatforms, Ot as presetConfig, Pt as listNames, Qn as PRESET_NAMES, Si as PresetAccess, Ti as PresetFieldKey, Tt as PresetInput, Wn as PresetSpec, Xn as PRESETS, Yn as NamedPreset, Zn as PRESET_GROUPS, _i as CONVENTION_FIELDS, _r as AppColumnFormat, bi as PRESET_TENANT_NAMES, di as INSTANCE_NAME, er as PresetName, fi as instancePrefix, gi as PresetGlueItem, hi as PresetCatalogManifest, ji as integrationsForFramework, jt as PresetIntegration, ki as PresetScope, kt as presetOf, mi as PresetCatalogBlock, nr as isPresetName, pi as PresetCatalog, qn as presetSpec, rr as namedPreset, tr as defaultPreset, ui as CORE_BLOCKS, ur as APP_COLUMN_FORMATS, vi as DEFAULT_CONVENTIONS, wi as PresetField, wt as ExpandedConfig, xi as Preset, yi as PRESET_FRAMEWORKS } from "../context-BJK9_ppk.js";
2
- import { $ as readDesignFile, A as DesignFile, B as designFileSource, C as diffAppTables, D as DESIGN_FILE, E as CreateDesign, F as MAX_DESIGN_CODE_LENGTH, G as isDesignCode, H as designOf, I as createQuery, J as presetApplyCommand, K as parseDesign, L as createUrl, M as DesignParseIssue, N as DesignParseResult, O as DESIGN_FORMAT, P as DesignTooLongError, Q as presetKey, R as decodeDesign, S as DiffOptions, T as CREATE_URL, U as designSchema, V as designFormat, W as encodeDesign, X as presetConfigSource, Y as presetArgumentOf, Z as presetInstallCommand, _ as glueCommand, a as blockRequires, b as DesignChange, c as installedBlocks, d as instancesOf, et as safeDesignFileSource, f as presetInstances, g as PROVIDER_COMMENT, h as withoutInstance, i as blockEntities, it as PRESET_CATALOG, j as DesignParseError, k as DesignErrorCode, l as instanceBlock, m as withInstance, n as BlockInstance, nt as appDefaultError, o as canAddInstance, p as withEntityName, q as presetAndDesignOf, r as PresetInstance, rt as isAppDefault, s as entityName, t as BlockEntity, tt as safeParseDesign, u as instanceNameProblem, v as presetBlocksSource, w as diffDesigns, x as DesignChangeKind, y as presetGlue, z as designConfig } from "../index-DcmDWojr.js";
3
- import { i as appReservedColumns, n as appIdentifierError, r as appNameLengthError, t as APP_NAME_MAX } from "../app-tables-Dg9lERHb.js";
1
+ import { $n as NamedPreset, Ai as PresetFieldValue, At as presetOf, Ci as PRESET_FRAMEWORKS, Di as PresetConventions, Dt as conventionConfig, Ei as PresetAccess, Et as PresetInput, Fi as integrationsForFramework, Ft as listNames, Ii as presetField, It as presetBlockConflict, Jn as PresetSpec, Li as presetValueLabel, Lt as resolvePreset, Mi as PresetPlatforms, Mt as PresetIntegration, Ni as PresetScope, Nt as ResolvedPreset, Oi as PresetField, Ot as expandPreset, Pi as PresetValueInfo, Pt as ResolvedPresetBlock, Qn as DEFAULT_PRESET_NAME, Si as DEFAULT_CONVENTIONS, Ti as Preset, Tt as ExpandedConfig, Xn as presetOfSpec, Yn as presetFromSpec, Zn as presetSpec, _i as PresetCatalog, ar as defaultPreset, bi as PresetGlueItem, er as PRESETS, gi as instancePrefix, hi as INSTANCE_NAME, ir as PresetName, ji as PresetFramework, jt as PresetConflict, ki as PresetFieldKey, kt as presetConfig, mi as CORE_BLOCKS, mr as APP_COLUMN_FORMATS, nr as PRESET_NAMES, or as isPresetName, rr as PresetGroup, sr as namedPreset, tr as PRESET_GROUPS, vi as PresetCatalogBlock, wi as PRESET_TENANT_NAMES, wt as ConfigConventions, xi as CONVENTION_FIELDS, xr as AppColumnFormat, yi as PresetCatalogManifest } from "../context-Lhw7PgdA.js";
2
+ import { $ as readDesignFile, A as DesignFile, B as designFileSource, C as diffAppTables, D as DESIGN_FILE, E as CreateDesign, F as MAX_DESIGN_CODE_LENGTH, G as isDesignCode, H as designOf, I as createQuery, J as presetApplyCommand, K as parseDesign, L as createUrl, M as DesignParseIssue, N as DesignParseResult, O as DESIGN_FORMAT, P as DesignTooLongError, Q as presetKey, R as decodeDesign, S as DiffOptions, T as CREATE_URL, U as designSchema, V as designFormat, W as encodeDesign, X as presetConfigSource, Y as presetArgumentOf, Z as presetInstallCommand, _ as glueCommand, a as blockRequires, b as DesignChange, c as installedBlocks, d as instancesOf, et as safeDesignFileSource, f as presetInstances, g as PROVIDER_COMMENT, h as withoutInstance, i as blockEntities, it as PRESET_CATALOG, j as DesignParseError, k as DesignErrorCode, l as instanceBlock, m as withInstance, n as BlockInstance, nt as appDefaultError, o as canAddInstance, p as withEntityName, q as presetAndDesignOf, r as PresetInstance, rt as isAppDefault, s as entityName, t as BlockEntity, tt as safeParseDesign, u as instanceNameProblem, v as presetBlocksSource, w as diffDesigns, x as DesignChangeKind, y as presetGlue, z as designConfig } from "../index-DYSGzEkY.js";
3
+ import { i as appReservedColumns, n as appIdentifierError, r as appNameLengthError, t as APP_NAME_MAX } from "../app-tables-HqT8E90s.js";
4
4
  export { APP_COLUMN_FORMATS, APP_NAME_MAX, type AppColumnFormat, type BlockEntity, type BlockInstance, CONVENTION_FIELDS, CREATE_URL, type ConfigConventions, type CreateDesign, DEFAULT_CONVENTIONS, DEFAULT_PRESET_NAME, DESIGN_FILE, DESIGN_FORMAT, type DesignChange, type DesignChangeKind, type DesignErrorCode, type DesignFile, DesignParseError, type DesignParseIssue, type DesignParseResult, DesignTooLongError, type DiffOptions, type ExpandedConfig, INSTANCE_NAME, MAX_DESIGN_CODE_LENGTH, type NamedPreset, PRESETS, PRESET_CATALOG, PRESET_FRAMEWORKS, PRESET_GROUPS, PRESET_NAMES, PRESET_TENANT_NAMES, PROVIDER_COMMENT, type Preset, type PresetAccess, type PresetCatalog, type PresetCatalogBlock, type PresetCatalogManifest, type PresetConflict, type PresetConventions, type PresetField, type PresetFieldKey, type PresetFieldValue, type PresetFramework, type PresetGlueItem, type PresetGroup, type PresetInput, type PresetInstance, type PresetIntegration, type PresetName, type PresetPlatforms, type PresetScope, type PresetSpec, type PresetValueInfo, type ResolvedPreset, type ResolvedPresetBlock, CORE_BLOCKS as SINGLE_INSTANCE_BLOCKS, appDefaultError, appIdentifierError, appNameLengthError, appReservedColumns, blockEntities, blockRequires, canAddInstance, conventionConfig, createQuery, createUrl, decodeDesign, defaultPreset, designConfig, designFileSource, designFormat, designOf, designSchema, diffAppTables, diffDesigns, encodeDesign, entityName, expandPreset, glueCommand, installedBlocks, instanceBlock, instanceNameProblem, instancePrefix, instancesOf, integrationsForFramework, isAppDefault, isDesignCode, isPresetName, listNames, namedPreset, parseDesign, presetAndDesignOf, presetApplyCommand, presetArgumentOf, presetBlockConflict, presetBlocksSource, presetConfig, presetConfigSource, presetField, presetFromSpec, presetGlue, presetInstallCommand, presetInstances, presetKey, presetOf, presetOfSpec, presetSpec, presetValueLabel, readDesignFile, resolvePreset, safeDesignFileSource, safeParseDesign, withEntityName, withInstance, withoutInstance };
@@ -1,4 +1,4 @@
1
- import { C as integrationsForFramework, S as PRESET_TENANT_NAMES, T as presetValueLabel, _ as isPresetName, a as presetOf, b as DEFAULT_CONVENTIONS, c as presetSpec, d as resolvePreset, f as DEFAULT_PRESET_NAME, g as defaultPreset, h as PRESET_NAMES, i as presetConfig, l as listNames, m as PRESET_GROUPS, o as presetFromSpec, p as PRESETS, r as expandPreset, s as presetOfSpec, t as conventionConfig, u as presetBlockConflict, v as namedPreset, w as presetField, x as PRESET_FRAMEWORKS, y as CONVENTION_FIELDS } from "../config-HOXkrND2.js";
2
- import { N as PRESET_CATALOG, O as APP_COLUMN_FORMATS, b as appDefaultError, c as APP_NAME_MAX, d as appIdentifierError, f as appNameLengthError, i as instancePrefix, n as INSTANCE_NAME, p as appReservedColumns, t as CORE_BLOCKS, x as isAppDefault } from "../instances-DGtu3S0m.js";
3
- import { A as isDesignCode, B as safeDesignFileSource, C as decodeDesign, D as designOf, E as designFormat, F as presetArgumentOf, G as presetGlue, H as PROVIDER_COMMENT, I as presetConfigSource, L as presetInstallCommand, M as parseDesign, N as presetAndDesignOf, O as designSchema, P as presetApplyCommand, R as presetKey, S as createUrl, T as designFileSource, U as glueCommand, V as safeParseDesign, W as presetBlocksSource, _ as DESIGN_FORMAT, a as installedBlocks, b as MAX_DESIGN_CODE_LENGTH, c as instancesOf, d as withInstance, f as withoutInstance, g as DESIGN_FILE, h as CREATE_URL, i as entityName, k as encodeDesign, l as presetInstances, m as diffDesigns, n as blockRequires, o as instanceBlock, p as diffAppTables, r as canAddInstance, s as instanceNameProblem, t as blockEntities, u as withEntityName, v as DesignParseError, w as designConfig, x as createQuery, y as DesignTooLongError, z as readDesignFile } from "../preset-His18bto.js";
1
+ import { C as integrationsForFramework, S as PRESET_TENANT_NAMES, T as presetValueLabel, _ as isPresetName, a as presetOf, b as DEFAULT_CONVENTIONS, c as presetSpec, d as resolvePreset, f as DEFAULT_PRESET_NAME, g as defaultPreset, h as PRESET_NAMES, i as presetConfig, l as listNames, m as PRESET_GROUPS, o as presetFromSpec, p as PRESETS, r as expandPreset, s as presetOfSpec, t as conventionConfig, u as presetBlockConflict, v as namedPreset, w as presetField, x as PRESET_FRAMEWORKS, y as CONVENTION_FIELDS } from "../config--zZjnkYA.js";
2
+ import { N as PRESET_CATALOG, O as APP_COLUMN_FORMATS, b as appDefaultError, c as APP_NAME_MAX, d as appIdentifierError, f as appNameLengthError, i as instancePrefix, n as INSTANCE_NAME, p as appReservedColumns, t as CORE_BLOCKS, x as isAppDefault } from "../instances-BUhbreNT.js";
3
+ import { A as isDesignCode, B as safeDesignFileSource, C as decodeDesign, D as designOf, E as designFormat, F as presetArgumentOf, G as presetGlue, H as PROVIDER_COMMENT, I as presetConfigSource, L as presetInstallCommand, M as parseDesign, N as presetAndDesignOf, O as designSchema, P as presetApplyCommand, R as presetKey, S as createUrl, T as designFileSource, U as glueCommand, V as safeParseDesign, W as presetBlocksSource, _ as DESIGN_FORMAT, a as installedBlocks, b as MAX_DESIGN_CODE_LENGTH, c as instancesOf, d as withInstance, f as withoutInstance, g as DESIGN_FILE, h as CREATE_URL, i as entityName, k as encodeDesign, l as presetInstances, m as diffDesigns, n as blockRequires, o as instanceBlock, p as diffAppTables, r as canAddInstance, s as instanceNameProblem, t as blockEntities, u as withEntityName, v as DesignParseError, w as designConfig, x as createQuery, y as DesignTooLongError, z as readDesignFile } from "../preset-DFZn_TLi.js";
4
4
  export { APP_COLUMN_FORMATS, APP_NAME_MAX, CONVENTION_FIELDS, CREATE_URL, DEFAULT_CONVENTIONS, DEFAULT_PRESET_NAME, DESIGN_FILE, DESIGN_FORMAT, DesignParseError, DesignTooLongError, INSTANCE_NAME, MAX_DESIGN_CODE_LENGTH, PRESETS, PRESET_CATALOG, PRESET_FRAMEWORKS, PRESET_GROUPS, PRESET_NAMES, PRESET_TENANT_NAMES, PROVIDER_COMMENT, CORE_BLOCKS as SINGLE_INSTANCE_BLOCKS, appDefaultError, appIdentifierError, appNameLengthError, appReservedColumns, blockEntities, blockRequires, canAddInstance, conventionConfig, createQuery, createUrl, decodeDesign, defaultPreset, designConfig, designFileSource, designFormat, designOf, designSchema, diffAppTables, diffDesigns, encodeDesign, entityName, expandPreset, glueCommand, installedBlocks, instanceBlock, instanceNameProblem, instancePrefix, instancesOf, integrationsForFramework, isAppDefault, isDesignCode, isPresetName, listNames, namedPreset, parseDesign, presetAndDesignOf, presetApplyCommand, presetArgumentOf, presetBlockConflict, presetBlocksSource, presetConfig, presetConfigSource, presetField, presetFromSpec, presetGlue, presetInstallCommand, presetInstances, presetKey, presetOf, presetOfSpec, presetSpec, presetValueLabel, readDesignFile, resolvePreset, safeDesignFileSource, safeParseDesign, withEntityName, withInstance, withoutInstance };
@@ -1,5 +1,5 @@
1
- import { M as groupEntries, a as presetOf, c as presetSpec, d as resolvePreset, g as defaultPreset, i as presetConfig, s as presetOfSpec } from "./config-HOXkrND2.js";
2
- import { I as asBlocksConfig, N as PRESET_CATALOG, _ as appTablesOf, n as INSTANCE_NAME, t as CORE_BLOCKS } from "./instances-DGtu3S0m.js";
1
+ import { M as groupEntries, a as presetOf, c as presetSpec, d as resolvePreset, g as defaultPreset, i as presetConfig, s as presetOfSpec } from "./config--zZjnkYA.js";
2
+ import { I as asBlocksConfig, N as PRESET_CATALOG, _ as appTablesOf, n as INSTANCE_NAME, t as CORE_BLOCKS } from "./instances-BUhbreNT.js";
3
3
  import { i as FIELD_FORMATS } from "./field-formats-sLYMh1ZK.js";
4
4
  import { t as isSqlType } from "./sql-type-XWMeZRAl.js";
5
5
  // src/preset/render.ts
@@ -1,8 +1,8 @@
1
- import { a as presetOf, d as resolvePreset } from "./config-HOXkrND2.js";
2
- import { N as PRESET_CATALOG, b as appDefaultError, d as appIdentifierError, f as appNameLengthError, p as appReservedColumns, x as isAppDefault } from "./instances-DGtu3S0m.js";
3
- import { c as resolveConfig } from "./config-DA_R9O_y.js";
4
- import { D as designOf, M as parseDesign, j as jsonPointer, k as encodeDesign, v as DesignParseError, w as designConfig, y as DesignTooLongError } from "./preset-His18bto.js";
5
- import { I as renderBlocks, j as moduleLayout, rt as SQL_MODULES } from "./sql-D3ihagTr.js";
1
+ import { a as presetOf, d as resolvePreset } from "./config--zZjnkYA.js";
2
+ import { N as PRESET_CATALOG, b as appDefaultError, d as appIdentifierError, f as appNameLengthError, p as appReservedColumns, x as isAppDefault } from "./instances-BUhbreNT.js";
3
+ import { c as resolveConfig } from "./config-CAbv8kRz.js";
4
+ import { D as designOf, M as parseDesign, j as jsonPointer, k as encodeDesign, v as DesignParseError, w as designConfig, y as DesignTooLongError } from "./preset-DFZn_TLi.js";
5
+ import { L as renderBlocks, M as moduleLayout, it as SQL_MODULES } from "./sql-TpANPmq7.js";
6
6
  // src/create/column-keys.ts
7
7
  /** The most options a select takes, and the longest option. */
8
8
  const MAX_OPTIONS = 100;