better-supabase 0.15.1 → 0.16.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 (272) hide show
  1. package/dist/{ai-schedules-D_Hz-ik5.d.ts → ai-schedules-BmkARmQ9.d.ts} +1 -1
  2. package/dist/{api-DxAPqMrE.d.ts → api-hHwieEfz.d.ts} +1 -1
  3. package/dist/{app-tables-CbCFSXLG.d.ts → app-tables-yMQ4ubyY.d.ts} +1 -1
  4. package/dist/astro/index.d.ts +4 -4
  5. package/dist/{auth-module-BEFESDC4.js → auth-module-BbmX-N4L.js} +12 -4
  6. package/dist/better-result/index.d.ts +2 -2
  7. package/dist/{bind-h5jre2K0.d.ts → bind-JGCPGUJh.d.ts} +4 -4
  8. package/dist/{block-env-BrfRvPrj.d.ts → block-env-y65GF_px.d.ts} +4 -4
  9. package/dist/blocks/access-requests/index.d.ts +1 -1
  10. package/dist/blocks/activities/index.d.ts +1 -1
  11. package/dist/blocks/agents/index.d.ts +1 -1
  12. package/dist/blocks/ai-cache/index.d.ts +1 -1
  13. package/dist/blocks/ai-chat/index.d.ts +4 -4
  14. package/dist/blocks/ai-files/index.d.ts +1 -1
  15. package/dist/blocks/ai-keys/index.d.ts +1 -1
  16. package/dist/blocks/ai-schedules/index.d.ts +2 -2
  17. package/dist/blocks/announcements/index.d.ts +4 -4
  18. package/dist/blocks/api-keys/index.d.ts +2 -2
  19. package/dist/blocks/approvals/index.d.ts +1 -1
  20. package/dist/blocks/assets/index.d.ts +1 -1
  21. package/dist/blocks/assignment/index.d.ts +1 -1
  22. package/dist/blocks/attachments/index.d.ts +2 -2
  23. package/dist/blocks/audit/index.d.ts +5 -5
  24. package/dist/blocks/automations/index.d.ts +3 -3
  25. package/dist/blocks/billable-time/index.d.ts +1 -1
  26. package/dist/blocks/billing/index.d.ts +3 -3
  27. package/dist/blocks/bookings/index.d.ts +2 -2
  28. package/dist/blocks/bulk/index.d.ts +1 -1
  29. package/dist/blocks/calendar/index.d.ts +2 -2
  30. package/dist/blocks/catalog/index.d.ts +1 -1
  31. package/dist/blocks/channels/index.d.ts +1 -1
  32. package/dist/blocks/collections/index.d.ts +1 -1
  33. package/dist/blocks/comments/index.d.ts +4 -4
  34. package/dist/blocks/compliance/index.d.ts +1 -1
  35. package/dist/blocks/connectors/index.d.ts +1 -1
  36. package/dist/blocks/contacts/index.d.ts +1 -1
  37. package/dist/blocks/content/index.d.ts +1 -1
  38. package/dist/blocks/contracts/index.d.ts +1 -1
  39. package/dist/blocks/courses/index.d.ts +1 -1
  40. package/dist/blocks/created-by/index.d.ts +1 -1
  41. package/dist/blocks/custom-fields/index.d.ts +1 -1
  42. package/dist/blocks/data-lifecycle/index.d.ts +1 -1
  43. package/dist/blocks/deals/index.d.ts +1 -1
  44. package/dist/blocks/dispatch/index.d.ts +1 -1
  45. package/dist/blocks/documents/index.d.ts +1 -1
  46. package/dist/blocks/domains/index.d.ts +1 -1
  47. package/dist/blocks/donations/index.d.ts +1 -1
  48. package/dist/blocks/drive/index.d.ts +1 -1
  49. package/dist/blocks/employees/index.d.ts +2 -2
  50. package/dist/blocks/enrichment/index.d.ts +1 -1
  51. package/dist/blocks/enrollments/index.d.ts +1 -1
  52. package/dist/blocks/entitlements/index.d.ts +3 -3
  53. package/dist/blocks/expenses/index.d.ts +1 -1
  54. package/dist/blocks/field-history/index.d.ts +1 -1
  55. package/dist/blocks/flags/index.d.ts +1 -1
  56. package/dist/blocks/forecasts/index.d.ts +1 -1
  57. package/dist/blocks/forms/index.d.ts +2 -2
  58. package/dist/blocks/goals/index.d.ts +1 -1
  59. package/dist/blocks/guests/index.d.ts +1 -1
  60. package/dist/blocks/hiring/index.d.ts +1 -1
  61. package/dist/blocks/identities/index.d.ts +1 -1
  62. package/dist/blocks/imports/index.d.ts +1 -1
  63. package/dist/blocks/inbox/index.d.ts +5 -5
  64. package/dist/blocks/incidents/index.d.ts +1 -1
  65. package/dist/blocks/index.d.ts +2 -2
  66. package/dist/blocks/inventory/index.d.ts +1 -1
  67. package/dist/blocks/invoices/index.d.ts +1 -1
  68. package/dist/blocks/knowledge/index.d.ts +1 -1
  69. package/dist/blocks/lead-scoring/index.d.ts +1 -1
  70. package/dist/blocks/leases/index.d.ts +1 -1
  71. package/dist/blocks/leave/index.d.ts +1 -1
  72. package/dist/blocks/ledger/index.d.ts +1 -1
  73. package/dist/blocks/mail-sync/index.d.ts +1 -1
  74. package/dist/blocks/memberships/index.d.ts +1 -1
  75. package/dist/blocks/memory/index.d.ts +1 -1
  76. package/dist/blocks/messaging/index.d.ts +4 -4
  77. package/dist/blocks/metrics/index.d.ts +1 -1
  78. package/dist/blocks/mfa/index.d.ts +2 -2
  79. package/dist/blocks/moderation/index.d.ts +1 -1
  80. package/dist/blocks/notifications/index.d.ts +4 -4
  81. package/dist/blocks/numbering/index.d.ts +1 -1
  82. package/dist/blocks/oauth-server/index.d.ts +1 -1
  83. package/dist/blocks/onboarding/index.d.ts +2 -2
  84. package/dist/blocks/orders/index.d.ts +2 -2
  85. package/dist/blocks/organizations/index.d.ts +2 -2
  86. package/dist/blocks/outbox/index.d.ts +1 -1
  87. package/dist/blocks/passes/index.d.ts +1 -1
  88. package/dist/blocks/permissions/index.d.ts +3 -3
  89. package/dist/blocks/pipelines/index.d.ts +1 -1
  90. package/dist/blocks/posts/index.d.ts +1 -1
  91. package/dist/blocks/profiles/index.d.ts +1 -1
  92. package/dist/blocks/promotions/index.d.ts +1 -1
  93. package/dist/blocks/push/index.d.ts +2 -2
  94. package/dist/blocks/queue/index.d.ts +29 -2
  95. package/dist/blocks/queue/index.js +1 -1
  96. package/dist/blocks/quotes/index.d.ts +1 -1
  97. package/dist/blocks/rank/index.d.ts +1 -1
  98. package/dist/blocks/reactions/index.d.ts +4 -4
  99. package/dist/blocks/relations/index.d.ts +1 -1
  100. package/dist/blocks/reminders/index.d.ts +1 -1
  101. package/dist/blocks/reviews/index.d.ts +1 -1
  102. package/dist/blocks/saved-views/index.d.ts +3 -3
  103. package/dist/blocks/scores/index.d.ts +1 -1
  104. package/dist/blocks/search/index.d.ts +3 -3
  105. package/dist/blocks/security-events/index.d.ts +1 -1
  106. package/dist/blocks/segments/index.d.ts +1 -1
  107. package/dist/blocks/sequences/index.d.ts +1 -1
  108. package/dist/blocks/service-accounts/index.d.ts +1 -1
  109. package/dist/blocks/sessions/index.d.ts +2 -2
  110. package/dist/blocks/settings/index.d.ts +2 -2
  111. package/dist/blocks/share-links/index.d.ts +1 -1
  112. package/dist/blocks/shipments/index.d.ts +1 -1
  113. package/dist/blocks/signatures/index.d.ts +1 -1
  114. package/dist/blocks/signing-keys/index.d.ts +1 -1
  115. package/dist/blocks/sla/index.d.ts +1 -1
  116. package/dist/blocks/sso/index.d.ts +1 -1
  117. package/dist/blocks/state-machine/index.d.ts +1 -1
  118. package/dist/blocks/subjects/index.d.ts +2 -2
  119. package/dist/blocks/tags/index.d.ts +2 -2
  120. package/dist/blocks/tasks/index.d.ts +2 -2
  121. package/dist/blocks/teams/index.d.ts +1 -1
  122. package/dist/blocks/templates/index.d.ts +1 -1
  123. package/dist/blocks/time-tracking/index.d.ts +1 -1
  124. package/dist/blocks/timeline/index.d.ts +3 -3
  125. package/dist/blocks/trash/index.d.ts +1 -1
  126. package/dist/blocks/undo/index.d.ts +2 -2
  127. package/dist/blocks/updated-at/index.d.ts +1 -1
  128. package/dist/blocks/usage/index.d.ts +2 -2
  129. package/dist/blocks/vercel-marketplace/index.d.ts +1 -1
  130. package/dist/blocks/versions/index.d.ts +1 -1
  131. package/dist/blocks/waitlist/index.d.ts +1 -1
  132. package/dist/blocks/webhooks/index.d.ts +2 -2
  133. package/dist/blocks/webhooks/index.js +1 -1
  134. package/dist/blocks/workflow-editor/index.d.ts +4 -4
  135. package/dist/blocks/workflows/index.d.ts +4 -4
  136. package/dist/{bucket-CiNi8sIw.d.ts → bucket-vc-QRrva.d.ts} +40 -1
  137. package/dist/cli/add-Bfb_ISrO.js +1 -0
  138. package/dist/cli/{add-DNOL9PDu.js → add-D7TkPdco.js} +9 -9
  139. package/dist/cli/{add-C04vkBk9.js → add-I8OW-qJH.js} +2 -2
  140. package/dist/cli/{backfill-VFzf-TJP.js → backfill-DIz5DnlQ.js} +1 -1
  141. package/dist/cli/bin.js +1 -1
  142. package/dist/cli/{blocks-Bn7WUca5.js → blocks-Bp5RPoft.js} +1 -1
  143. package/dist/cli/{blocks-Cb7mILFU.js → blocks-xk-SE8gS.js} +1 -1
  144. package/dist/cli/{cache-DkplpIGe.js → cache-AznIssjI.js} +1 -1
  145. package/dist/cli/{codemod-BbaE5dL_.js → codemod-Aewxza6i.js} +1 -1
  146. package/dist/cli/{content-mapper-Cdx6arxu.js → content-mapper-DCrz6OIv.js} +2 -2
  147. package/dist/cli/{doctor-C-VO-QQ2.js → doctor-DkOSLPEQ.js} +13 -13
  148. package/dist/cli/{gen-yRHOHW1b.js → gen-CFkYUnWq.js} +10 -10
  149. package/dist/cli/index.d.ts +1 -1
  150. package/dist/cli/index.js +6 -6
  151. package/dist/cli/{init-BOw0SX65.js → init-CHj9ad4S.js} +5 -5
  152. package/dist/cli/{live-Lmg-hYyO.js → live-DGdLR41j.js} +2 -2
  153. package/dist/cli/{mcp-DQ1zR2eA.js → mcp-BZno503V.js} +2 -2
  154. package/dist/cli/{metadata-CZaxkv21.js → metadata-BfgHMe4q.js} +3 -3
  155. package/dist/cli/{migration-safety-BbhLu2fo.js → migration-safety-BnnXPAro.js} +1 -1
  156. package/dist/cli/{module-migration-DOn6EmNz.js → module-migration-O_IxewFs.js} +1 -1
  157. package/dist/cli/{print-D_xf8PPj.js → print-DosQIFSy.js} +1 -1
  158. package/dist/cli/{remove-BY_TOTRj.js → remove-DK2G_KHm.js} +5 -5
  159. package/dist/cli/{render-lJmHr0y9.js → render-5y5a1QZr.js} +3 -3
  160. package/dist/cli/{run-BJ6IMs_H.js → run-Bs4OKdDI.js} +7 -7
  161. package/dist/cli/{run-DkB0fhc9.js → run-MRET30vh.js} +20 -20
  162. package/dist/cli/{shared-Bh-6IqJS.js → shared-BLqbvY2x.js} +1 -1
  163. package/dist/cli/{snapshot-Bzcigm7T.js → snapshot-uTUlEzY2.js} +2 -2
  164. package/dist/cli/{source-WoLdcQzN.js → source-D2gJHKwC.js} +1 -1
  165. package/dist/cli/{spec-CZMiLhv_.js → spec-Cm2einTO.js} +2 -2
  166. package/dist/cli/{spec-BF_dpwzW.js → spec-DUjOtciN.js} +1 -1
  167. package/dist/cli/{sql-layout-rFP0oq1N.js → sql-layout-lUWenjJw.js} +2 -2
  168. package/dist/cli/{sync-mANmYYoL.js → sync-CZMRB3aU.js} +2 -2
  169. package/dist/cli/{upgrade-B0Q9wMs-.js → upgrade-BFEIMC7U.js} +3 -3
  170. package/dist/cli/{upgrade-BrNLt92u.js → upgrade-fVsJniXm.js} +2 -2
  171. package/dist/cli/{version-CyavsyGA.js → version-B2Dr6VmJ.js} +1 -1
  172. package/dist/client/index.d.ts +5 -5
  173. package/dist/client/index.js +1 -1
  174. package/dist/client/native/index.d.ts +5 -5
  175. package/dist/client/native/index.js +1 -1
  176. package/dist/{client-BAEbEA7t.js → client-C_mlji5R.js} +6 -5
  177. package/dist/{composite-BZYXlVBN.d.ts → composite-CfYyU3vs.d.ts} +4 -3
  178. package/dist/config/index.d.ts +1 -1
  179. package/dist/{context-TGX2eDS5.d.ts → context-8kb8m5uO.d.ts} +1 -1
  180. package/dist/{controller-DyPPMFSw.d.ts → controller-BW-5Opig.d.ts} +1 -1
  181. package/dist/{conversion-O-kyhXcC.d.ts → conversion-3iv2r7YC.d.ts} +1 -1
  182. package/dist/create/index.d.ts +2 -2
  183. package/dist/create/index.js +1 -1
  184. package/dist/{define-DFBnQyYg.d.ts → define-C5AcEkEJ.d.ts} +1 -1
  185. package/dist/{define-block-DvvcM54N.d.ts → define-block-C1RHXz7L.d.ts} +2 -2
  186. package/dist/edge/index.d.ts +5 -5
  187. package/dist/{entitlements-BnhDBxLW.d.ts → entitlements-sO977DO-.d.ts} +1 -1
  188. package/dist/{executor-CVIn6JHa.d.ts → executor-BcNWcD-4.d.ts} +2 -2
  189. package/dist/expo/index.d.ts +2 -2
  190. package/dist/{field-errors-DYtg1mwv.d.ts → field-errors-Dt86dCKk.d.ts} +12 -12
  191. package/dist/{framework-h5lP_5yj.d.ts → framework-BGdZVyPL.d.ts} +3 -3
  192. package/dist/hono/index.d.ts +4 -4
  193. package/dist/{index-BAHGLvGD.d.ts → index-CENWq3zb.d.ts} +1 -1
  194. package/dist/{index-Do2ChN_y.d.ts → index-CQhPHHDF.d.ts} +20 -2
  195. package/dist/{index-DN9mfmhA.d.ts → index-CTu-3fJB.d.ts} +51 -3
  196. package/dist/{index-BfK6olKm.d.ts → index-Cc4mIQS8.d.ts} +2 -2
  197. package/dist/{index-BfkltrGJ.d.ts → index-CcAmFNVi.d.ts} +2 -2
  198. package/dist/{index-Ab4UeEn_.d.ts → index-Craf712U.d.ts} +44 -12
  199. package/dist/{index-B4gcStOz.d.ts → index-DZKCc2WM.d.ts} +3 -3
  200. package/dist/index.d.ts +2 -2
  201. package/dist/list/index.d.ts +1 -1
  202. package/dist/{list-query-BDVutLFr.d.ts → list-query-DYhgRTd5.d.ts} +1 -1
  203. package/dist/mapper/bin.js +5 -5
  204. package/dist/mcp/index.d.ts +3 -3
  205. package/dist/mcp/sdk/index.d.ts +2 -2
  206. package/dist/next/client/index.d.ts +81 -1
  207. package/dist/next/client/index.js +178 -2
  208. package/dist/next/index.d.ts +15 -14
  209. package/dist/orpc/index.d.ts +4 -4
  210. package/dist/otel/index.js +4 -4
  211. package/dist/{ports-DOhtuw3c.js → ports-CaVRXjxq.js} +1 -1
  212. package/dist/{ports-CpdiQv1D.d.ts → ports-mObLgH1z.d.ts} +1 -1
  213. package/dist/powersync/index.d.ts +2 -2
  214. package/dist/preset/index.d.ts +3 -3
  215. package/dist/{push-token-B3m3pWAv.d.ts → push-token-BSSvsWXZ.d.ts} +1 -1
  216. package/dist/query/index.d.ts +1 -1
  217. package/dist/{rate-limit-o44SYkVY.js → rate-limit-Dt9vAY4E.js} +53 -0
  218. package/dist/react/index.d.ts +6 -6
  219. package/dist/react/index.js +3 -3
  220. package/dist/react/native/index.d.ts +1 -1
  221. package/dist/react/native/index.js +1 -1
  222. package/dist/react/server.d.ts +12 -7
  223. package/dist/react/server.js +8 -3
  224. package/dist/react/session.d.ts +5 -0
  225. package/dist/react/session.js +9 -1
  226. package/dist/{react-BuDYI62C.js → react-CZUZYn9E.js} +41 -4
  227. package/dist/react-router/index.d.ts +3 -3
  228. package/dist/realtime/index.d.ts +5 -5
  229. package/dist/realtime/index.js +2 -1
  230. package/dist/{record-form-DB_5Ue_B.d.ts → record-form-D9ILuVtA.d.ts} +1 -1
  231. package/dist/records/index.d.ts +7 -7
  232. package/dist/relay-gKvKJ3xf.js +208 -0
  233. package/dist/{resource-execute-CzHuDsil.d.ts → resource-execute-Cpnob1Vj.d.ts} +1 -1
  234. package/dist/{resource-types-DnKiH4G2.d.ts → resource-types-pMeLs68X.d.ts} +1 -1
  235. package/dist/{resources-B9cQxhjw.d.ts → resources-7iq2-5_A.d.ts} +1 -1
  236. package/dist/server/index.d.ts +147 -9
  237. package/dist/server/index.js +396 -1
  238. package/dist/{server-types-7QPzW2bF.d.ts → server-types-CK8mUIUT.d.ts} +5 -354
  239. package/dist/{session-CfBCJGgc.d.ts → session-DWmFv3vB.d.ts} +2 -1
  240. package/dist/session-status-qQLm7jzh.d.ts +82 -0
  241. package/dist/{sign-in-BsIaNx2C.js → sign-in-CmPK1AgM.js} +20 -10
  242. package/dist/solid/index.d.ts +7 -7
  243. package/dist/solid/index.js +1 -1
  244. package/dist/solid-start/index.d.ts +3 -3
  245. package/dist/spec/index.d.ts +1 -1
  246. package/dist/sql/index.d.ts +3 -3
  247. package/dist/sql/index.js +1 -1
  248. package/dist/{sql-OLVW4t08.js → sql-Dl3Alk43.js} +127 -0
  249. package/dist/sqlite/index.d.ts +1 -1
  250. package/dist/ssr/index.d.ts +1 -1
  251. package/dist/storage/index.d.ts +3 -3
  252. package/dist/storage/index.js +54 -1
  253. package/dist/support-B4ZBVxt3.d.ts +357 -0
  254. package/dist/svelte/index.d.ts +7 -7
  255. package/dist/svelte/index.js +1 -1
  256. package/dist/sveltekit/index.d.ts +4 -4
  257. package/dist/{tags-BjHflcHF.d.ts → tags-qvVk79pp.d.ts} +1 -1
  258. package/dist/tanstack-db/index.d.ts +1 -1
  259. package/dist/tanstack-start/index.d.ts +3 -3
  260. package/dist/{tenant-DzFsg0Pc.d.ts → tenant-DOKIJI62.d.ts} +1 -1
  261. package/dist/testing/index.d.ts +8 -7
  262. package/dist/{timeline-WrFMgd3U.d.ts → timeline-CvTuXYvn.d.ts} +3 -3
  263. package/dist/{topic-DNFEFGKI.d.ts → topic-CZXHhZye.d.ts} +2 -2
  264. package/dist/{verify-CMou8dWZ.d.ts → verify-CjvNLY7N.d.ts} +1 -1
  265. package/dist/vue/index.d.ts +7 -7
  266. package/dist/vue/index.js +1 -1
  267. package/dist/{watch-topic-Bo9S2R4P.d.ts → watch-topic-BAxoPKZx.d.ts} +1 -1
  268. package/dist/yjs/index.d.ts +1 -1
  269. package/package.json +1 -1
  270. package/skills/better-supabase-api/SKILL.md +3 -1
  271. package/skills/better-supabase-auth/SKILL.md +7 -0
  272. package/dist/cli/add-CUH0rORo.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import { A as BLOCK_OPTION_SCHEMAS, O as resolveBlock, j as BlockOptionsRegistry } from "../authorization-HZdJCaVm.js";
