better-supabase 0.15.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (300) hide show
  1. package/dist/{ai-schedules-D_Hz-ik5.d.ts → ai-schedules-Dk9H3kAp.d.ts} +1 -1
  2. package/dist/ai-sdk/agents/index.d.ts +2 -2
  3. package/dist/{api-DxAPqMrE.d.ts → api-CpL3hm87.d.ts} +1 -1
  4. package/dist/{app-tables-D29Rahtg.js → app-tables-Q0TYfeih.js} +1 -0
  5. package/dist/{app-tables-CbCFSXLG.d.ts → app-tables-dS02piE7.d.ts} +1 -1
  6. package/dist/astro/index.d.ts +4 -4
  7. package/dist/{auth-module-BEFESDC4.js → auth-module-BbmX-N4L.js} +12 -4
  8. package/dist/{authorization-HZdJCaVm.d.ts → authorization-CNsvnwle.d.ts} +19 -3
  9. package/dist/better-result/index.d.ts +2 -2
  10. package/dist/{bind-h5jre2K0.d.ts → bind-C801IaK-.d.ts} +4 -4
  11. package/dist/{block-env-BrfRvPrj.d.ts → block-env-BeG4DiiO.d.ts} +4 -4
  12. package/dist/blocks/access-requests/index.d.ts +1 -1
  13. package/dist/blocks/activities/index.d.ts +1 -1
  14. package/dist/blocks/agents/index.d.ts +1 -1
  15. package/dist/blocks/ai-cache/index.d.ts +1 -1
  16. package/dist/blocks/ai-chat/index.d.ts +4 -4
  17. package/dist/blocks/ai-files/index.d.ts +1 -1
  18. package/dist/blocks/ai-keys/index.d.ts +1 -1
  19. package/dist/blocks/ai-schedules/index.d.ts +2 -2
  20. package/dist/blocks/announcements/index.d.ts +4 -4
  21. package/dist/blocks/api-keys/index.d.ts +2 -2
  22. package/dist/blocks/approvals/index.d.ts +1 -1
  23. package/dist/blocks/assets/index.d.ts +1 -1
  24. package/dist/blocks/assignment/index.d.ts +1 -1
  25. package/dist/blocks/attachments/index.d.ts +2 -2
  26. package/dist/blocks/audit/index.d.ts +5 -5
  27. package/dist/blocks/automations/index.d.ts +3 -3
  28. package/dist/blocks/billable-time/index.d.ts +1 -1
  29. package/dist/blocks/billing/index.d.ts +3 -3
  30. package/dist/blocks/bookings/index.d.ts +2 -2
  31. package/dist/blocks/bulk/index.d.ts +1 -1
  32. package/dist/blocks/calendar/index.d.ts +2 -2
  33. package/dist/blocks/catalog/index.d.ts +1 -1
  34. package/dist/blocks/channels/index.d.ts +1 -1
  35. package/dist/blocks/collections/index.d.ts +1 -1
  36. package/dist/blocks/comments/index.d.ts +5 -5
  37. package/dist/blocks/compliance/index.d.ts +1 -1
  38. package/dist/blocks/connectors/index.d.ts +1 -1
  39. package/dist/blocks/contacts/index.d.ts +1 -1
  40. package/dist/blocks/content/index.d.ts +1 -1
  41. package/dist/blocks/contracts/index.d.ts +1 -1
  42. package/dist/blocks/courses/index.d.ts +1 -1
  43. package/dist/blocks/created-by/index.d.ts +4 -3
  44. package/dist/blocks/created-by/index.js +2 -2
  45. package/dist/blocks/custom-fields/index.d.ts +1 -1
  46. package/dist/blocks/data-lifecycle/index.d.ts +1 -1
  47. package/dist/blocks/deals/index.d.ts +1 -1
  48. package/dist/blocks/dispatch/index.d.ts +1 -1
  49. package/dist/blocks/documents/index.d.ts +1 -1
  50. package/dist/blocks/domains/index.d.ts +1 -1
  51. package/dist/blocks/donations/index.d.ts +1 -1
  52. package/dist/blocks/drive/index.d.ts +1 -1
  53. package/dist/blocks/employees/index.d.ts +2 -2
  54. package/dist/blocks/enrichment/index.d.ts +1 -1
  55. package/dist/blocks/enrollments/index.d.ts +1 -1
  56. package/dist/blocks/entitlements/index.d.ts +3 -3
  57. package/dist/blocks/expenses/index.d.ts +1 -1
  58. package/dist/blocks/field-history/index.d.ts +1 -1
  59. package/dist/blocks/flags/index.d.ts +1 -1
  60. package/dist/blocks/forecasts/index.d.ts +1 -1
  61. package/dist/blocks/forms/index.d.ts +2 -2
  62. package/dist/blocks/goals/index.d.ts +1 -1
  63. package/dist/blocks/guests/index.d.ts +1 -1
  64. package/dist/blocks/hiring/index.d.ts +1 -1
  65. package/dist/blocks/identities/index.d.ts +1 -1
  66. package/dist/blocks/imports/index.d.ts +1 -1
  67. package/dist/blocks/inbox/index.d.ts +5 -5
  68. package/dist/blocks/incidents/index.d.ts +1 -1
  69. package/dist/blocks/index.d.ts +2 -2
  70. package/dist/blocks/inventory/index.d.ts +1 -1
  71. package/dist/blocks/invoices/index.d.ts +1 -1
  72. package/dist/blocks/knowledge/index.d.ts +1 -1
  73. package/dist/blocks/lead-scoring/index.d.ts +1 -1
  74. package/dist/blocks/leases/index.d.ts +1 -1
  75. package/dist/blocks/leave/index.d.ts +1 -1
  76. package/dist/blocks/ledger/index.d.ts +1 -1
  77. package/dist/blocks/mail-sync/index.d.ts +1 -1
  78. package/dist/blocks/memberships/index.d.ts +1 -1
  79. package/dist/blocks/memory/index.d.ts +1 -1
  80. package/dist/blocks/messaging/index.d.ts +5 -5
  81. package/dist/blocks/metrics/index.d.ts +1 -1
  82. package/dist/blocks/mfa/index.d.ts +2 -2
  83. package/dist/blocks/moderation/index.d.ts +1 -1
  84. package/dist/blocks/notifications/index.d.ts +4 -4
  85. package/dist/blocks/numbering/index.d.ts +1 -1
  86. package/dist/blocks/oauth-server/index.d.ts +1 -1
  87. package/dist/blocks/onboarding/index.d.ts +2 -2
  88. package/dist/blocks/orders/index.d.ts +2 -2
  89. package/dist/blocks/organizations/index.d.ts +2 -2
  90. package/dist/blocks/outbox/index.d.ts +1 -1
  91. package/dist/blocks/passes/index.d.ts +1 -1
  92. package/dist/blocks/permissions/index.d.ts +3 -3
  93. package/dist/blocks/pipelines/index.d.ts +1 -1
  94. package/dist/blocks/posts/index.d.ts +1 -1
  95. package/dist/blocks/profiles/index.d.ts +1 -1
  96. package/dist/blocks/promotions/index.d.ts +1 -1
  97. package/dist/blocks/push/index.d.ts +2 -2
  98. package/dist/blocks/queue/index.d.ts +29 -2
  99. package/dist/blocks/queue/index.js +1 -1
  100. package/dist/blocks/quotes/index.d.ts +1 -1
  101. package/dist/blocks/rank/index.d.ts +1 -1
  102. package/dist/blocks/reactions/index.d.ts +4 -4
  103. package/dist/blocks/relations/index.d.ts +1 -1
  104. package/dist/blocks/reminders/index.d.ts +1 -1
  105. package/dist/blocks/reviews/index.d.ts +1 -1
  106. package/dist/blocks/saved-views/index.d.ts +3 -3
  107. package/dist/blocks/scores/index.d.ts +1 -1
  108. package/dist/blocks/search/index.d.ts +3 -3
  109. package/dist/blocks/security-events/index.d.ts +1 -1
  110. package/dist/blocks/segments/index.d.ts +1 -1
  111. package/dist/blocks/sequences/index.d.ts +1 -1
  112. package/dist/blocks/service-accounts/index.d.ts +1 -1
  113. package/dist/blocks/sessions/index.d.ts +2 -2
  114. package/dist/blocks/settings/index.d.ts +2 -2
  115. package/dist/blocks/share-links/index.d.ts +1 -1
  116. package/dist/blocks/shipments/index.d.ts +1 -1
  117. package/dist/blocks/signatures/index.d.ts +1 -1
  118. package/dist/blocks/signing-keys/index.d.ts +1 -1
  119. package/dist/blocks/sla/index.d.ts +1 -1
  120. package/dist/blocks/sso/index.d.ts +1 -1
  121. package/dist/blocks/state-machine/index.d.ts +1 -1
  122. package/dist/blocks/subjects/index.d.ts +2 -2
  123. package/dist/blocks/tags/index.d.ts +2 -2
  124. package/dist/blocks/tasks/index.d.ts +2 -2
  125. package/dist/blocks/teams/index.d.ts +1 -1
  126. package/dist/blocks/templates/index.d.ts +1 -1
  127. package/dist/blocks/time-tracking/index.d.ts +1 -1
  128. package/dist/blocks/timeline/index.d.ts +3 -3
  129. package/dist/blocks/trash/index.d.ts +1 -1
  130. package/dist/blocks/undo/index.d.ts +2 -2
  131. package/dist/blocks/updated-at/index.d.ts +7 -4
  132. package/dist/blocks/updated-at/index.js +2 -2
  133. package/dist/blocks/usage/index.d.ts +2 -2
  134. package/dist/blocks/vercel-marketplace/index.d.ts +1 -1
  135. package/dist/blocks/versions/index.d.ts +1 -1
  136. package/dist/blocks/waitlist/index.d.ts +1 -1
  137. package/dist/blocks/webhooks/index.d.ts +2 -2
  138. package/dist/blocks/webhooks/index.js +1 -1
  139. package/dist/blocks/workflow-editor/index.d.ts +4 -4
  140. package/dist/blocks/workflows/index.d.ts +4 -4
  141. package/dist/{bucket-CiNi8sIw.d.ts → bucket-vc-QRrva.d.ts} +40 -1
  142. package/dist/cli/{add-C04vkBk9.js → add-BinNYhFD.js} +2 -2
  143. package/dist/cli/{add-DNOL9PDu.js → add-DMcrsWjC.js} +13 -11
  144. package/dist/cli/add-z-3pXI6C.js +1 -0
  145. package/dist/cli/{backfill-VFzf-TJP.js → backfill-DxBB62Zr.js} +3 -3
  146. package/dist/cli/bin.js +1 -1
  147. package/dist/cli/{blocks-Cb7mILFU.js → blocks-DSgTifw0.js} +1 -1
  148. package/dist/cli/{blocks-Bn7WUca5.js → blocks-rxOS-Mzz.js} +1 -1
  149. package/dist/cli/{cache-DkplpIGe.js → cache-oU0yHKf0.js} +1 -1
  150. package/dist/cli/{codemod-BbaE5dL_.js → codemod-Dsrv_3gQ.js} +1 -1
  151. package/dist/cli/{config-9t5ec_N7.js → config-2rwFHbwj.js} +3 -1
  152. package/dist/cli/{config-CBqkQjjN.js → config-C6XylzKz.js} +1 -1
  153. package/dist/cli/{content-mapper-Cdx6arxu.js → content-mapper-DLbXilBz.js} +2 -2
  154. package/dist/cli/{db-DrBI_HNv.js → db-Bwrr3GHM.js} +2 -2
  155. package/dist/cli/{doctor-C-VO-QQ2.js → doctor-CKt5Yyl4.js} +184 -142
  156. package/dist/cli/{gen-yRHOHW1b.js → gen-CeG6lbka.js} +13 -13
  157. package/dist/cli/index.d.ts +1 -1
  158. package/dist/cli/index.js +7 -7
  159. package/dist/cli/{init-BOw0SX65.js → init-DrQlf9RL.js} +6 -6
  160. package/dist/cli/{live-Lmg-hYyO.js → live-BvWGM4c3.js} +2 -2
  161. package/dist/cli/{mcp-DQ1zR2eA.js → mcp-BrOnGB15.js} +2 -2
  162. package/dist/cli/{metadata-CZaxkv21.js → metadata-BNSdPuKp.js} +3 -3
  163. package/dist/cli/{migration-safety-BbhLu2fo.js → migration-safety-NtB3dsRU.js} +2 -2
  164. package/dist/cli/{module-migration-DOn6EmNz.js → module-migration-mKhX88V_.js} +1 -1
  165. package/dist/cli/{print-D_xf8PPj.js → print-Dh8iuPK3.js} +1 -1
  166. package/dist/cli/{remove-BY_TOTRj.js → remove-DfFXVBRr.js} +5 -5
  167. package/dist/cli/{render-lJmHr0y9.js → render-ChIwdIOJ.js} +10 -4
  168. package/dist/cli/{run-BJ6IMs_H.js → run-CLSHSVYo.js} +7 -7
  169. package/dist/cli/{run-DkB0fhc9.js → run-D48ZEU58.js} +24 -24
  170. package/dist/cli/{seed-Cz8PcXeT.js → seed-CG-pA-5N.js} +2 -2
  171. package/dist/cli/seed-CUxW5Dks.js +1 -0
  172. package/dist/cli/{shared-Bh-6IqJS.js → shared-D0XBFSlz.js} +1 -1
  173. package/dist/cli/{snapshot-Bzcigm7T.js → snapshot-C6vh_n3t.js} +3 -3
  174. package/dist/cli/{source-WoLdcQzN.js → source-BZbEK5if.js} +1 -1
  175. package/dist/cli/{source-args-IpJRJO5t.js → source-args-MTLYpifA.js} +1 -1
  176. package/dist/cli/{spec-CZMiLhv_.js → spec-B4LhpI6t.js} +2 -2
  177. package/dist/cli/{spec-BF_dpwzW.js → spec-C-dhdKwa.js} +1 -1
  178. package/dist/cli/{sql-layout-rFP0oq1N.js → sql-layout-26LSoifK.js} +2 -2
  179. package/dist/cli/{sync-mANmYYoL.js → sync-CHGMZCJ5.js} +2 -2
  180. package/dist/cli/{upgrade-B0Q9wMs-.js → upgrade-C0dVsqNX.js} +3 -3
  181. package/dist/cli/{upgrade-BrNLt92u.js → upgrade-GB9rqUGT.js} +2 -2
  182. package/dist/cli/{version-CyavsyGA.js → version-T507a49w.js} +1 -1
  183. package/dist/client/index.d.ts +5 -5
  184. package/dist/client/index.js +1 -1
  185. package/dist/client/native/index.d.ts +5 -5
  186. package/dist/client/native/index.js +1 -1
  187. package/dist/{client-BAEbEA7t.js → client-C_mlji5R.js} +6 -5
  188. package/dist/{composite-BZYXlVBN.d.ts → composite-B7f1MMgr.d.ts} +4 -3
  189. package/dist/config/index.d.ts +3 -3
  190. package/dist/config/index.js +4 -4
  191. package/dist/{config-DWGgUQCh.js → config-BVNNJwGC.js} +7 -6
  192. package/dist/{config-CcehOvbz.js → config-CIBc79_8.js} +1 -1
  193. package/dist/{context-TGX2eDS5.d.ts → context-CKCgjEDF.d.ts} +9 -2
  194. package/dist/{controller-DyPPMFSw.d.ts → controller-CJUXhshv.d.ts} +1 -1
  195. package/dist/{conversion-O-kyhXcC.d.ts → conversion-DgHdDlTK.d.ts} +1 -1
  196. package/dist/create/index.d.ts +2 -2
  197. package/dist/create/index.js +5 -5
  198. package/dist/{define-DFBnQyYg.d.ts → define-Cgru0_kF.d.ts} +2 -2
  199. package/dist/{define-block-DvvcM54N.d.ts → define-block-Xxw8Hroe.d.ts} +2 -2
  200. package/dist/edge/index.d.ts +5 -5
  201. package/dist/{entitlements-BnhDBxLW.d.ts → entitlements-B0jmjNLD.d.ts} +1 -1
  202. package/dist/{executor-CVIn6JHa.d.ts → executor-BWFfz0ik.d.ts} +2 -2
  203. package/dist/expo/index.d.ts +2 -2
  204. package/dist/{extension-B-lajjex.js → extension-DTaHjwdc.js} +3 -2
  205. package/dist/{extension-B0EjCYhO.js → extension-mGylYROs.js} +2 -10
  206. package/dist/{field-errors-DYtg1mwv.d.ts → field-errors-DqlebtTE.d.ts} +12 -12
  207. package/dist/{framework-h5lP_5yj.d.ts → framework-CF6zFU7a.d.ts} +3 -3
  208. package/dist/hono/index.d.ts +4 -4
  209. package/dist/{index-BfkltrGJ.d.ts → index-B8YjrfVl.d.ts} +2 -2
  210. package/dist/{index-BAHGLvGD.d.ts → index-BCeTYhFk.d.ts} +1 -1
  211. package/dist/{index-Do2ChN_y.d.ts → index-CQhPHHDF.d.ts} +20 -2
  212. package/dist/{index-Ab4UeEn_.d.ts → index-ClMN0f98.d.ts} +44 -12
  213. package/dist/{index-B4gcStOz.d.ts → index-DUxXdQN_.d.ts} +3 -3
  214. package/dist/{index-BfK6olKm.d.ts → index-Dbb7BQdi.d.ts} +9 -4
  215. package/dist/{index-DN9mfmhA.d.ts → index-lB-8iPmY.d.ts} +51 -3
  216. package/dist/index.d.ts +2 -2
  217. package/dist/{instances-BHjCZoF8.js → instances-QOzIz9-q.js} +1 -1
  218. package/dist/list/index.d.ts +1 -1
  219. package/dist/{list-query-BDVutLFr.d.ts → list-query-DxjuIHEL.d.ts} +1 -1
  220. package/dist/mapper/bin.js +6 -6
  221. package/dist/mcp/index.d.ts +4 -4
  222. package/dist/mcp/sdk/index.d.ts +2 -2
  223. package/dist/next/client/index.d.ts +81 -1
  224. package/dist/next/client/index.js +178 -2
  225. package/dist/next/index.d.ts +15 -14
  226. package/dist/{operations-CSc_IsHO.d.ts → operations-Dc07aV_H.d.ts} +1 -1
  227. package/dist/{options-DChZoVfs.d.ts → options-B_NrjVDt.d.ts} +1 -0
  228. package/dist/{options-B2swWnJW.js → options-CCUaRLgd.js} +2 -1
  229. package/dist/{options-CM6-18FQ.d.ts → options-CDSCkYxu.d.ts} +1 -0
  230. package/dist/{options-C-dQHH5-.js → options-tSsUF0-7.js} +2 -1
  231. package/dist/orpc/index.d.ts +4 -4
  232. package/dist/otel/index.js +4 -4
  233. package/dist/{ports-DOhtuw3c.js → ports-CaVRXjxq.js} +1 -1
  234. package/dist/{ports-CpdiQv1D.d.ts → ports-DnpAuTvB.d.ts} +1 -1
  235. package/dist/powersync/index.d.ts +2 -2
  236. package/dist/preset/index.d.ts +3 -3
  237. package/dist/preset/index.js +3 -3
  238. package/dist/{preset-CsHnIBJF.js → preset-BIANzB5p.js} +2 -2
  239. package/dist/{push-token-B3m3pWAv.d.ts → push-token-C_mFkYfq.d.ts} +1 -1
  240. package/dist/query/index.d.ts +1 -1
  241. package/dist/{rate-limit-o44SYkVY.js → rate-limit-Dt9vAY4E.js} +53 -0
  242. package/dist/react/index.d.ts +6 -6
  243. package/dist/react/index.js +3 -3
  244. package/dist/react/native/index.d.ts +1 -1
  245. package/dist/react/native/index.js +1 -1
  246. package/dist/react/server.d.ts +12 -7
  247. package/dist/react/server.js +8 -3
  248. package/dist/react/session.d.ts +5 -0
  249. package/dist/react/session.js +9 -1
  250. package/dist/{react-BuDYI62C.js → react-CZUZYn9E.js} +41 -4
  251. package/dist/react-router/index.d.ts +3 -3
  252. package/dist/realtime/index.d.ts +5 -5
  253. package/dist/realtime/index.js +2 -1
  254. package/dist/{record-form-DB_5Ue_B.d.ts → record-form-xWvVcb86.d.ts} +1 -1
  255. package/dist/records/index.d.ts +7 -7
  256. package/dist/relay-gKvKJ3xf.js +208 -0
  257. package/dist/{resource-execute-CzHuDsil.d.ts → resource-execute-DqWfEc56.d.ts} +1 -1
  258. package/dist/{resource-types-DnKiH4G2.d.ts → resource-types-BIoz_ElD.d.ts} +1 -1
  259. package/dist/{resources-B9cQxhjw.d.ts → resources-Bt2PDKE7.d.ts} +1 -1
  260. package/dist/server/index.d.ts +147 -9
  261. package/dist/server/index.js +396 -1
  262. package/dist/{server-types-7QPzW2bF.d.ts → server-types-gR4Q1aM0.d.ts} +5 -354
  263. package/dist/{session-CfBCJGgc.d.ts → session-C1OuXbtN.d.ts} +2 -1
  264. package/dist/session-status-qQLm7jzh.d.ts +82 -0
  265. package/dist/{sign-in-BsIaNx2C.js → sign-in-CmPK1AgM.js} +20 -10
  266. package/dist/solid/index.d.ts +7 -7
  267. package/dist/solid/index.js +1 -1
  268. package/dist/solid-start/index.d.ts +3 -3
  269. package/dist/spec/index.d.ts +1 -1
  270. package/dist/sql/index.d.ts +5 -5
  271. package/dist/sql/index.js +3 -3
  272. package/dist/{sql-OLVW4t08.js → sql-ClTmzHs8.js} +199 -31
  273. package/dist/sqlite/index.d.ts +1 -1
  274. package/dist/ssr/index.d.ts +1 -1
  275. package/dist/storage/index.d.ts +3 -3
  276. package/dist/storage/index.js +54 -1
  277. package/dist/support-B4ZBVxt3.d.ts +357 -0
  278. package/dist/svelte/index.d.ts +7 -7
  279. package/dist/svelte/index.js +1 -1
  280. package/dist/sveltekit/index.d.ts +4 -4
  281. package/dist/{tags-BjHflcHF.d.ts → tags-sM-CH9Mn.d.ts} +1 -1
  282. package/dist/tanstack-db/index.d.ts +1 -1
  283. package/dist/tanstack-start/index.d.ts +3 -3
  284. package/dist/{tenant-DzFsg0Pc.d.ts → tenant-DVvjw9H-.d.ts} +1 -1
  285. package/dist/testing/index.d.ts +9 -8
  286. package/dist/testing/index.js +3 -3
  287. package/dist/{timeline-WrFMgd3U.d.ts → timeline-BBfKuMVL.d.ts} +3 -3
  288. package/dist/{topic-DNFEFGKI.d.ts → topic-BtLz-qTI.d.ts} +3 -3
  289. package/dist/{verify-CMou8dWZ.d.ts → verify-DEqY__0N.d.ts} +1 -1
  290. package/dist/vue/index.d.ts +7 -7
  291. package/dist/vue/index.js +1 -1
  292. package/dist/{watch-topic-Bo9S2R4P.d.ts → watch-topic-tnfOTa3-.d.ts} +1 -1
  293. package/dist/yjs/index.d.ts +1 -1
  294. package/package.json +1 -1
  295. package/schemas/config-v1.json +22 -0
  296. package/schemas/doctor-report-v1.json +1 -0
  297. package/skills/better-supabase-api/SKILL.md +3 -1
  298. package/skills/better-supabase-auth/SKILL.md +7 -0
  299. package/dist/cli/add-CUH0rORo.js +0 -1
  300. package/dist/cli/seed-D6XijwbR.js +0 -1