2
- import { C as OwnView, Qn as auditRegistrations, S as BlockSqlUpgrade, T as notNullCheckName, Xn as sameTenantLayout, Yn as DeclaredForeignKey, Zn as AuditedTable, _ as BlockSqlDeprecation, a as BlockSqlContext, b as BlockSqlLayout, c as BlockSqlIdType, d as MODULE_ID_TYPES, f as contractSignature, g as BlockSqlAccessProvider, h as BlockSql, i as BlockSqlAudit, l as BlockSqlNames, m as moduleIdType, n as AuditCategory, o as BlockSqlContractFunction, p as isBlockSqlIdType, r as BlockSqlAction, s as BlockSqlEmit, t as AUDIT_CATEGORIES, u as BlockSqlTableSpec, v as BlockSqlEntitlementsProvider, w as blockSqlVersion, x as BlockSqlTestFile, y as BlockSqlFile } from "../context-TGX2eDS5.js";
3
- import { a as appTableEventTypes } from "../app-tables-CbCFSXLG.js";
4
- import { $ as modulePermissionKeys, A as sameTenantColumn, B as adoptedTables, C as extensionSchema, D as TenantQuery, E as subjectColumns, F as excludedColumns, G as DEFAULT_ROLES, H as APP_TABLES_MARKER, I as resolveExposeColumns, J as resolveBlocks, K as instanceFunctions, L as AdoptedTable, M as DataExportPlan, N as SECRET_COLUMNS, O as tenantsQuery, P as dataExportPlan, Q as moduleHidingColumns, R as AdoptedView, S as declaredViews, St as renderBlocks, T as rlsTables, U as APP_TABLES_MODULE, V as adoptedViews, W as appTablesFiles, X as BlockSqlPermissionKey, Y as BlockSqlExtension, Z as moduleEventTriggers, _ as DeclaredView, _t as upgradePlan, a as hasColumnAccess, at as moduleDataDir, b as declaredTables, bt as moduleBody, c as compileReadSets, ct as EntityRenameStep, d as migrationOptionUses, dt as currentBlockName, et as moduleSchemaExtensions, f as moduleLayout, ft as formerBlockName, g as templateFunctions, gt as moduleDeprecations, h as scopeProblems, ht as InstalledBlock, i as scopePolicyName, it as sameBlockFile, j as sameTenantTrigger, k as expiredFlagsQuery, l as sharedRolesProblems, lt as entityRenamePlan, m as resolveProviderSql, mt as BlockSqlUpgradePlan, n as widenedCommands, nt as isModuleDataFile, o as CompiledReadSet, ot as moduleFilePaths, p as SCOPE_ID_TYPES, pt as renamedBlock, q as SQL_MODULES, r as TENANT_SCOPE_POLICY, rt as moduleFileVersion, s as compileReadSet, st as EntityRenamePlan, t as declaredPolicies, tt as blockFileState, u as MigrationOptionUse, ut as BLOCK_RENAMES, v as PolicyGrant, vt as BlockSqlTopic, w as policyGrants, x as declaredUpdatedAtTriggers, xt as moduleTopics, y as declaredTableColumns, yt as customContracts, z as adoptedColumnProblems } from "../index-BfK6olKm.js";
2
+ import { C as OwnView, Qn as auditRegistrations, S as BlockSqlUpgrade, T as notNullCheckName, Xn as sameTenantLayout, Yn as DeclaredForeignKey, Zn as AuditedTable, _ as BlockSqlDeprecation, a as BlockSqlContext, b as BlockSqlLayout, c as BlockSqlIdType, d as MODULE_ID_TYPES, f as contractSignature, g as BlockSqlAccessProvider, h as BlockSql, i as BlockSqlAudit, l as BlockSqlNames, m as moduleIdType, n as AuditCategory, o as BlockSqlContractFunction, p as isBlockSqlIdType, r as BlockSqlAction, s as BlockSqlEmit, t as AUDIT_CATEGORIES, u as BlockSqlTableSpec, v as BlockSqlEntitlementsProvider, w as blockSqlVersion, x as BlockSqlTestFile, y as BlockSqlFile } from "../context-8kb8m5uO.js";
3
+ import { a as appTableEventTypes } from "../app-tables-yMQ4ubyY.js";
4
+ import { $ as modulePermissionKeys, A as sameTenantColumn, B as adoptedTables, C as extensionSchema, D as TenantQuery, E as subjectColumns, F as excludedColumns, G as DEFAULT_ROLES, H as APP_TABLES_MARKER, I as resolveExposeColumns, J as resolveBlocks, K as instanceFunctions, L as AdoptedTable, M as DataExportPlan, N as SECRET_COLUMNS, O as tenantsQuery, P as dataExportPlan, Q as moduleHidingColumns, R as AdoptedView, S as declaredViews, St as renderBlocks, T as rlsTables, U as APP_TABLES_MODULE, V as adoptedViews, W as appTablesFiles, X as BlockSqlPermissionKey, Y as BlockSqlExtension, Z as moduleEventTriggers, _ as DeclaredView, _t as upgradePlan, a as hasColumnAccess, at as moduleDataDir, b as declaredTables, bt as moduleBody, c as compileReadSets, ct as EntityRenameStep, d as migrationOptionUses, dt as currentBlockName, et as moduleSchemaExtensions, f as moduleLayout, ft as formerBlockName, g as templateFunctions, gt as moduleDeprecations, h as scopeProblems, ht as InstalledBlock, i as scopePolicyName, it as sameBlockFile, j as sameTenantTrigger, k as expiredFlagsQuery, l as sharedRolesProblems, lt as entityRenamePlan, m as resolveProviderSql, mt as BlockSqlUpgradePlan, n as widenedCommands, nt as isModuleDataFile, o as CompiledReadSet, ot as moduleFilePaths, p as SCOPE_ID_TYPES, pt as renamedBlock, q as SQL_MODULES, r as TENANT_SCOPE_POLICY, rt as moduleFileVersion, s as compileReadSet, st as EntityRenamePlan, t as declaredPolicies, tt as blockFileState, u as MigrationOptionUse, ut as BLOCK_RENAMES, v as PolicyGrant, vt as BlockSqlTopic, w as policyGrants, x as declaredUpdatedAtTriggers, xt as moduleTopics, y as declaredTableColumns, yt as customContracts, z as adoptedColumnProblems } from "../index-Cc4mIQS8.js";
5
5
  export { APP_TABLES_MARKER, APP_TABLES_MODULE, AUDIT_CATEGORIES, type AdoptedTable, type AdoptedView, type AuditCategory, type AuditedTable, BLOCK_OPTION_SCHEMAS, BLOCK_RENAMES, type BlockOptionsRegistry, type BlockSql, type BlockSqlAccessProvider, type BlockSqlAction, type BlockSqlAudit, type BlockSqlContext, type BlockSqlContractFunction, type BlockSqlDeprecation, type BlockSqlEmit, type BlockSqlEntitlementsProvider, type BlockSqlExtension, type BlockSqlFile, type BlockSqlIdType, type BlockSqlLayout, type BlockSqlNames, type BlockSqlPermissionKey, type BlockSqlTableSpec, type BlockSqlTestFile, type BlockSqlTopic, type BlockSqlUpgrade, type BlockSqlUpgradePlan, type CompiledReadSet, DEFAULT_ROLES, type DataExportPlan, type DeclaredForeignKey, type DeclaredView, type EntityRenamePlan, type EntityRenameStep, type InstalledBlock, MODULE_ID_TYPES, type MigrationOptionUse, type OwnView, type PolicyGrant, SCOPE_ID_TYPES, SECRET_COLUMNS, SQL_MODULES, TENANT_SCOPE_POLICY, type TenantQuery, adoptedColumnProblems, adoptedTables, adoptedViews, appTableEventTypes, appTablesFiles, auditRegistrations, blockFileState, blockSqlVersion, compileReadSet, compileReadSets, contractSignature, currentBlockName, customContracts, dataExportPlan, declaredPolicies, declaredTableColumns, declaredTables, declaredUpdatedAtTriggers, declaredViews, entityRenamePlan, excludedColumns, expiredFlagsQuery, extensionSchema, formerBlockName, hasColumnAccess, instanceFunctions, isBlockSqlIdType, isModuleDataFile, migrationOptionUses, moduleBody, moduleDataDir, moduleDeprecations, moduleEventTriggers, moduleFilePaths, moduleFileVersion, moduleHidingColumns, moduleIdType, moduleLayout, modulePermissionKeys, moduleSchemaExtensions, moduleTopics, notNullCheckName, policyGrants, renamedBlock, renderBlocks, resolveBlock, resolveBlocks, resolveExposeColumns, resolveProviderSql, rlsTables, sameBlockFile, sameTenantColumn, sameTenantLayout, sameTenantTrigger, scopePolicyName, scopeProblems, sharedRolesProblems, subjectColumns, templateFunctions, tenantsQuery, upgradePlan, widenedCommands };
package/dist/sql/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { A as resolveBlock, l as appTableEventTypes, v as hasColumnAccess } from "../app-tables-D29Rahtg.js";
2
2
  import { c as templateFunctions, o as resolveProviderSql, s as scopeProblems, t as SCOPE_ID_TYPES } from "../access-sql-B-MkVARa.js";
3
3
  import { Y as notNullCheckName, a as DEFAULT_ROLES } from "../workflow-sdk-Bw6_u0ar.js";
4
- import { $ as contractSignature, A as moduleFileVersion, B as resolveExposeColumns, C as APP_TABLES_MARKER, D as blockSqlVersion, E as scopePolicyName, F as moduleSchemaExtensions, G as sameTenantTrigger, H as dataExportPlan, I as SQL_MODULES, J as currentBlockName, K as migrationOptionUses, L as resolveBlocks, M as moduleEventTriggers, N as moduleHidingColumns, O as blockFileState, P as modulePermissionKeys, Q as MODULE_ID_TYPES, R as TENANT_SCOPE_POLICY, S as moduleFilePaths, T as appTablesFiles, U as subjectColumns, V as SECRET_COLUMNS, W as sameTenantColumn, X as renamedBlock, Y as formerBlockName, Z as AUDIT_CATEGORIES, _ as moduleDeprecations, a as tenantsQuery, at as declaredUpdatedAtTriggers, b as widenedCommands, c as adoptedColumnProblems, ct as policyGrants, d as instanceFunctions, et as isBlockSqlIdType, f as entityRenamePlan, g as renderBlocks, h as moduleTopics, i as moduleLayout, it as declaredTables, j as sameBlockFile, k as isModuleDataFile, l as adoptedTables, lt as rlsTables, m as moduleBody, n as compileReadSets, nt as BLOCK_OPTION_SCHEMAS, o as expiredFlagsQuery, ot as declaredViews, p as customContracts, q as BLOCK_RENAMES, r as sharedRolesProblems, rt as declaredTableColumns, s as sameTenantLayout, st as extensionSchema, t as compileReadSet, tt as moduleIdType, u as adoptedViews, ut as auditRegistrations, v as upgradePlan, w as APP_TABLES_MODULE, x as moduleDataDir, y as declaredPolicies, z as excludedColumns } from "../sql-OLVW4t08.js";
4
+ import { $ as contractSignature, A as moduleFileVersion, B as resolveExposeColumns, C as APP_TABLES_MARKER, D as blockSqlVersion, E as scopePolicyName, F as moduleSchemaExtensions, G as sameTenantTrigger, H as dataExportPlan, I as SQL_MODULES, J as currentBlockName, K as migrationOptionUses, L as resolveBlocks, M as moduleEventTriggers, N as moduleHidingColumns, O as blockFileState, P as modulePermissionKeys, Q as MODULE_ID_TYPES, R as TENANT_SCOPE_POLICY, S as moduleFilePaths, T as appTablesFiles, U as subjectColumns, V as SECRET_COLUMNS, W as sameTenantColumn, X as renamedBlock, Y as formerBlockName, Z as AUDIT_CATEGORIES, _ as moduleDeprecations, a as tenantsQuery, at as declaredUpdatedAtTriggers, b as widenedCommands, c as adoptedColumnProblems, ct as policyGrants, d as instanceFunctions, et as isBlockSqlIdType, f as entityRenamePlan, g as renderBlocks, h as moduleTopics, i as moduleLayout, it as declaredTables, j as sameBlockFile, k as isModuleDataFile, l as adoptedTables, lt as rlsTables, m as moduleBody, n as compileReadSets, nt as BLOCK_OPTION_SCHEMAS, o as expiredFlagsQuery, ot as declaredViews, p as customContracts, q as BLOCK_RENAMES, r as sharedRolesProblems, rt as declaredTableColumns, s as sameTenantLayout, st as extensionSchema, t as compileReadSet, tt as moduleIdType, u as adoptedViews, ut as auditRegistrations, v as upgradePlan, w as APP_TABLES_MODULE, x as moduleDataDir, y as declaredPolicies, z as excludedColumns } from "../sql-Dl3Alk43.js";
5
5
  export { APP_TABLES_MARKER, APP_TABLES_MODULE, AUDIT_CATEGORIES, BLOCK_OPTION_SCHEMAS, BLOCK_RENAMES, DEFAULT_ROLES, MODULE_ID_TYPES, SCOPE_ID_TYPES, SECRET_COLUMNS, SQL_MODULES, TENANT_SCOPE_POLICY, adoptedColumnProblems, adoptedTables, adoptedViews, appTableEventTypes, appTablesFiles, auditRegistrations, blockFileState, blockSqlVersion, compileReadSet, compileReadSets, contractSignature, currentBlockName, customContracts, dataExportPlan, declaredPolicies, declaredTableColumns, declaredTables, declaredUpdatedAtTriggers, declaredViews, entityRenamePlan, excludedColumns, expiredFlagsQuery, extensionSchema, formerBlockName, hasColumnAccess, instanceFunctions, isBlockSqlIdType, isModuleDataFile, migrationOptionUses, moduleBody, moduleDataDir, moduleDeprecations, moduleEventTriggers, moduleFilePaths, moduleFileVersion, moduleHidingColumns, moduleIdType, moduleLayout, modulePermissionKeys, moduleSchemaExtensions, moduleTopics, notNullCheckName, policyGrants, renamedBlock, renderBlocks, resolveBlock, resolveBlocks, resolveExposeColumns, resolveProviderSql, rlsTables, sameBlockFile, sameTenantColumn, sameTenantLayout, sameTenantTrigger, scopePolicyName, scopeProblems, sharedRolesProblems, subjectColumns, templateFunctions, tenantsQuery, upgradePlan, widenedCommands };