@@ -1,8 +1,8 @@
1
1
  import { t as escapeLike } from "../escape-like-DHfx6jRr.js";
2
- import { d as useSupabase, i as BetterSupabaseProvider, o as useAuth, s as useBroadcast, u as useLiveQuery } from "../sign-in-BsIaNx2C.js";
2
+ import { d as useSupabase, i as BetterSupabaseProvider, o as useAuth, s as useBroadcast, u as useLiveQuery } from "../sign-in-CmPK1AgM.js";
3
3
  import { t as supportOf } from "../support-view-g4YLBeqX.js";
4
4
  import { d as fieldErrorsOf } from "../data-hooks-tgF1Ct0F.js";
5
- import "../react-BuDYI62C.js";
5
+ import "../react-CZUZYn9E.js";
6
6
  import { t as tenantOf } from "../tenant-BgIiMQpo.js";
7
7
  import { SessionProvider } from "./session.js";
8
8
  //#region src/react/server.ts
@@ -39,6 +39,11 @@ const useActionForm = clientOnly("useActionForm");
39
39
  */
40
40
  const usePresence = clientOnly("usePresence");
41
41
  /**
42
+ * The `react-server` build of `useRealtimeRelay`: create the relay client in a
43
+ * Client Component.
44
+ */
45
+ const useRealtimeRelay = clientOnly("useRealtimeRelay");
46
+ /**
42
47
  * The `react-server` build of `useSignIn`: sign in from a Client Component or a
43
48
  * Server Action.
44
49
  */