@@ -94909,6 +94909,133 @@ $$;
94909
94909
  revoke execute on function better_supabase.check_rate_limit(text, text, integer, interval) from public, anon, authenticated;
94910
94910
  grant execute on function better_supabase.check_rate_limit(text, text, integer, interval) to service_role;
94911
94911
 
94912
+ -- Counts one hit against several limits at once: hits is a JSON array of
94913
+ -- { scope, key, max_requests?, period? }, each with its own scope and key.
94914
+ -- The counters are locked in a fixed order and the hit counts only when every
94915
+ -- limit allows it, so a refused call leaves every counter as it was. Returns
94916
+ -- { allowed, blocked, retry_after, results }: blocked is the index of the first
94917
+ -- limit over its maximum, retry_after the longest wait of the refusing
94918
+ -- limits, and results one { allowed, remaining, retry_after } per hit.
94919
+ create or replace function better_supabase.check_rate_limits(hits jsonb)
94920
+ returns jsonb
94921
+ language plpgsql
94922
+ security definer
94923
+ set search_path = ''
94924
+ as $$
94925
+ declare
94926
+ total integer;
94927
+ scopes text[] := '{}';
94928
+ keys text[] := '{}';
94929
+ maxes integer[] := '{}';
94930
+ periods interval[] := '{}';
94931
+ used integer[] := '{}';
94932
+ starts timestamptz[] := '{}';
94933
+ hit jsonb;
94934
+ rule better_supabase.rate_limit_rules;
94935
+ counter better_supabase.rate_limits;
94936
+ limit_max integer;
94937
+ limit_period interval;
94938
+ current_hits integer;
94939
+ first_blocked integer;
94940
+ longest integer := 0;
94941
+ passed boolean;
94942
+ results jsonb := '[]'::jsonb;
94943
+ begin
94944
+ if jsonb_typeof(hits) is distinct from 'array' or jsonb_array_length(hits) = 0 then
94945
+ raise exception 'check_rate_limits needs a non-empty array of hits'
94946
+ using errcode = '22023', hint = 'RATE_LIMIT_HITS';
94947
+ end if;
94948
+ total := jsonb_array_length(hits);
94949
+ for i in 1 .. total loop
94950
+ hit := hits -> (i - 1);
94951
+ if coalesce(hit ->> 'scope', '') = '' or (hit ->> 'key') is null then
94952
+ raise exception 'Hit % of check_rate_limits needs a scope and a key', i - 1
94953
+ using errcode = '22023', hint = 'RATE_LIMIT_HITS';
94954
+ end if;
94955
+ select * into rule from better_supabase.rate_limit_rules r where r.scope = hit ->> 'scope';
94956
+ limit_max := coalesce((hit ->> 'max_requests')::integer, rule.max_requests);
94957
+ limit_period := coalesce((hit ->> 'period')::interval, rule.period);
94958
+ if limit_max is null or limit_period is null then
94959
+ raise exception 'No rate limit for %: call set_rate_limit or pass max_requests and period', hit ->> 'scope'
94960
+ using errcode = '22023', hint = 'RATE_LIMIT_UNKNOWN';
94961
+ end if;
94962
+ if limit_max < 1 or limit_period <= interval '0' then
94963
+ raise exception 'The rate limit for % needs a positive max_requests and period', hit ->> 'scope'
94964
+ using errcode = '22023', hint = 'RATE_LIMIT_HITS';
94965
+ end if;
94966
+ for j in 1 .. i - 1 loop
94967
+ if scopes[j] = hit ->> 'scope' and keys[j] = hit ->> 'key' then
94968
+ raise exception 'Hits % and % of check_rate_limits count the same scope % and key; give each limit its own scope', j - 1, i - 1, hit ->> 'scope'
94969
+ using errcode = '22023', hint = 'RATE_LIMIT_HITS';
94970
+ end if;
94971
+ end loop;
94972
+ scopes := scopes || (hit ->> 'scope');
94973
+ keys := keys || (hit ->> 'key');
94974
+ maxes := maxes || limit_max;
94975
+ periods := periods || limit_period;
94976
+ end loop;
94977
+
94978
+ insert into better_supabase.rate_limits as l (scope, key, window_start, hits, period)
94979
+ select u.scope, u.key, now(), 0, u.period
94980
+ from unnest(scopes, keys, periods) as u(scope, key, period)
94981
+ order by u.scope, u.key
94982
+ on conflict on constraint rate_limits_pkey do nothing;
94983
+
94984
+ perform 1
94985
+ from better_supabase.rate_limits l
94986
+ join unnest(scopes, keys) as u(scope, key) on l.scope = u.scope and l.key = u.key
94987
+ order by l.scope, l.key
94988
+ for update of l;
94989
+
94990
+ for i in 1 .. total loop
94991
+ select * into counter from better_supabase.rate_limits l
94992
+ where l.scope = scopes[i] and l.key = keys[i];
94993
+ if counter.window_start + periods[i] <= now() then
94994
+ used := used || 0;
94995
+ starts := starts || now();
94996
+ else
94997
+ used := used || counter.hits;
94998
+ starts := starts || counter.window_start;
94999
+ end if;
95000
+ if used[i] + 1 > maxes[i] then
95001
+ longest := greatest(longest, greatest(1, ceil(extract(epoch from starts[i] + periods[i] - now()))::integer));
95002
+ first_blocked := coalesce(first_blocked, i - 1);
95003
+ end if;
95004
+ end loop;
95005
+
95006
+ passed := first_blocked is null;
95007
+
95008
+ if passed then
95009
+ for i in 1 .. total loop
95010
+ update better_supabase.rate_limits l set
95011
+ window_start = starts[i],
95012
+ hits = used[i] + 1,
95013
+ period = periods[i]
95014
+ where l.scope = scopes[i] and l.key = keys[i];
95015
+ end loop;
95016
+ end if;
95017
+
95018
+ for i in 1 .. total loop
95019
+ current_hits := used[i] + case when passed then 1 else 0 end;
95020
+ results := results || jsonb_build_array(jsonb_build_object(
95021
+ 'allowed', used[i] + 1 <= maxes[i],
95022
+ 'remaining', greatest(maxes[i] - current_hits, 0),
95023
+ 'retry_after', case when used[i] + 1 <= maxes[i] then 0
95024
+ else greatest(1, ceil(extract(epoch from starts[i] + periods[i] - now()))::integer) end
95025
+ ));
95026
+ end loop;
95027
+
95028
+ return jsonb_build_object(
95029
+ 'allowed', passed,
95030
+ 'blocked', first_blocked,
95031
+ 'retry_after', longest,
95032
+ 'results', results
95033
+ );
95034
+ end
95035
+ $$;
95036
+ revoke execute on function better_supabase.check_rate_limits(jsonb) from public, anon, authenticated;
95037
+ grant execute on function better_supabase.check_rate_limits(jsonb) to service_role;
95038
+
94912
95039
  -- Deletes up to batch counters whose window has ended: the period the
94913
95040
  -- counter was last hit with, else its rule's, else a day (counters from
94914
95041
  -- before the period column). Every caller keeps a row until then, so
@@ -1,6 +1,6 @@
1
1
  import { Bt as Executor } from "../types-DFdg_4yN.js";
2
2
  import { c as LocalTablesOption, n as DataEngine, s as LiveEngineOptions } from "../data-engine-BWoz9lED.js";
3
- import { i as fromSqliteError, n as SqliteDatabaseLike, o as CheckSqliteOptions, r as SqliteExecutorOptions, s as checkSqlite, t as SqliteContextLike } from "../executor-CVIn6JHa.js";
3
+ import { i as fromSqliteError, n as SqliteDatabaseLike, o as CheckSqliteOptions, r as SqliteExecutorOptions, s as checkSqlite, t as SqliteContextLike } from "../executor-BcNWcD-4.js";
4
4
  //#region src/sqlite/engine.d.ts
5
5
  /** A SQLite database that may report which tables changed. */
6
6
  interface ChangingSqliteDatabase extends SqliteDatabaseLike {
@@ -1,6 +1,6 @@
1
1
  import { C as readSession, D as writeSession, E as sessionEncoding, S as pruneSessionChunks, T as sessionCookieName, _ as StoredSession, a as ResolveAuthOptions, b as clearSessionAtScopes, d as CookieOptions, f as CookieRecord, g as SessionEncoding, h as DEFAULT_SESSION_ENCODING, l as resolveAuth, m as CookieWrite, n as AuthResolver, p as CookieScope, r as AuthState, t as AuthResolution, u as AUTH_CACHE_HEADERS, v as WriteSessionOptions, w as serializeCookie, x as parseCookies, y as applyCookieWrites } from "../resolve-CXX6DHv3.js";
2
2
  import { n as toSession, t as AuthSession } from "../view-DyFdMCqg.js";
3
- import { r as MembershipClaim } from "../entitlements-BnhDBxLW.js";
3
+ import { r as MembershipClaim } from "../entitlements-sO977DO-.js";
4
4
  import { n as RefreshOutcome, r as refreshSession, t as RefreshOptions } from "../refresh-DT_ICaK-.js";
5
5
  import { a as sessionStatus, i as clearSessionCookies, n as SessionStatus, o as authContext, r as SessionStatusOptions, t as ClearSessionCookiesOptions } from "../ended-gUsMZVNg.js";
6
6
  export { AUTH_CACHE_HEADERS, type AuthResolution, type AuthResolver, type AuthSession, type AuthState, type ClearSessionCookiesOptions, type CookieOptions, type CookieRecord, type CookieScope, type CookieWrite, DEFAULT_SESSION_ENCODING, type MembershipClaim, type RefreshOptions, type RefreshOutcome, type ResolveAuthOptions, type SessionEncoding, type SessionStatus, type SessionStatusOptions, type StoredSession, type WriteSessionOptions, applyCookieWrites, authContext, clearSessionAtScopes, clearSessionCookies, parseCookies, pruneSessionChunks, readSession, refreshSession, resolveAuth, serializeCookie, sessionCookieName, sessionEncoding, sessionStatus, toSession, writeSession };
@@ -1,4 +1,4 @@
1
1
  import { E as AccessPolicySql, T as AccessBucketPolicy, _t as BucketLifecycle, bt as VersioningStatus, vt as BucketLifecycleRule, yt as ObjectVersion } from "../types-DFdg_4yN.js";
2
- import { $ as TemplateValues, A as StorageBucketApi, B as StorageListV2Result, C as UploadOptions, D as TTL, E as parseSize, F as StorageFetchParameters, G as StorageSearchV2Options, H as StorageRemoveEntry, I as StorageFileOptions, J as StorageUrlOptions, K as StorageSignedUrlEntry, L as StorageListEntry, M as StorageDestinationOptions, N as StorageDownloadOptions, O as TtlPreset, P as StorageFailure, Q as TemplateParams, R as StorageListV2Folder, S as UploadBody, T as defineBucket, U as StorageResponse, V as StorageObjectInfo, W as StorageSearchOptions, X as StoragePath, Y as PathIn, Z as AppliedBucket, _ as StoredObject, a as BucketConnectOptions, b as TransferOptions, c as DownloadOptions, d as PathValues, f as PurgeCacheOptions, g as StorageAdminClient, h as Reservation, i as BucketConfig, j as StorageClient, k as StorageApi, l as ImageTransform, m as ReplaceResult, n as Bucket, o as BucketDrift, p as ReplaceOptions, q as StorageTransform, r as BucketClient, s as BucketPolicy, t as ActualBucket, u as ObjectTarget, v as SweepOptions, w as UrlOptions, x as TransformOptions, y as SweepResult, z as StorageListV2Object } from "../bucket-CiNi8sIw.js";
3
- import { A as StoredRef, C as AnyBucket, D as Buckets, E as BucketWithId, F as storageImageUrl, I as fromStorageError, M as StorageImageOptions, N as StorageImageSize, O as ConnectedRef, P as storageImageSrcSet, S as organizationLogoBucket, T as BucketMap, _ as IMAGE_TYPES, a as VectorHit, b as OrganizationLogoBucketOptions, c as VectorMetadata, d as defineVectorBucket, f as AnalyticsBucket, g as AvatarBucketOptions, h as defineAnalyticsBucket, i as VectorDistance, j as defineBuckets, k as ResolvedRef, l as VectorQueryOptions, m as AnalyticsCatalog, n as VectorBucketClient, o as VectorIndexClient, p as AnalyticsBucketClient, r as VectorBucketConfig, s as VectorIndexConfig, t as VectorBucket, u as VectorRecord, v as ImageBucketOptions, w as BucketIdOf, x as avatarBucket, y as ImageVariant } from "../index-Do2ChN_y.js";
4
- export { type AccessBucketPolicy, type AccessPolicySql, type ActualBucket, type AnalyticsBucket, type AnalyticsBucketClient, type AnalyticsCatalog, type AnyBucket, type AppliedBucket, type AvatarBucketOptions, type Bucket, type BucketClient, type BucketConfig, type BucketConnectOptions, type BucketDrift, type BucketIdOf, type BucketLifecycle, type BucketLifecycleRule, type BucketMap, type BucketPolicy, type BucketWithId, type Buckets, type ConnectedRef, type DownloadOptions, IMAGE_TYPES, type ImageBucketOptions, type ImageTransform, type ImageVariant, type ObjectTarget, type ObjectVersion, type OrganizationLogoBucketOptions, type PathIn, type PathValues, type PurgeCacheOptions, type ReplaceOptions, type ReplaceResult, type Reservation, type ResolvedRef, type StorageAdminClient, type StorageApi, type StorageBucketApi, type StorageClient, type StorageDestinationOptions, type StorageDownloadOptions, type StorageFailure, type StorageFetchParameters, type StorageFileOptions, type StorageImageOptions, type StorageImageSize, type StorageListEntry, type StorageListV2Folder, type StorageListV2Object, type StorageListV2Result, type StorageObjectInfo, type StoragePath, type StorageRemoveEntry, type StorageResponse, type StorageSearchOptions, type StorageSearchV2Options, type StorageSignedUrlEntry, type StorageTransform, type StorageUrlOptions, type StoredObject, type StoredRef, type SweepOptions, type SweepResult, TTL, type TemplateParams, type TemplateValues, type TransferOptions, type TransformOptions, type TtlPreset, type UploadBody, type UploadOptions, type UrlOptions, type VectorBucket, type VectorBucketClient, type VectorBucketConfig, type VectorDistance, type VectorHit, type VectorIndexClient, type VectorIndexConfig, type VectorMetadata, type VectorQueryOptions, type VectorRecord, type VersioningStatus, avatarBucket, defineAnalyticsBucket, defineBucket, defineBuckets, defineVectorBucket, fromStorageError, organizationLogoBucket, parseSize, storageImageSrcSet, storageImageUrl };
2
+ import { $ as AppliedBucket, A as TtlPreset, B as StorageListV2Folder, C as TransformOptions, D as defineBucket, E as UrlOptions, F as StorageDownloadOptions, G as StorageResponse, H as StorageListV2Result, I as StorageFailure, J as StorageSignedUrlEntry, K as StorageSearchOptions, L as StorageFetchParameters, M as StorageBucketApi, N as StorageClient, O as parseSize, P as StorageDestinationOptions, Q as StoragePath, R as StorageFileOptions, S as TransferOptions, T as UploadOptions, U as StorageObjectInfo, V as StorageListV2Object, W as StorageRemoveEntry, X as StorageUrlOptions, Y as StorageTransform, Z as PathIn, _ as ResumableReservation, a as BucketConnectOptions, b as SweepOptions, c as DownloadOptions, d as PathValues, et as TemplateParams, f as PurgeCacheOptions, g as ReserveResumableOptions, h as Reservation, i as BucketConfig, j as StorageApi, k as TTL, l as ImageTransform, m as ReplaceResult, n as Bucket, o as BucketDrift, p as ReplaceOptions, q as StorageSearchV2Options, r as BucketClient, s as BucketPolicy, t as ActualBucket, tt as TemplateValues, u as ObjectTarget, v as StorageAdminClient, w as UploadBody, x as SweepResult, y as StoredObject, z as StorageListEntry } from "../bucket-vc-QRrva.js";
3
+ import { A as ConnectedRef, C as avatarBucket, D as BucketMap, E as BucketIdOf, F as StorageImageSize, I as storageImageSrcSet, L as storageImageUrl, M as StoredRef, N as defineBuckets, O as BucketWithId, P as StorageImageOptions, R as fromStorageError, S as OrganizationLogoBucketOptions, T as AnyBucket, _ as defineAnalyticsBucket, a as VectorBucketConfig, b as ImageBucketOptions, c as VectorIndexClient, d as VectorQueryOptions, f as VectorRecord, g as AnalyticsCatalog, h as AnalyticsBucketClient, i as VectorBucketClient, j as ResolvedRef, k as Buckets, l as VectorIndexConfig, m as AnalyticsBucket, n as resumableEndpoint, o as VectorDistance, p as defineVectorBucket, r as VectorBucket, s as VectorHit, t as ResumableEndpointOptions, u as VectorMetadata, v as AvatarBucketOptions, w as organizationLogoBucket, x as ImageVariant, y as IMAGE_TYPES } from "../index-CQhPHHDF.js";
4
+ export { type AccessBucketPolicy, type AccessPolicySql, type ActualBucket, type AnalyticsBucket, type AnalyticsBucketClient, type AnalyticsCatalog, type AnyBucket, type AppliedBucket, type AvatarBucketOptions, type Bucket, type BucketClient, type BucketConfig, type BucketConnectOptions, type BucketDrift, type BucketIdOf, type BucketLifecycle, type BucketLifecycleRule, type BucketMap, type BucketPolicy, type BucketWithId, type Buckets, type ConnectedRef, type DownloadOptions, IMAGE_TYPES, type ImageBucketOptions, type ImageTransform, type ImageVariant, type ObjectTarget, type ObjectVersion, type OrganizationLogoBucketOptions, type PathIn, type PathValues, type PurgeCacheOptions, type ReplaceOptions, type ReplaceResult, type Reservation, type ReserveResumableOptions, type ResolvedRef, type ResumableEndpointOptions, type ResumableReservation, type StorageAdminClient, type StorageApi, type StorageBucketApi, type StorageClient, type StorageDestinationOptions, type StorageDownloadOptions, type StorageFailure, type StorageFetchParameters, type StorageFileOptions, type StorageImageOptions, type StorageImageSize, type StorageListEntry, type StorageListV2Folder, type StorageListV2Object, type StorageListV2Result, type StorageObjectInfo, type StoragePath, type StorageRemoveEntry, type StorageResponse, type StorageSearchOptions, type StorageSearchV2Options, type StorageSignedUrlEntry, type StorageTransform, type StorageUrlOptions, type StoredObject, type StoredRef, type SweepOptions, type SweepResult, TTL, type TemplateParams, type TemplateValues, type TransferOptions, type TransformOptions, type TtlPreset, type UploadBody, type UploadOptions, type UrlOptions, type VectorBucket, type VectorBucketClient, type VectorBucketConfig, type VectorDistance, type VectorHit, type VectorIndexClient, type VectorIndexConfig, type VectorMetadata, type VectorQueryOptions, type VectorRecord, type VersioningStatus, avatarBucket, defineAnalyticsBucket, defineBucket, defineBuckets, defineVectorBucket, fromStorageError, organizationLogoBucket, parseSize, resumableEndpoint, storageImageSrcSet, storageImageUrl };
@@ -4,6 +4,7 @@ import { c as optionalTemporal, n as isInstant } from "../temporal-DLZlWbOi.js";
4
4
  import { n as temporalMissing } from "../temporal-required-Dy0GGD8E.js";
5
5
  import { a as ok, r as err, s as toDbError, t as AsyncResult } from "../result-ntFBW2p2.js";
6
6
  import { a as spansAllTenants } from "../plugin-AKwwe2gF.js";
7
+ import { n as decodeJwtPayload } from "../base64-B9Wlsdj7.js";
7
8
  import { a as tenantClaimPaths, o as tenantFrom, s as tenantPathsFor } from "../claims-Bp9My7XP.js";
8
9
  import { a as sqlString, i as sqlIdent, n as parseTemplate, r as slug, t as claimSql } from "../template-Drgg3v2J.js";
9
10
  import { r as accessCheck } from "../access-sql-B-MkVARa.js";
@@ -281,6 +282,38 @@ function parseFailure(status, text) {
281
282
  };
282
283
  }