@@ -138,4 +143,4 @@ const useBlockEnv = clientOnly("useBlockEnv");
138
143
  */
139
144
  const useBlockTenant = clientOnly("useBlockTenant");
140
145
  //#endregion
141
- export { BetterSupabaseProvider, SessionProvider, createHooks, createRecordProvider, defineDataHooks, escapeLike, fieldErrorsOf, supportOf, tenantOf, useAction, useActionForm, useAuth, useBlockEnv, useBlockEvent, useBlockMutation, useBlockQuery, useBlockTenant, useBroadcast, useConflicts, useController, useDebouncedSearch, useImage, useLatest, useLiveCount, useLiveQuery, usePresence, useRecordForm, useRecordListState, useSession, useSignIn, useSignOut, useSignedUrl, useSupabase, useSupportSession, useSyncStatus, useUpload };
146
+ export { BetterSupabaseProvider, SessionProvider, createHooks, createRecordProvider, defineDataHooks, escapeLike, fieldErrorsOf, supportOf, tenantOf, useAction, useActionForm, useAuth, useBlockEnv, useBlockEvent, useBlockMutation, useBlockQuery, useBlockTenant, useBroadcast, useConflicts, useController, useDebouncedSearch, useImage, useLatest, useLiveCount, useLiveQuery, usePresence, useRealtimeRelay, useRecordForm, useRecordListState, useSession, useSignIn, useSignOut, useSignedUrl, useSupabase, useSupportSession, useSyncStatus, useUpload };
@@ -26,4 +26,9 @@ export declare function useSession<C = unknown, P = unknown>(): AuthSession<C, P
26
26
  * `useSession`.