283
284
  //#endregion
285
+ //#region src/storage/resumable.ts
286
+ /** Storage signs upload tokens for two hours. */
287
+ const UPLOAD_TOKEN_SECONDS = 7200;
288
+ const HOSTED = /^(?<ref>[a-z0-9-]+)\.supabase\.co$/i;
289
+ const SIGNED_UPLOAD = "/object/upload/sign/";
290
+ const STORAGE_PATH = "/storage/v1";
291
+ /**
292
+ * The TUS endpoint for a signed resumable upload,
293
+ * `<storage>/upload/resumable/sign`. `url` is the project URL (`SUPABASE_URL`),
294
+ * the Storage URL (`.../storage/v1`) or a signed upload URL from
295
+ * `createSignedUploadUrl`.
296
+ */
297
+ function resumableEndpoint(url, options = {}) {
298
+ const parsed = new URL(url);
299
+ const path = parsed.pathname;
300
+ const storage = path.indexOf(STORAGE_PATH);
301
+ const signed = path.indexOf(SIGNED_UPLOAD);
302
+ const base = storage === -1 ? signed === -1 ? `${path.replace(/\/+$/, "")}${STORAGE_PATH}` : path.slice(0, signed) : path.slice(0, storage + 11);
303
+ const hosted = HOSTED.exec(parsed.hostname);
304
+ if ((options.direct ?? true) && hosted?.groups?.["ref"] !== void 0) parsed.hostname = `${hosted.groups["ref"]}.storage.supabase.co`;
305
+ parsed.pathname = `${base}/upload/resumable/sign`;
306
+ parsed.search = "";
307
+ parsed.hash = "";
308
+ return parsed.toString();
309
+ }
310
+ /** When a signed upload token expires: its `exp`, else two hours from `now`. */
311
+ function uploadTokenExpiry(token, now) {
312
+ const exp = decodeJwtPayload(token)?.["exp"];
313
+ const seconds = typeof exp === "number" && Number.isFinite(exp) ? exp : Math.floor(now / 1e3) + UPLOAD_TOKEN_SECONDS;
314
+ return (/* @__PURE__ */ new Date(seconds * 1e3)).toISOString();
315
+ }
316
+ //#endregion
284
317
  //#region src/storage/storage-api.ts
285
318
  /** The `StorageApi` of a client, or the client itself. */
286
319
  function storageApiOf(client) {
@@ -673,6 +706,26 @@ function connectBucket(bucket, client, resolveTarget, connectOptions, guard) {
673
706
  signedUrl: data.signedUrl
674
707
  }));
675
708
  }),
709
+ reserveResumable: (target, options) => AsyncResult.from(async () => {
710
+ const path = resolve(target);
711
+ const upsert = options?.upsert ?? false;
712
+ return run(() => api().createSignedUploadUrl(path, upsert ? { upsert } : void 0)).map((data) => ({
713
+ path: data.path,
714
+ token: data.token,
715
+ signedUrl: data.signedUrl,
716
+ bucket: bucket.id,
717
+ tusEndpoint: resumableEndpoint(data.signedUrl, options?.direct === void 0 ? {} : { direct: options.direct }),
718
+ expiresAt: uploadTokenExpiry(data.token, options?.now?.() ?? Date.now()),
719
+ headers: {
720
+ "x-signature": data.token,
721
+ "x-upsert": upsert ? "true" : "false"
722
+ },
723
+ metadata: {
724
+ bucketName: bucket.id,
725
+ objectName: data.path
726
+ }
727
+ }));
728
+ }),
676
729
  uploadReserved: (reservation, body, options) => AsyncResult.from(async () => {
677
730
  options?.signal?.throwIfAborted();
678
731
  const path = resolve(reservation.path);
@@ -1412,4 +1465,4 @@ function connectVectorBucket(config, client) {
1412
1465
  };
1413
1466
  }
1414
1467
  //#endregion
1415
- export { IMAGE_TYPES, TTL, avatarBucket, defineAnalyticsBucket, defineBucket, defineBuckets, defineVectorBucket, fromStorageError, organizationLogoBucket, parseSize, storageImageSrcSet, storageImageUrl };
1468
+ export { IMAGE_TYPES, TTL, avatarBucket, defineAnalyticsBucket, defineBucket, defineBuckets, defineVectorBucket, fromStorageError, organizationLogoBucket, parseSize, resumableEndpoint, storageImageSrcSet, storageImageUrl };
@@ -0,0 +1,357 @@
1
+ /// <reference lib="esnext.temporal" />
2
+ import { t as AsyncResult } from "./result-DZeA5KS6.js";
3
+ import { o as EventHub } from "./events-vcqenSYU.js";
4
+ import { r as AuthState } from "./resolve-CXX6DHv3.js";
5
+ import { a as ProblemFormat } from "./problem-DNwN8iGz.js";
6
+ import { _ as SupportAuthorize, i as AuthorizationHooks } from "./authorization-hooks-D_pwXlBs.js";
7
+ import { t as BetterPostgres } from "./pool-CrtT4dg-.js";
8
+ import { StandardSchemaV1 } from "@standard-schema/spec";
9
+ //#region src/auth/support.d.ts
10
+ type SupportEndedBy = "admin" | "expired" | "revoked";
11
+ /** A support session: a platform admin viewing the app as `targetUserId`. */
12
+ interface SupportSession {
13
+ readonly id: string;
14
+ readonly adminId: string;
15
+ readonly targetUserId: string;
16
+ readonly reason: string;
17
+ /** Writes fail while it is true (`begin read only`). */
18
+ readonly readOnly: boolean;
19
+ readonly tenant?: string;
20
+ readonly startedAt: Temporal.Instant;
21
+ readonly expiresAt: Temporal.Instant;
22
+ readonly endedAt?: Temporal.Instant;
23
+ readonly endedBy?: SupportEndedBy;
24
+ /** App data, such as a ticket id. */
25
+ readonly metadata: Readonly<Record<string, unknown>>;
26
+ }
27
+ interface SupportStartInput {
28
+ readonly adminId: string;
29
+ /**
30
+ * The admin's verified claims. The SQL store runs `start_support_session`
31
+ * with them, so `is_platform()` checks the admin in the database too.
32
+ */
33
+ readonly adminClaims: Readonly<Record<string, unknown>>;
34
+ readonly targetUserId: string;
35
+ readonly reason: string;
36
+ readonly ttlSeconds: number;
37
+ readonly readOnly: boolean;
38
+ readonly tenant?: string;
39
+ readonly metadata: Readonly<Record<string, unknown>>;
40
+ /** The approved request this start uses, when the server found one. */
41
+ readonly requestId?: string;
42
+ }
43
+ /**
44
+ * A request for a support session that waits for a second admin. A start uses
45
+ * an approved request once; `approvedBy` is never `adminId`.
46
+ */
47
+ interface SupportRequest {
48
+ readonly id: string;
49
+ readonly adminId: string;
50
+ readonly targetUserId: string;
51
+ readonly reason: string;
52
+ readonly readOnly: boolean;
53
+ readonly tenant?: string;
54
+ readonly metadata: Readonly<Record<string, unknown>>;
55
+ readonly requestedAt: Temporal.Instant;
56
+ /** An unapproved or unused request is closed after this. */
57
+ readonly expiresAt: Temporal.Instant;
58
+ readonly approvedBy?: string;
59
+ readonly approvedAt?: Temporal.Instant;
60
+ /** The session the approval started. */
61
+ readonly sessionId?: string;
62
+ }
63
+ interface SupportRequestInput {
64
+ readonly adminId: string;
65
+ /** The admin's verified claims; the SQL store asks as the admin with them. */
66
+ readonly adminClaims: Readonly<Record<string, unknown>>;
67
+ readonly targetUserId: string;
68
+ readonly reason: string;
69
+ readonly readOnly: boolean;
70
+ readonly tenant?: string;
71
+ readonly metadata: Readonly<Record<string, unknown>>;
72
+ /**
73
+ * An approver the server's authorization hook already decided, never the
74
+ * admin. The SQL store then records the request approved, over the admin
75
+ * connection.
76
+ */
77
+ readonly approvedBy?: string;
78
+ }
79
+ /**
80
+ * Who approves a request: with `claims` the store runs as them and decides
81
+ * eligibility itself.
82
+ */
83
+ interface SupportApprover {
84
+ readonly id: string;
85
+ readonly claims?: SupportCallerClaims;
86
+ }
87
+ /** What `approvedRequest` looks up. */
88
+ interface SupportApprovalQuery {
89
+ readonly adminId: string;
90
+ readonly targetUserId: string;
91
+ readonly tenant?: string;
92
+ readonly readOnly: boolean;
93
+ }
94
+ /** A caller's verified claims, which the store runs a call with. */
95
+ type SupportCallerClaims = Readonly<Record<string, unknown>>;
96
+ interface SupportListFilter {
97
+ readonly adminId?: string;
98
+ readonly targetUserId?: string;
99
+ /** `true`: running sessions only; `false`: ended or expired ones only. */
100
+ readonly active?: boolean;
101
+ /** Defaults to 50. */
102
+ readonly limit?: number;
103
+ }
104
+ /**
105
+ * Where support sessions live. `sqlSupportStore` uses the `impersonation` SQL
106
+ * module; implement this for another store and check it with
107
+ * `testSupportSessionStore` from `better-supabase/testing`.
108
+ */
109
+ interface SupportSessionStore {
110
+ readonly apiVersion: 1;
111
+ readonly name: string;
112
+ /**
113
+ * Starts a session and ends the admin's previous one. Rejects when the store
114
+ * refuses.
115
+ */
116
+ start(input: SupportStartInput): Promise<SupportSession>;
117
+ /**
118
+ * The admin's session while it is running; `undefined` once ended or expired.
119
+ * With the admin's `claims`, the store also checks that the admin may still
120
+ * start sessions.
121
+ */
122
+ get(sessionId: string, adminId: string, claims?: SupportCallerClaims): Promise<SupportSession | undefined>;
123
+ /**
124
+ * `false` when it was not running. With `claims`, it runs as that caller: the
125
+ * session's admin, or staff with the revoke permission.
126
+ */
127
+ end(sessionId: string, endedBy: SupportEndedBy, claims?: SupportCallerClaims): Promise<boolean>;
128
+ /** With `claims`, only what that caller may view. */
129
+ list(filter?: SupportListFilter, claims?: SupportCallerClaims): Promise<readonly SupportSession[]>;
130
+ /** The claims `targetUserId` would get, when the store can build them. */
131
+ claims?(targetUserId: string): Promise<Readonly<Record<string, unknown>>>;
132
+ /**
133
+ * Ends every running session past its expiry with `endedBy: "expired"` and
134
+ * returns them. Optional; `support.expire()` fails without it.
135
+ */
136
+ expire?(): Promise<readonly SupportSession[]>;
137
+ /**
138
+ * The store with `namespace` for its time values, unless it was given one
139
+ * itself. Optional; `createServer` calls it with the definition's
140
+ * `temporal`.
141
+ */
142
+ withTemporal?(namespace: typeof Temporal): SupportSessionStore;
143
+ /**
144
+ * Records a request for a session that waits for a second admin. Optional;
145
+ * without it and the two methods below, starts that need an approval are
146
+ * refused.
147
+ */
148
+ request?(input: SupportRequestInput): Promise<SupportRequest>;
149
+ /** A request by id, or `undefined`. */
150
+ getRequest?(requestId: string): Promise<SupportRequest | undefined>;
151
+ /** Approves a request. Rejects when the approver is the requester. */
152
+ approve?(requestId: string, approver: SupportApprover): Promise<SupportRequest>;
153
+ /** The approved, unused, unexpired request a start would use, or `undefined`. */
154
+ approvedRequest?(query: SupportApprovalQuery): Promise<SupportRequest | undefined>;
155
+ }
156
+ interface SqlSupportStoreOptions {
157
+ /** `blocks.impersonation.schema`. Defaults to `better_supabase`. */
158
+ readonly schema?: string;
159
+ /**
160
+ * The Temporal namespace for the sessions' time values, for runtimes without
161
+ * a global one. Defaults to the one `createServer` passes from the
162
+ * definition, then the provided or global Temporal.
163
+ */
164
+ readonly temporal?: typeof Temporal;
165
+ }
166
+ /**
167
+ * Support sessions in the `impersonation` SQL module. `start` runs as the
168
+ * admin, so the module's `is_platform()` gate applies; the reads run on the
169
+ * admin connection.
170
+ */
171
+ declare function sqlSupportStore(postgres: Pick<BetterPostgres, "admin" | "asUser">, options?: SqlSupportStoreOptions): SupportSessionStore;
172
+ /**
173
+ * The claims a support session runs with: the target's, plus `act` naming the
174
+ * admin, the reason and the session (the audit module records all three),
175
+ * marked `kind: "support"` so `actorOf` never reads it as an OAuth client.
176
+ * `role` falls back to `authenticated`; the admin's claims never leak in.
177
+ */
178
+ declare function supportClaims(session: Pick<SupportSession, "id" | "adminId" | "targetUserId" | "reason" | "readOnly">, target: Readonly<Record<string, unknown>>): Record<string, unknown>;
179
+ //#endregion
180
+ //#region src/auth/support-cookie.d.ts
181
+ /** The cookie that carries the support session id. */
182
+ declare const SUPPORT_COOKIE = "bsb-support";
183
+ interface SupportCookieOptions {
184
+ /** Defaults to `bsb-support`. */
185
+ readonly name?: string;
186
+ /** Defaults to `/`. */
187
+ readonly path?: string;
188
+ /** Defaults to true; set false for plain-HTTP local development. */
189
+ readonly secure?: boolean;
190
+ }
191
+ /**
192
+ * `Set-Cookie` for a session: HttpOnly, SameSite=Lax, gone when the session
193
+ * expires.
194
+ */
195
+ declare function supportCookie(session: Pick<SupportSession, "id" | "expiresAt">, options?: SupportCookieOptions, now?: number): string;
196
+ /** `Set-Cookie` that removes the support cookie. */
197
+ declare function clearSupportCookie(options?: SupportCookieOptions): string;
198
+ /** The support session id in a `Cookie` header, or `undefined`. */
199
+ declare function supportCookieValue(cookieHeader: string | null, name?: string): string | undefined;
200
+ //#endregion
201
+ //#region src/server/support.d.ts
202
+ interface SupportPolicy {
203
+ /** Seconds a session lasts. Defaults to 1800 (30 minutes). */
204
+ readonly ttl?: number;
205
+ /** The longest `ttl` a start may ask for. Defaults to 14400 (4 hours). */
206
+ readonly maxTtl?: number;
207
+ /** Defaults to true. */
208
+ readonly requireReason?: boolean;
209
+ /**
210
+ * `always` (the default): every session is read-only. `default`: read-only
211
+ * unless the start passes `readOnly: false`.
212
+ */
213
+ readonly readOnly?: "always" | "default";
214
+ /**
215
+ * `distinct` (the default): a start needs a request that another admin
216
+ * approved (`support.request`, then `support.approve`), or an `authorize`
217
+ * decision of `{ approvedBy }` naming someone else. `none`: no second admin.
218
+ * Set `blocks.impersonation.options.approval` to the same value, because the
219
+ * SQL store checks it again.
220
+ */
221
+ readonly approval?: "distinct" | "none";
222
+ }
223
+ interface SupportOptions {
224
+ readonly store: SupportSessionStore;
225
+ /**
226
+ * Whether `admin` may view the app as the target. Without it, the
227
+ * authorization hooks' `support.authorize` decides, and without those every
228
+ * start is refused (`SUPPORT_FORBIDDEN`). A throw or rejection counts as a
229
+ * deny. `true` still needs a second admin under `policy.approval:
230
+ * 'distinct'`; `{ approvedBy }` names that admin.
231
+ *
232
+ * `'store'` hands the decision to the store alone: the SQL store checks
233
+ * `is_platform(blocks['impersonation'].permissions.start)` and nothing else,
234
+ * so use it only when that permission is the whole rule.
235
+ */
236
+ readonly authorize?: SupportAuthorize | "store";
237
+ /**
238
+ * The claims the target gets. Defaults to `store.claims` (the SQL store runs
239
+ * your custom access token hook), then `{ role: 'authenticated' }`.
240
+ */
241
+ readonly claims?: (targetUserId: string) => Readonly<Record<string, unknown>> | Promise<Readonly<Record<string, unknown>>>;
242
+ readonly policy?: SupportPolicy;
243
+ readonly cookie?: SupportCookieOptions;
244
+ /**
245
+ * Where a request names its support session, for apps that keep it in a
246
+ * header or their own request store instead of the `bsb-support` cookie.
247
+ * Defaults to reading the cookie.
248
+ */
249
+ readonly sessionId?: (request: Request) => string | undefined;
250
+ }
251
+ interface SupportStartRequest {
252
+ readonly targetUserId: string;
253
+ readonly reason?: string;
254
+ /** Seconds; defaults to `policy.ttl`. */
255
+ readonly ttl?: number;
256
+ /** Honoured only with `policy.readOnly: 'default'`. */
257
+ readonly readOnly?: boolean;
258
+ readonly tenant?: string;
259
+ readonly metadata?: Readonly<Record<string, unknown>>;
260
+ }
261
+ /** Options for `support.expireRoute`. */
262
+ interface SupportExpireRouteOptions {
263
+ /** The bearer token the cron caller sends, such as `process.env.CRON_SECRET`. */
264
+ readonly secret: string | undefined;
265
+ /** Rewrites the Problem Details bodies of the route's errors. */
266
+ readonly problem?: ProblemFormat;
267
+ }
268
+ /** A running support session, as the request that carries its cookie sees it. */
269
+ interface ActiveSupport {
270
+ readonly session: SupportSession;
271
+ /** The admin behind the session, from their own verified token. */
272
+ readonly admin: {
273
+ readonly id: string;
274
+ readonly email?: string;
275
+ };
276
+ /** The target's claims plus `act`, which repositories run with. */
277
+ readonly claims: Readonly<Record<string, unknown>>;
278
+ }
279
+ /** `bsb.support`: start, stop and inspect support sessions. */
280
+ interface SupportApi {
281
+ /**
282
+ * Starts a session for a signed-in admin and returns it with the `Set-Cookie`
283
+ * value that switches the admin's next requests to the target.
284
+ */
285
+ start(admin: AuthState, request: SupportStartRequest): AsyncResult<{
286
+ readonly session: SupportSession;
287
+ readonly cookie: string;
288
+ }>;
289
+ /**
290
+ * Asks for a session that a second admin approves with `approve`; the policy
291
+ * checks of `start` apply. `ttl` is not stored: `start` passes it.
292
+ */
293
+ request(admin: AuthState, request: SupportStartRequest): AsyncResult<SupportRequest>;
294
+ /**
295
+ * Approves a request as `approver`, who is never the admin who asked. With
296
+ * the hooks' `approverOf`, it decides who may approve; otherwise the store
297
+ * does (the SQL store: the provider's `isApprover`, else the start
298
+ * permission).
299
+ */
300
+ approve(approver: AuthState, requestId: string): AsyncResult<SupportRequest>;
301
+ /**
302
+ * Ends the admin's own session and returns the `Set-Cookie` that clears the
303
+ * cookie.
304
+ */
305
+ stop(admin: AuthState, sessionId: string): AsyncResult<{
306
+ readonly ended: boolean;
307
+ readonly cookie: string;
308
+ }>;
309
+ /**
310
+ * Ends a session as `caller`: the SQL store allows the session's admin and
311
+ * staff with the revoke permission.
312
+ */
313
+ revoke(caller: AuthState, sessionId: string): AsyncResult<boolean>;
314
+ /** The running session the request names (`sessionIdOf`) for `auth`, if any. */
315
+ current(request: Request, auth: AuthState): Promise<ActiveSupport | undefined>;
316
+ /**
317
+ * The running session `sessionId` for the admin in `auth`, if any. Use it
318
+ * when the app keeps the session id in its own request context; pass the
319
+ * result to `contextFor(auth, { support })` or `dbFor(auth, context, {
320
+ * support })`.
321
+ */
322
+ resolve(sessionId: string, auth: AuthState): Promise<ActiveSupport | undefined>;
323
+ /** The sessions `caller` may view (the SQL store checks the view permission). */
324
+ list(caller: AuthState, filter?: SupportListFilter): AsyncResult<readonly SupportSession[]>;
325
+ /**
326
+ * Ends every session past its expiry through the store and emits
327
+ * `support.ended` with `endedBy: "expired"` for each; the SQL store runs over
328
+ * `postgres.admin`. Returns the sessions it ended.
329
+ */
330
+ expire(): AsyncResult<readonly SupportSession[]>;
331
+ /**
332
+ * A `GET` or `POST` handler for a cron caller that runs `expire()` and
333
+ * answers `{ expired }`, the number of sessions it ended.
334
+ */
335
+ expireRoute(options: SupportExpireRouteOptions): (request: Request) => Promise<Response>;
336
+ /** The support session id a request names: `options.sessionId`, or the cookie. */
337
+ sessionIdOf(request: Request): string | undefined;
338
+ /** `Set-Cookie` that clears the support cookie. */
339
+ clearCookie(): string;
340
+ }
341
+ /** `ServerOptions.support`, from `supportSessions(options)`. */
342
+ interface SupportSessions {
343
+ readonly options: SupportOptions;
344
+ /**
345
+ * Builds `bsb.support`; `createServer` calls it once, with the definition's
346
+ * `temporal`, which goes on to the store's `withTemporal`, and the server's
347
+ * authorization hooks.
348
+ */
349
+ readonly create: (events: EventHub, claimsSchema: StandardSchemaV1 | undefined, temporal?: typeof Temporal, authorization?: AuthorizationHooks) => SupportApi;
350
+ }
351
+ /**
352
+ * Support sessions for `createServer(betterSupabase, { support })`. Apps that
353
+ * never import it don't bundle the support code.
354
+ */
355
+ declare function supportSessions(options: SupportOptions): SupportSessions;
356
+ //#endregion
357
+ export { SupportSessionStore as C, supportClaims as E, SupportSession as S, sqlSupportStore as T, SupportCallerClaims as _, SupportPolicy as a, SupportRequest as b, supportSessions as c, clearSupportCookie as d, supportCookie as f, SupportApprover as g, SupportApprovalQuery as h, SupportOptions as i, SUPPORT_COOKIE as l, SqlSupportStoreOptions as m, SupportApi as n, SupportSessions as o, supportCookieValue as p, SupportExpireRouteOptions as r, SupportStartRequest as s, ActiveSupport as t, SupportCookieOptions as u, SupportEndedBy as v, SupportStartInput as w, SupportRequestInput as x, SupportListFilter as y };