27
27
  */
28
28
  export declare function useSupportSession(): SupportView | undefined;
29
+ /**
30
+ * `useSupportSession()` that answers `undefined` outside a `<SessionProvider>`
31
+ * instead of throwing.
32
+ */
33
+ export declare function useOptionalSupportSession(): SupportView | undefined;
29
34
  //#endregion
@@ -27,5 +27,13 @@ function useSession() {
27
27
  function useSupportSession() {
28
28
  return supportOf(useSession());
29
29
  }
30
+ /**
31
+ * `useSupportSession()` that answers `undefined` outside a `<SessionProvider>`
32
+ * instead of throwing.
33
+ */
34
+ function useOptionalSupportSession() {
35
+ const promise = useContext(SessionContext);
36
+ return promise ? supportOf(use(promise)) : void 0;
37
+ }
30
38
  //#endregion
31
- export { SessionProvider, useSession, useSupportSession };
39
+ export { SessionProvider, useOptionalSupportSession, useSession, useSupportSession };
@@ -1,13 +1,14 @@
1
1
  import { n as dbError } from "./errors-BVFgt8BZ.js";
2
2
  import { t as escapeLike } from "./escape-like-DHfx6jRr.js";
3
3
  import { a as ok, r as err, s as toDbError } from "./result-ntFBW2p2.js";
4
- import { c as useBroadcastAuth, f as ClientContext } from "./sign-in-BsIaNx2C.js";
5
- import "./react/session.js";
4
+ import { c as useBroadcastAuth, f as ClientContext } from "./sign-in-CmPK1AgM.js";
5
+ import { useOptionalSupportSession } from "./react/session.js";
6
6
  import { a as blockArgsKey, c as listenToBlockEvents, d as fieldErrorsOf, i as dataTarget, l as blockEnv, n as createDataOne, o as createBlockMutation, r as dataArgsKey, s as createBlockQuery, t as createDataList } from "./data-hooks-tgF1Ct0F.js";
7
7
  import { H as rpcTransport } from "./block-helpers-CtBdjgO4.js";
8
8
  import { r as createBlocks } from "./create-blocks-Bu4H5TXw.js";
9
9
  import { a as recordCan, i as plainData, l as runBindingWrite, s as recordSubject } from "./record-type-DRbnlj5q.js";
10
10
  import { t as createRecordController } from "./controller-BNZKd6bJ.js";
11
+ import { t as relayRealtimeClient } from "./relay-gKvKJ3xf.js";
11
12
  import { a as ttlSeconds, n as scaleTransform, r as transformFor } from "./variants-Cy--Ub-a.js";
12
13
  import { createContext, createElement, use, useCallback, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore, useTransition } from "react";
13
14
  //#region src/react/actions.ts
@@ -529,7 +530,7 @@ const notJoined = () => Promise.resolve(dbError("invalid_request", "better-supab
529
530
  */
530
531
  function usePresence(topic, values, options = {}) {
531
532
  const context = useContext(ClientContext);
532
- const supabase = options.client ?? context?.client.supabase;
533
+ const supabase = options.client ?? context?.realtime ?? context?.client.supabase;
533
534
  if (!supabase) throw new Error("better-supabase: usePresence needs <BetterSupabaseProvider client={bsb}> or { client: supabase }");
534
535
  const auth = useBroadcastAuth(options.client === void 0 ? context?.client : void 0, supabase);
535
536
  const [members, setMembers] = useState(NONE);
@@ -606,6 +607,42 @@ function syncState(joined, current, tracked) {
606
607
  else joined.track(current.state);
607
608
  }
608
609
  //#endregion
610
+ //#region src/react/relay.ts
611
+ /**
612
+ * A `relayRealtimeClient(url)` while it is needed, else `undefined`. Pass it to
613
+ * `<BetterSupabaseProvider realtime={...}>`, and `useBroadcast`, `usePresence`,
614
+ * `useLiveQuery` and `useLiveCount` join through the server's `realtimeRelay`
615
+ * route, as the viewed user in a support session. The client is created once
616
+ * per `url` and options, so pass a stable `fetch` and `EventSource`.
617
+ *
618
+ * ```tsx
619
+ * const realtime = useRealtimeRelay("/api/realtime");
620
+ * return (
621
+ * <BetterSupabaseProvider client={bsb} realtime={realtime}>
622
+ * {children}
623
+ * </BetterSupabaseProvider>
624
+ * );
625
+ * ```
626
+ */
627
+ function useRealtimeRelay(url, options = {}) {
628
+ const support = useOptionalSupportSession();
629
+ const active = options.when === "always" || support !== void 0;
630
+ const { EventSource: source, fetch: send, timeoutMs, maxBackoffMs } = options;
631
+ return useMemo(() => active ? relayRealtimeClient(url, {
632
+ ...source === void 0 ? {} : { EventSource: source },
633
+ ...send === void 0 ? {} : { fetch: send },
634
+ ...timeoutMs === void 0 ? {} : { timeoutMs },
635
+ ...maxBackoffMs === void 0 ? {} : { maxBackoffMs }
636
+ }) : void 0, [
637
+ active,
638
+ url,
639
+ source,
640
+ send,
641
+ timeoutMs,
642
+ maxBackoffMs
643
+ ]);
644
+ }
645
+ //#endregion
609
646
  //#region src/react/search.ts
610
647
  /**
611
648
  * A search box's value, debounced. Pass `term` to `contains` (which escapes it)
@@ -976,4 +1013,4 @@ function useUpload(bucket, options = {}) {
976
1013
  };
977
1014
  }
978
1015
  //#endregion
979
- export { useController as _, usePresence as a, useActionForm as b, defineDataHooks as c, useBlockQuery as d, useRecordForm as f, useBlockTenant as g, useBlockEnv as h, useDebouncedSearch as i, useBlockEvent as l, createRecordProvider as m, useSignedUrl as n, useConflicts as o, useRecordListState as p, useUpload as r, useSyncStatus as s, useImage as t, useBlockMutation as u, useLatest as v, useAction as y };
1016
+ export { useBlockTenant as _, useRealtimeRelay as a, useAction as b, useSyncStatus as c, useBlockMutation as d, useBlockQuery as f, useBlockEnv as g, createRecordProvider as h, useDebouncedSearch as i, defineDataHooks as l, useRecordListState as m, useSignedUrl as n, usePresence as o, useRecordForm as p, useUpload as r, useConflicts as s, useImage as t, useBlockEvent as u, useController as v, useActionForm as x, useLatest as y };
@@ -1,10 +1,10 @@
1
1
  import { O as AnyFunctions, k as AnyModels } from "../types-DFdg_4yN.js";
2
2
  import { l as PermissionRef, t as AnyAuthorizer } from "../authorizer-B6X09otb.js";
3
- import { t as BetterSupabase } from "../define-DFBnQyYg.js";
4
- import { n as BetterServer } from "../server-types-7QPzW2bF.js";
3
+ import { t as BetterSupabase } from "../define-Cgru0_kF.js";
4
+ import { n as BetterServer } from "../server-types-gR4Q1aM0.js";
5
5
  import { a as AuthorizedContext, c as ResourceLoaderContext, i as AuthorizeOptions, l as Unwrapped, n as ActionParsed, o as BlockActionOptions, r as ActionResult, s as BlockRequireOptions } from "../kit-DOwKpSkA.js";
6
6
  import { t as RefusalRedirects } from "../refusal-CSntB_x8.js";
7
- import { n as FrameworkOptions, r as LocalsResource, t as FrameworkLocals } from "../framework-h5lP_5yj.js";
7
+ import { n as FrameworkOptions, r as LocalsResource, t as FrameworkLocals } from "../framework-CF6zFU7a.js";
8
8
  import { t as Validated } from "../shared-CRRfQAKG.js";
9
9
  import { AnyEntry, Contributions } from "@supabase/middleware";
10
10
  import { StandardSchemaV1 } from "@standard-schema/spec";
@@ -1,8 +1,8 @@
1
1
  import { D as AccessTopicPolicy, E as AccessPolicySql } from "../types-DFdg_4yN.js";
2
- import { $ as TemplateValues, Q as TemplateParams } from "../bucket-CiNi8sIw.js";
2
+ import { et as TemplateParams, tt as TemplateValues } from "../bucket-vc-QRrva.js";
3
3
  import { t as RealtimeStatus } from "../realtime-status-BhNkb-Ow.js";
4
- import { A as TriggerTopic, C as TopicSubscription, D as TriggerLookup, E as TopicTriggerValue, F as FanOutResult, I as TopicFanOutOptions, M as defineTopic, N as rowChange, O as TriggerOptions, P as rowKeys, S as TopicSubscribeOptions, T as TopicTriggerOptions, _ as TopicMessage, a as PresenceOutput, b as TopicPermission, c as RealtimeClient, d as SubscribeOptions, f as Subscription, g as TopicHandlers, h as TopicEvent, i as PresenceOptions, j as TriggerValue, k as TriggerPayloadMode, l as RowChange, m as Topic, n as PresenceInput, o as PresenceSchema, p as SubscriptionStatus, r as PresenceMember, s as PresenceSubscription, t as EventSchemas, u as RowKeys, v as TopicOptions, w as TopicTriggerLookup, x as TopicSqlOptions, y as TopicPayload } from "../topic-DNFEFGKI.js";
5
- import { a as watchTopic, i as topicPort, n as TopicPort, r as TopicWatch, t as TopicHandle } from "../watch-topic-Bo9S2R4P.js";
6
- import { _ as subjectPresenceValues, a as LiveSource, c as liveCount, d as realtimeChanges, f as SUBJECT_PRESENCE_TEMPLATE, g as subjectPresenceTopic, h as subjectPresence, i as LiveQueryOptions, l as liveQuery, m as SubjectPresenceValues, n as LiveCountOptions, o as LiveSubscription, p as SubjectPresenceTopic, r as LiveCountSeed, s as RealtimeChangesOptions, t as CountRunner, u as liveTopic } from "../index-DN9mfmhA.js";
4
+ import { A as TriggerTopic, C as TopicSubscription, D as TriggerLookup, E as TopicTriggerValue, F as FanOutResult, I as TopicFanOutOptions, M as defineTopic, N as rowChange, O as TriggerOptions, P as rowKeys, S as TopicSubscribeOptions, T as TopicTriggerOptions, _ as TopicMessage, a as PresenceOutput, b as TopicPermission, c as RealtimeClient, d as SubscribeOptions, f as Subscription, g as TopicHandlers, h as TopicEvent, i as PresenceOptions, j as TriggerValue, k as TriggerPayloadMode, l as RowChange, m as Topic, n as PresenceInput, o as PresenceSchema, p as SubscriptionStatus, r as PresenceMember, s as PresenceSubscription, t as EventSchemas, u as RowKeys, v as TopicOptions, w as TopicTriggerLookup, x as TopicSqlOptions, y as TopicPayload } from "../topic-BtLz-qTI.js";
5
+ import { a as watchTopic, i as topicPort, n as TopicPort, r as TopicWatch, t as TopicHandle } from "../watch-topic-tnfOTa3-.js";
6
+ import { S as relayTopicPort, _ as subjectPresenceValues, a as LiveSource, b as RelayEventSourceConstructor, c as liveCount, d as realtimeChanges, f as SUBJECT_PRESENCE_TEMPLATE, g as subjectPresenceTopic, h as subjectPresence, i as LiveQueryOptions, l as liveQuery, m as SubjectPresenceValues, n as LiveCountOptions, o as LiveSubscription, p as SubjectPresenceTopic, r as LiveCountSeed, s as RealtimeChangesOptions, t as CountRunner, u as liveTopic, v as RelayClientOptions, x as relayRealtimeClient, y as RelayEventSource } from "../index-lB-8iPmY.js";
7
7
  import { n as subjectReaders, t as SubjectReadersOptions } from "../subject-readers-8GySC9Z8.js";
8
- export { type AccessPolicySql, type AccessTopicPolicy, type CountRunner, type EventSchemas, type FanOutResult, type LiveCountOptions, type LiveCountSeed, type LiveQueryOptions, type LiveSource, type LiveSubscription, type PresenceInput, type PresenceMember, type PresenceOptions, type PresenceOutput, type PresenceSchema, type PresenceSubscription, type RealtimeChangesOptions, type RealtimeClient, type RealtimeStatus, type RowChange, type RowKeys, SUBJECT_PRESENCE_TEMPLATE, type SubjectPresenceTopic, type SubjectPresenceValues, type SubjectReadersOptions, type SubscribeOptions, type Subscription, type SubscriptionStatus, type TemplateParams, type TemplateValues, type Topic, type TopicEvent, type TopicFanOutOptions, type TopicHandle, type TopicHandlers, type TopicMessage, type TopicOptions, type TopicPayload, type TopicPermission, type TopicPort, type TopicSqlOptions, type TopicSubscribeOptions, type TopicSubscription, type TopicTriggerLookup, type TopicTriggerOptions, type TopicTriggerValue, type TopicWatch, type TriggerLookup, type TriggerOptions, type TriggerPayloadMode, type TriggerTopic, type TriggerValue, defineTopic, liveCount, liveQuery, liveTopic, realtimeChanges, rowChange, rowKeys, subjectPresence, subjectPresenceTopic, subjectPresenceValues, subjectReaders, topicPort, watchTopic };
8
+ export { type AccessPolicySql, type AccessTopicPolicy, type CountRunner, type EventSchemas, type FanOutResult, type LiveCountOptions, type LiveCountSeed, type LiveQueryOptions, type LiveSource, type LiveSubscription, type PresenceInput, type PresenceMember, type PresenceOptions, type PresenceOutput, type PresenceSchema, type PresenceSubscription, type RealtimeChangesOptions, type RealtimeClient, type RealtimeStatus, type RelayClientOptions, type RelayEventSource, type RelayEventSourceConstructor, type RowChange, type RowKeys, SUBJECT_PRESENCE_TEMPLATE, type SubjectPresenceTopic, type SubjectPresenceValues, type SubjectReadersOptions, type SubscribeOptions, type Subscription, type SubscriptionStatus, type TemplateParams, type TemplateValues, type Topic, type TopicEvent, type TopicFanOutOptions, type TopicHandle, type TopicHandlers, type TopicMessage, type TopicOptions, type TopicPayload, type TopicPermission, type TopicPort, type TopicSqlOptions, type TopicSubscribeOptions, type TopicSubscription, type TopicTriggerLookup, type TopicTriggerOptions, type TopicTriggerValue, type TopicWatch, type TriggerLookup, type TriggerOptions, type TriggerPayloadMode, type TriggerTopic, type TriggerValue, defineTopic, liveCount, liveQuery, liveTopic, realtimeChanges, relayRealtimeClient, relayTopicPort, rowChange, rowKeys, subjectPresence, subjectPresenceTopic, subjectPresenceValues, subjectReaders, topicPort, watchTopic };
@@ -1,5 +1,6 @@
1
1
  import { i as realtimeChanges, n as liveQuery, r as liveTopic, t as liveCount } from "../live-C21DgbsD.js";
2
2
  import { n as watchTopic, t as topicPort } from "../watch-topic-CuaWfCuv.js";
3
+ import { n as relayTopicPort, t as relayRealtimeClient } from "../relay-gKvKJ3xf.js";
3
4
  import { t as subjectReaders } from "../subject-readers-B-pQ9Mmo.js";
4
5
  import { n as rowChange, r as rowKeys, t as defineTopic } from "../topic-ikV_pLTX.js";
5
6
  //#region src/realtime/subject-presence.ts
@@ -34,4 +35,4 @@ function subjectPresenceValues(subject) {
34
35
  } : null;
35
36
  }
36
37
  //#endregion
37
- export { SUBJECT_PRESENCE_TEMPLATE, defineTopic, liveCount, liveQuery, liveTopic, realtimeChanges, rowChange, rowKeys, subjectPresence, subjectPresenceTopic, subjectPresenceValues, subjectReaders, topicPort, watchTopic };
38
+ export { SUBJECT_PRESENCE_TEMPLATE, defineTopic, liveCount, liveQuery, liveTopic, realtimeChanges, relayRealtimeClient, relayTopicPort, rowChange, rowKeys, subjectPresence, subjectPresenceTopic, subjectPresenceValues, subjectReaders, topicPort, watchTopic };
@@ -1,4 +1,4 @@
1
- import { Sn as EntitySchema } from "./define-block-DvvcM54N.js";
1
+ import { Sn as EntitySchema } from "./define-block-Xxw8Hroe.js";
2
2
  import { s as FormFieldType } from "./form-definition-BjEtH8BT.js";
3
3
  //#region src/records/record-form.d.ts
4
4
  /** The input a field renders: a forms block field type, or a date and time. */
@@ -1,13 +1,13 @@
1
1
  import { b as DbError, t as AsyncResult } from "../result-DZeA5KS6.js";
2
2
  import { $ as RecordRef } from "../types-DFdg_4yN.js";
3
- import { _n as recordBindingWrite, an as RecordBindingDefinition, cn as RecordBindingResult, dn as RecordBindingWriteName, fn as RecordBindingWriteOutput, gn as defineRecordBinding, hn as TimelineItem, in as RecordBindingData, ln as RecordBindingWrite, mn as RecordRowInput, nn as AnyRecordBindingWrite, on as RecordBindingOptions, pn as RecordBindingWrites, rn as RecordBinding, sn as RecordBindingPermissions, tn as AnyRecordBinding, un as RecordBindingWriteInput, vn as recordEventMatches, yn as recordRowInput } from "../define-block-DvvcM54N.js";
4
- import { A as BindingBlocks, B as PermissionFlags, C as defineRecordType, D as recordPermissionKeys, E as recordCan, F as LoadBindingsOptions, H as can, I as LoadedBindings, L as bindingCan, M as BindingName, N as BindingOf, O as recordSubject, P as BindingSource, R as countBinding, S as RecordWriteInput, T as plainData, U as permissionFlags, V as PermissionSet, _ as RecordTypeBlocks, b as RecordTypeWriteInput, d as BindingWritesOf, f as Plain, g as RecordType, h as RecordCan, j as BindingCheck, k as recordWriteInput, m as PlainBindings, p as PlainBinding, v as RecordTypePermissions, w as findBindingWrite, x as RecordTypeWriteOutput, y as RecordTypeSpec, z as loadBindings } from "../index-BfkltrGJ.js";
5
- import { p as SubscriptionStatus } from "../topic-DNFEFGKI.js";
6
- import { n as TopicPort } from "../watch-topic-Bo9S2R4P.js";
7
- import { n as Controller, t as AuthPort } from "../controller-DyPPMFSw.js";
3
+ import { _n as recordBindingWrite, an as RecordBindingDefinition, cn as RecordBindingResult, dn as RecordBindingWriteName, fn as RecordBindingWriteOutput, gn as defineRecordBinding, hn as TimelineItem, in as RecordBindingData, ln as RecordBindingWrite, mn as RecordRowInput, nn as AnyRecordBindingWrite, on as RecordBindingOptions, pn as RecordBindingWrites, rn as RecordBinding, sn as RecordBindingPermissions, tn as AnyRecordBinding, un as RecordBindingWriteInput, vn as recordEventMatches, yn as recordRowInput } from "../define-block-Xxw8Hroe.js";
4
+ import { A as BindingBlocks, B as PermissionFlags, C as defineRecordType, D as recordPermissionKeys, E as recordCan, F as LoadBindingsOptions, H as can, I as LoadedBindings, L as bindingCan, M as BindingName, N as BindingOf, O as recordSubject, P as BindingSource, R as countBinding, S as RecordWriteInput, T as plainData, U as permissionFlags, V as PermissionSet, _ as RecordTypeBlocks, b as RecordTypeWriteInput, d as BindingWritesOf, f as Plain, g as RecordType, h as RecordCan, j as BindingCheck, k as recordWriteInput, m as PlainBindings, p as PlainBinding, v as RecordTypePermissions, w as findBindingWrite, x as RecordTypeWriteOutput, y as RecordTypeSpec, z as loadBindings } from "../index-B8YjrfVl.js";
5
+ import { p as SubscriptionStatus } from "../topic-BtLz-qTI.js";
6
+ import { n as TopicPort } from "../watch-topic-tnfOTa3-.js";
7
+ import { n as Controller, t as AuthPort } from "../controller-CJUXhshv.js";
8
8
  import { a as RecordSummaryOptions, c as Subjects, f as MyWorkKind, i as RecordSummary, n as MyWorkItem, r as MyWorkOptions } from "../subjects-BpIEN1MS.js";
9
- import { a as timelineBindings, c as RecordListCells, d as RecordListQuery, f as RecordListRow, h as defineRecordList, i as loadTimeline, l as RecordListColumn, m as RecordListSpec, n as Timeline, o as RecordList, p as RecordListSource, r as TimelineEntry, s as RecordListCell, t as LoadTimelineOptions, u as RecordListPage } from "../timeline-WrFMgd3U.js";
10
- import { a as RecordFormOptions, c as recordForm, i as RecordFormInput, n as RecordFormCustomField, o as RecordFormResult, r as RecordFormField, s as RecordFormValues, t as RecordForm } from "../record-form-DB_5Ue_B.js";
9
+ import { a as timelineBindings, c as RecordListCells, d as RecordListQuery, f as RecordListRow, h as defineRecordList, i as loadTimeline, l as RecordListColumn, m as RecordListSpec, n as Timeline, o as RecordList, p as RecordListSource, r as TimelineEntry, s as RecordListCell, t as LoadTimelineOptions, u as RecordListPage } from "../timeline-BBfKuMVL.js";
10
+ import { a as RecordFormOptions, c as recordForm, i as RecordFormInput, n as RecordFormCustomField, o as RecordFormResult, r as RecordFormField, s as RecordFormValues, t as RecordForm } from "../record-form-xWvVcb86.js";
11
11
  //#region src/records/controller.d.ts
12
12
  interface RecordControllerOptions<B extends BindingBlocks, N extends BindingName<B>> extends LoadBindingsOptions<B, N> {
13
13
  readonly source: BindingSource<B>;
@@ -0,0 +1,208 @@
1
+ import { t as topicPort } from "./watch-topic-CuaWfCuv.js";
2
+ //#region src/realtime/relay.ts
3
+ const CLOSED_STATE = 2;
4
+ function parse(event) {
5
+ if (typeof event.data !== "string") return;
6
+ try {
7
+ return JSON.parse(event.data);
8
+ } catch {
9
+ return;
10
+ }
11
+ }
12
+ /** The runtime's `EventSource`, read without assuming DOM types. */
13
+ function globalEventSource() {
14
+ const value = "EventSource" in globalThis ? globalThis.EventSource : void 0;
15
+ return typeof value === "function" ? value : void 0;
16
+ }
17
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
18
+ /**
19
+ * A Realtime client that joins topics through `realtimeRelay` on the server
20
+ * instead of a browser connection with the user's token: for support sessions
21
+ * ("view as user") and apps that keep sessions in httpOnly cookies. It has the
22
+ * `RealtimeClient` surface, so `defineTopic(...).subscribe`, `send`,
23
+ * `liveQuery`, `watchTopic` and the React hooks take it unchanged. Each topic
24
+ * is one server-sent event stream that reconnects on its own and reports a
25
+ * rejoin after a gap, so live queries refetch. Presence states arrive, but
26
+ * `track` answers `error`: presence is not relayed upstream.
27
+ *
28
+ * ```ts
29
+ * const realtime = relayRealtimeClient("/api/realtime");
30
+ * using sub = notifications.subscribe(realtime, { userId }, handlers);
31
+ * ```
32
+ */
33
+ function relayRealtimeClient(url, options = {}) {
34
+ const channels = [];
35
+ const timeoutMs = options.timeoutMs ?? 15e3;
36
+ const maxBackoffMs = options.maxBackoffMs ?? 3e4;
37
+ const channelClose = /* @__PURE__ */ new WeakMap();
38
+ const post = async (topic, event, payload) => {
39
+ const doFetch = options.fetch ?? globalThis.fetch.bind(globalThis);
40
+ try {
41
+ const response = await doFetch(url, {
42
+ method: "POST",
43
+ credentials: "same-origin",
44
+ headers: { "content-type": "application/json" },
45
+ body: JSON.stringify({
46
+ topic,
47
+ event,
48
+ payload
49
+ })
50
+ });
51
+ if (response.ok) {
52
+ await response.body?.cancel();
53
+ return { success: true };
54
+ }
55
+ const problem = await response.json().catch(() => void 0);
56
+ const detail = isRecord(problem) && typeof problem["detail"] === "string" ? problem["detail"] : isRecord(problem) && typeof problem["title"] === "string" ? problem["title"] : response.statusText;
57
+ return {
58
+ success: false,
59
+ status: response.status,
60
+ error: detail
61
+ };
62
+ } catch (cause) {
63
+ return {
64
+ success: false,
65
+ status: 0,
66
+ error: cause instanceof Error ? cause.message : String(cause)
67
+ };
68
+ }
69
+ };
70
+ const create = (name) => {
71
+ const topic = `realtime:${name}`;
72
+ const listeners = [];
73
+ let presence = {};
74
+ let source;
75
+ let status;
76
+ let subscribed = false;
77
+ let ending = false;
78
+ let removed = false;
79
+ let backoff = 1e3;
80
+ let joinTimer;
81
+ let retryTimer;
82
+ const dispatch = (type, event, message) => {
83
+ for (const listener of listeners) if (listener.event === `${type}:*` || listener.event === `${type}:${event}`) listener.callback(message);
84
+ };
85
+ const open = () => {
86
+ if (removed) return;
87
+ const Source = options.EventSource ?? globalEventSource();
88
+ if (Source === void 0) {
89
+ status?.("CHANNEL_ERROR", /* @__PURE__ */ new Error("relayRealtimeClient needs EventSource"));
90
+ return;
91
+ }
92
+ const next = new Source(`${url}${url.includes("?") ? "&" : "?"}topic=${encodeURIComponent(name)}`, { withCredentials: true });
93
+ source = next;
94
+ clearTimeout(joinTimer);
95
+ joinTimer = setTimeout(() => {
96
+ if (!subscribed && source === next) status?.("TIMED_OUT");
97
+ }, timeoutMs);
98
+ next.addEventListener("status", (event) => {
99
+ const data = parse(event);
100
+ if (!isRecord(data) || source !== next) return;
101
+ if (data["status"] === "subscribed") {
102
+ clearTimeout(joinTimer);
103
+ subscribed = true;
104
+ ending = false;
105
+ backoff = 1e3;
106
+ status?.("SUBSCRIBED");
107
+ } else if (data["status"] === "error") status?.("CHANNEL_ERROR", /* @__PURE__ */ new Error(`Realtime error on ${name}`));
108
+ });
109
+ next.addEventListener("broadcast", (event) => {
110
+ const data = parse(event);
111
+ if (!isRecord(data) || typeof data["event"] !== "string") return;
112
+ dispatch("broadcast", data["event"], {
113
+ type: "broadcast",
114
+ event: data["event"],
115
+ payload: data["payload"]
116
+ });
117
+ });
118
+ next.addEventListener("presence", (event) => {
119
+ const data = parse(event);
120
+ if (!isRecord(data)) return;
121
+ presence = Object.fromEntries(Object.entries(data).filter((entry) => Array.isArray(entry[1])));
122
+ dispatch("presence", "sync", {});
123
+ });
124
+ next.addEventListener("end", () => {
125
+ ending = true;
126
+ });
127
+ next.addEventListener("error", () => {
128
+ if (removed || source !== next) return;
129
+ if (next.readyState !== CLOSED_STATE) {
130
+ if (subscribed && !ending) status?.("CHANNEL_ERROR", /* @__PURE__ */ new Error(`The relay connection for ${name} dropped`));
131
+ return;
132
+ }
133
+ next.close();
134
+ source = void 0;
135
+ if (!subscribed) {
136
+ clearTimeout(joinTimer);
137
+ status?.("CHANNEL_ERROR", /* @__PURE__ */ new Error(`The relay refused ${name}`));
138
+ return;
139
+ }
140
+ status?.("CHANNEL_ERROR", /* @__PURE__ */ new Error(`The relay closed ${name}; reconnecting`));
141
+ retryTimer = setTimeout(open, backoff);
142
+ backoff = Math.min(backoff * 2, maxBackoffMs);
143
+ });
144
+ };
145
+ const close = () => {
146
+ removed = true;
147
+ clearTimeout(joinTimer);
148
+ clearTimeout(retryTimer);
149
+ source?.close();
150
+ source = void 0;
151
+ };
152
+ const channel = {
153
+ topic,
154
+ on(type, filter, callback) {
155
+ listeners.push({
156
+ event: `${type}:${filter.event ?? "*"}`,
157
+ callback
158
+ });
159
+ return channel;
160
+ },
161
+ subscribe(callback) {
162
+ if (status !== void 0 || removed) throw new Error(`tried to subscribe multiple times to ${name} on the relay`);
163
+ status = callback ?? (() => void 0);
164
+ open();
165
+ return channel;
166
+ },
167
+ unsubscribe: () => {
168
+ close();
169
+ status?.("CLOSED");
170
+ return Promise.resolve("ok");
171
+ },
172
+ presenceState: () => presence,
173
+ track: () => Promise.resolve("error"),
174
+ untrack: () => Promise.resolve("error"),
175
+ send: async (message) => (await post(name, message.event, message.payload)).success ? "ok" : "error",
176
+ httpSend: (event, payload) => post(name, event, payload)
177
+ };
178
+ channelClose.set(channel, close);
179
+ return channel;
180
+ };
181
+ return {
182
+ channel: (name) => {
183
+ const topic = `realtime:${name}`;
184
+ const open = channels.find((each) => each.topic === topic);
185
+ if (open) return open;
186
+ const channel = create(name);
187
+ channels.push(channel);
188
+ return channel;
189
+ },
190
+ getChannels: () => [...channels],
191
+ removeChannel: (channel) => {
192
+ const index = channels.indexOf(channel);
193
+ if (index !== -1) channels.splice(index, 1);
194
+ channelClose.get(channel)?.();
195
+ return Promise.resolve("ok");
196
+ },
197
+ realtime: { setAuth: () => Promise.resolve() }
198
+ };
199
+ }
200
+ /**
201
+ * The block controllers' realtime port over `realtimeRelay`:
202
+ * `topicPort(relayRealtimeClient(url, options))`.
203
+ */
204
+ function relayTopicPort(url, options = {}) {
205
+ return topicPort(relayRealtimeClient(url, options));
206
+ }
207
+ //#endregion
208
+ export { relayTopicPort as n, relayRealtimeClient as t };
@@ -1,5 +1,5 @@
1
1
  import { n as ResourceActionSpec } from "./resource-D8pzB5Qf.js";
2
- import { i as ResourceContext, n as Parsed, r as ResourceAction, t as ActionArgs } from "./resource-types-DnKiH4G2.js";
2
+ import { i as ResourceContext, n as Parsed, r as ResourceAction, t as ActionArgs } from "./resource-types-BIoz_ElD.js";
3
3
  import { StandardSchemaV1 } from "@standard-schema/spec";
4
4
  //#region src/server/resource-execute.d.ts
5
5
  /**
@@ -1,6 +1,6 @@
1
1
  import { D as ValidationIssue, f as Result } from "./result-DZeA5KS6.js";
2
2
  import { Ft as RequestContext, K as Insert, dt as TableMeta, ht as Update, it as Row, k as AnyModels, ut as TableKey } from "./types-DFdg_4yN.js";
3
- import { Wt as SelectArg } from "./define-DFBnQyYg.js";
3
+ import { Wt as SelectArg } from "./define-Cgru0_kF.js";
4
4
  import { a as RespondOptions } from "./respond-Dn1_YhC1.js";
5
5
  import { D as ResourceOperation, k as TableVerb } from "./model-hwpvole9.js";
6
6
  import { a as ResourcePlan, i as ResourcePagination, n as ResourceActionSpec, r as ResourceDescription } from "./resource-D8pzB5Qf.js";
@@ -1,5 +1,5 @@
1
1
  import { k as AnyModels, ut as TableKey } from "./types-DFdg_4yN.js";
2
- import { l as ResourceRouteOptions } from "./resource-types-DnKiH4G2.js";
2
+ import { l as ResourceRouteOptions } from "./resource-types-BIoz_ElD.js";
3
3
  //#region src/server/resources.d.ts
4
4
  /** Resources by table name; `true` serves a table with the defaults. */
5
5
  type ResourceMap<M extends AnyModels, Ref = string, DbT = unknown> = { readonly [T in TableKey<M>]?: ResourceRouteOptions<M, T, Ref, DbT> | true; };