better-supabase 0.31.0 → 0.33.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 (1703) hide show
  1. package/README.md +11 -10
  2. package/codemods/0.32.json +31 -0
  3. package/dist/access-sql-Dao1C0fz.js +383 -0
  4. package/dist/actor-B5b0i1Fs.js +149 -0
  5. package/dist/actor-DseNR02I.d.ts +104 -0
  6. package/dist/adapter-CWzyKepA.js +2260 -0
  7. package/dist/agents-DXiOPB3V.d.ts +115 -0
  8. package/dist/ai-cache-CLiAXCPH.d.ts +80 -0
  9. package/dist/ai-cache-D9D36eh4.js +86 -0
  10. package/dist/ai-chat-DlcBdOhJ.d.ts +532 -0
  11. package/dist/ai-files-DCMVGSds.js +337 -0
  12. package/dist/ai-message-cnroprVB.js +13 -0
  13. package/dist/ai-schedules-Drx2KRTn.d.ts +164 -0
  14. package/dist/ai-sdk/agents/index.d.ts +8 -12
  15. package/dist/ai-sdk/agents/index.js +10 -12
  16. package/dist/ai-sdk/batches/index.d.ts +12 -7
  17. package/dist/ai-sdk/batches/index.js +16 -9
  18. package/dist/ai-sdk/cache/index.d.ts +2 -4
  19. package/dist/ai-sdk/cache/index.js +3 -4
  20. package/dist/ai-sdk/chat/index.d.ts +77 -2
  21. package/dist/ai-sdk/chat/index.js +179 -28
  22. package/dist/ai-sdk/embeddings/index.d.ts +2 -2
  23. package/dist/ai-sdk/embeddings/index.js +1 -1
  24. package/dist/ai-sdk/files/index.d.ts +3 -5
  25. package/dist/ai-sdk/files/index.js +5 -6
  26. package/dist/ai-sdk/index.d.ts +75 -21
  27. package/dist/ai-sdk/index.js +112 -66
  28. package/dist/ai-sdk/mcp/index.d.ts +28 -13
  29. package/dist/ai-sdk/mcp/index.js +56 -17
  30. package/dist/ai-sdk/memory/index.d.ts +3 -5
  31. package/dist/ai-sdk/memory/index.js +3 -4
  32. package/dist/ai-sdk/react/index.d.ts +2 -2
  33. package/dist/ai-sdk/react/index.js +3 -1
  34. package/dist/ai-sdk/react/server.d.ts +7 -4
  35. package/dist/ai-sdk/react/server.js +10 -3
  36. package/dist/ai-sdk/workflow/index.d.ts +12 -13
  37. package/dist/ai-sdk/workflow/index.js +17 -17
  38. package/dist/ai-sdk/workflow/react/index.d.ts +1 -3
  39. package/dist/ai-sdk/workflow/react/index.js +3 -3
  40. package/dist/ai-sdk/workflow/react/server.d.ts +1 -3
  41. package/dist/ai-sdk/workflow/react/server.js +1 -2
  42. package/dist/anchors-sCLvYj-8.d.ts +36 -0
  43. package/dist/api-keys-DbIbkGxx.d.ts +211 -0
  44. package/dist/api-myq2e9t5.d.ts +482 -0
  45. package/dist/api-wwix_K5c.js +691 -0
  46. package/dist/app-tables-IrglDJCs.d.ts +26 -0
  47. package/dist/approvals-DZoGtNFv.d.ts +127 -0
  48. package/dist/approvals-Da4uAANx.js +166 -0
  49. package/dist/assistant-BEbRPjhn.d.ts +209 -0
  50. package/dist/astro/index.d.ts +7 -10
  51. package/dist/astro/index.js +8 -9
  52. package/dist/attachments-BWtUQgsL.js +375 -0
  53. package/dist/attributes-BZNkR2z2.js +51 -0
  54. package/dist/auth-link-BmJsQG4a.js +117 -0
  55. package/dist/auth-link-DRjtI1Ky.d.ts +102 -0
  56. package/dist/auth-module-CqXdm8qD.js +50 -0
  57. package/dist/auth-reply-BMPJQssh.d.ts +9 -0
  58. package/dist/auth-reply-Cnwn3I_q.js +30 -0
  59. package/dist/auth-wFlGgwTZ.js +19 -0
  60. package/dist/authorization-BlmDNI2b.d.ts +3734 -0
  61. package/dist/authorization-hooks-CxwsRnfV.d.ts +219 -0
  62. package/dist/authorizer-BtIPDO-c.js +194 -0
  63. package/dist/automation-acq3iK9y.js +74 -0
  64. package/dist/automations-BfH8GJqv.js +27 -0
  65. package/dist/automations-Bw5cX7oj.js +29 -0
  66. package/dist/automations-CCc5RUw-.js +31 -0
  67. package/dist/automations-Dou1t3lt.js +313 -0
  68. package/dist/availability-CebEOfMN.d.ts +236 -0
  69. package/dist/base64-CVyKHBBw.js +41 -0
  70. package/dist/batch-limit-DqQ3d6op.js +4 -0
  71. package/dist/before-route-Ra3OhI2x.js +29 -0
  72. package/dist/better-result/index.d.ts +4 -6
  73. package/dist/better-result/index.js +2 -3
  74. package/dist/bind-DP-KLgYI.d.ts +102 -0
  75. package/dist/block-authors-C5z3tGVu.d.ts +10 -0
  76. package/dist/block-authors-DCQ4zl8e.js +13 -0
  77. package/dist/block-env-CJ38ZSTP.d.ts +30 -0
  78. package/dist/block-event-listener-DCi7c89M.js +15 -0
  79. package/dist/block-events-Bp6GPIBN.js +82 -0
  80. package/dist/block-fields-Bjcv6_zc.js +139 -0
  81. package/dist/block-fields-Puv5m5D3.d.ts +56 -0
  82. package/dist/block-helpers-I7UzjNEf.js +435 -0
  83. package/dist/block-helpers-disoUWCp.d.ts +56 -0
  84. package/dist/block-hooks-CadxQ9-_.js +129 -0
  85. package/dist/block-hooks-DrA_d1dJ.d.ts +115 -0
  86. package/dist/block-method-DIbWG4Mj.js +20 -0
  87. package/dist/block-method-QSaPsL2P.d.ts +12 -0
  88. package/dist/block-subjects-Br2MQNFn.d.ts +4 -0
  89. package/dist/block-subjects-cRlVtKDO.js +54 -0
  90. package/dist/block-tables-CQTU71zn.d.ts +34 -0
  91. package/dist/block-tenant-Bun03JuO.js +13 -0
  92. package/dist/block-transport-BEtC_Kis.d.ts +67 -0
  93. package/dist/blocks/access-requests/index.d.ts +9 -15
  94. package/dist/blocks/access-requests/index.js +11 -14
  95. package/dist/blocks/activities/index.d.ts +13 -21
  96. package/dist/blocks/activities/index.js +16 -21
  97. package/dist/blocks/agents/index.d.ts +4 -8
  98. package/dist/blocks/agents/index.js +11 -14
  99. package/dist/blocks/ai-cache/index.d.ts +3 -5
  100. package/dist/blocks/ai-cache/index.js +5 -6
  101. package/dist/blocks/ai-chat/index.d.ts +10 -19
  102. package/dist/blocks/ai-chat/index.js +20 -28
  103. package/dist/blocks/ai-files/index.d.ts +5 -9
  104. package/dist/blocks/ai-files/index.js +5 -6
  105. package/dist/blocks/ai-keys/index.d.ts +4 -10
  106. package/dist/blocks/ai-keys/index.js +14 -18
  107. package/dist/blocks/ai-schedules/index.d.ts +3 -5
  108. package/dist/blocks/ai-schedules/index.js +14 -16
  109. package/dist/blocks/announcements/index.d.ts +12 -20
  110. package/dist/blocks/announcements/index.js +12 -16
  111. package/dist/blocks/api-keys/index.d.ts +4 -116
  112. package/dist/blocks/api-keys/index.js +17 -22
  113. package/dist/blocks/approvals/index.d.ts +4 -8
  114. package/dist/blocks/approvals/index.js +7 -173
  115. package/dist/blocks/assets/index.d.ts +9 -17
  116. package/dist/blocks/assets/index.js +13 -17
  117. package/dist/blocks/assignment/index.d.ts +9 -17
  118. package/dist/blocks/assignment/index.js +10 -14
  119. package/dist/blocks/attachments/index.d.ts +6 -18
  120. package/dist/blocks/attachments/index.js +19 -24
  121. package/dist/blocks/audit/index.d.ts +15 -31
  122. package/dist/blocks/audit/index.js +27 -35
  123. package/dist/blocks/automations/index.d.ts +14 -26
  124. package/dist/blocks/automations/index.js +18 -23
  125. package/dist/blocks/billable-time/index.d.ts +9 -19
  126. package/dist/blocks/billable-time/index.js +15 -20
  127. package/dist/blocks/billing/index.d.ts +12 -22
  128. package/dist/blocks/billing/index.js +19 -24
  129. package/dist/blocks/bookings/index.d.ts +8 -18
  130. package/dist/blocks/bookings/index.js +17 -23
  131. package/dist/blocks/bulk/index.d.ts +6 -12
  132. package/dist/blocks/bulk/index.js +10 -13
  133. package/dist/blocks/calendar/index.d.ts +13 -23
  134. package/dist/blocks/calendar/index.js +35 -32
  135. package/dist/blocks/catalog/index.d.ts +12 -20
  136. package/dist/blocks/catalog/index.js +17 -21
  137. package/dist/blocks/channels/index.d.ts +9 -17
  138. package/dist/blocks/channels/index.js +11 -15
  139. package/dist/blocks/collections/index.d.ts +11 -17
  140. package/dist/blocks/collections/index.js +13 -16
  141. package/dist/blocks/comments/index.d.ts +16 -26
  142. package/dist/blocks/comments/index.js +21 -26
  143. package/dist/blocks/compliance/index.d.ts +9 -17
  144. package/dist/blocks/compliance/index.js +13 -17
  145. package/dist/blocks/connectors/index.d.ts +4 -8
  146. package/dist/blocks/connectors/index.js +13 -16
  147. package/dist/blocks/contacts/index.d.ts +10 -18
  148. package/dist/blocks/contacts/index.js +12 -16
  149. package/dist/blocks/content/index.d.ts +8 -16
  150. package/dist/blocks/content/index.js +13 -17
  151. package/dist/blocks/contracts/index.d.ts +11 -21
  152. package/dist/blocks/contracts/index.js +17 -22
  153. package/dist/blocks/courses/index.d.ts +11 -21
  154. package/dist/blocks/courses/index.js +17 -22
  155. package/dist/blocks/created-by/index.d.ts +3 -7
  156. package/dist/blocks/created-by/index.js +4 -5
  157. package/dist/blocks/custom-fields/index.d.ts +10 -16
  158. package/dist/blocks/custom-fields/index.js +13 -16
  159. package/dist/blocks/data-lifecycle/index.d.ts +10 -26
  160. package/dist/blocks/data-lifecycle/index.js +17 -23
  161. package/dist/blocks/deals/index.d.ts +12 -20
  162. package/dist/blocks/deals/index.js +18 -22
  163. package/dist/blocks/dispatch/index.d.ts +11 -23
  164. package/dist/blocks/dispatch/index.js +19 -24
  165. package/dist/blocks/documents/index.d.ts +4 -8
  166. package/dist/blocks/documents/index.js +9 -12
  167. package/dist/blocks/domains/index.d.ts +8 -14
  168. package/dist/blocks/domains/index.js +12 -15
  169. package/dist/blocks/donations/index.d.ts +13 -23
  170. package/dist/blocks/donations/index.js +21 -26
  171. package/dist/blocks/drive/index.d.ts +116 -20
  172. package/dist/blocks/drive/index.js +138 -26
  173. package/dist/blocks/employees/index.d.ts +13 -23
  174. package/dist/blocks/employees/index.js +18 -23
  175. package/dist/blocks/enrichment/index.d.ts +8 -16
  176. package/dist/blocks/enrichment/index.js +11 -15
  177. package/dist/blocks/enrollments/index.d.ts +9 -17
  178. package/dist/blocks/enrollments/index.js +13 -17
  179. package/dist/blocks/entitlements/index.d.ts +8 -14
  180. package/dist/blocks/entitlements/index.js +8 -32
  181. package/dist/blocks/expenses/index.d.ts +22 -19
  182. package/dist/blocks/expenses/index.js +25 -23
  183. package/dist/blocks/field-history/index.d.ts +6 -10
  184. package/dist/blocks/field-history/index.js +5 -7
  185. package/dist/blocks/flags/index.d.ts +49 -20
  186. package/dist/blocks/flags/index.js +65 -19
  187. package/dist/blocks/forecasts/index.d.ts +10 -16
  188. package/dist/blocks/forecasts/index.js +11 -14
  189. package/dist/blocks/forms/index.d.ts +11 -25
  190. package/dist/blocks/forms/index.js +17 -24
  191. package/dist/blocks/goals/index.d.ts +8 -12
  192. package/dist/blocks/goals/index.js +9 -11
  193. package/dist/blocks/guests/index.d.ts +9 -19
  194. package/dist/blocks/guests/index.js +14 -19
  195. package/dist/blocks/hiring/index.d.ts +10 -18
  196. package/dist/blocks/hiring/index.js +12 -15
  197. package/dist/blocks/identities/index.d.ts +7 -11
  198. package/dist/blocks/identities/index.js +7 -9
  199. package/dist/blocks/imports/index.d.ts +8 -18
  200. package/dist/blocks/imports/index.js +11 -16
  201. package/dist/blocks/inbox/index.d.ts +11 -21
  202. package/dist/blocks/inbox/index.js +26 -23
  203. package/dist/blocks/incidents/index.d.ts +9 -17
  204. package/dist/blocks/incidents/index.js +14 -18
  205. package/dist/blocks/index.d.ts +14 -20
  206. package/dist/blocks/index.js +17 -20
  207. package/dist/blocks/inventory/index.d.ts +11 -17
  208. package/dist/blocks/inventory/index.js +12 -15
  209. package/dist/blocks/invoices/index.d.ts +34 -21
  210. package/dist/blocks/invoices/index.js +31 -18
  211. package/dist/blocks/knowledge/index.d.ts +3 -5
  212. package/dist/blocks/knowledge/index.js +5 -6
  213. package/dist/blocks/lead-scoring/index.d.ts +10 -14
  214. package/dist/blocks/lead-scoring/index.js +11 -13
  215. package/dist/blocks/leases/index.d.ts +11 -21
  216. package/dist/blocks/leases/index.js +20 -25
  217. package/dist/blocks/leave/index.d.ts +50 -17
  218. package/dist/blocks/leave/index.js +35 -14
  219. package/dist/blocks/ledger/index.d.ts +9 -17
  220. package/dist/blocks/ledger/index.js +13 -17
  221. package/dist/blocks/mail-sync/index.d.ts +6 -12
  222. package/dist/blocks/mail-sync/index.js +26 -25
  223. package/dist/blocks/memberships/index.d.ts +5 -9
  224. package/dist/blocks/memberships/index.js +4 -5
  225. package/dist/blocks/memory/index.d.ts +4 -8
  226. package/dist/blocks/memory/index.js +12 -15
  227. package/dist/blocks/messaging/index.d.ts +14 -24
  228. package/dist/blocks/messaging/index.js +19 -24
  229. package/dist/blocks/metrics/index.d.ts +9 -17
  230. package/dist/blocks/metrics/index.js +14 -18
  231. package/dist/blocks/mfa/index.d.ts +5 -9
  232. package/dist/blocks/mfa/index.js +7 -9
  233. package/dist/blocks/moderation/index.d.ts +9 -17
  234. package/dist/blocks/moderation/index.js +13 -17
  235. package/dist/blocks/notifications/index.d.ts +18 -34
  236. package/dist/blocks/notifications/index.js +32 -42
  237. package/dist/blocks/numbering/index.d.ts +6 -12
  238. package/dist/blocks/numbering/index.js +8 -11
  239. package/dist/blocks/oauth-server/index.d.ts +7 -13
  240. package/dist/blocks/oauth-server/index.js +12 -15
  241. package/dist/blocks/onboarding/index.d.ts +7 -13
  242. package/dist/blocks/onboarding/index.js +8 -11
  243. package/dist/blocks/orders/index.d.ts +17 -29
  244. package/dist/blocks/orders/index.js +22 -28
  245. package/dist/blocks/organizations/index.d.ts +11 -21
  246. package/dist/blocks/organizations/index.js +16 -19
  247. package/dist/blocks/outbox/index.d.ts +4 -6
  248. package/dist/blocks/outbox/index.js +11 -13
  249. package/dist/blocks/passes/index.d.ts +12 -22
  250. package/dist/blocks/passes/index.js +20 -25
  251. package/dist/blocks/permissions/index.d.ts +50 -15
  252. package/dist/blocks/permissions/index.js +99 -19
  253. package/dist/blocks/pipelines/index.d.ts +12 -18
  254. package/dist/blocks/pipelines/index.js +12 -15
  255. package/dist/blocks/posts/index.d.ts +10 -18
  256. package/dist/blocks/posts/index.js +15 -19
  257. package/dist/blocks/profiles/index.d.ts +8 -12
  258. package/dist/blocks/profiles/index.js +9 -11
  259. package/dist/blocks/promotions/index.d.ts +11 -17
  260. package/dist/blocks/promotions/index.js +13 -16
  261. package/dist/blocks/push/index.d.ts +12 -18
  262. package/dist/blocks/push/index.js +13 -16
  263. package/dist/blocks/queue/index.d.ts +187 -39
  264. package/dist/blocks/queue/index.js +226 -60
  265. package/dist/blocks/quotes/index.d.ts +13 -21
  266. package/dist/blocks/quotes/index.js +14 -17
  267. package/dist/blocks/rank/index.d.ts +7 -13
  268. package/dist/blocks/rank/index.js +8 -10
  269. package/dist/blocks/reactions/index.d.ts +11 -19
  270. package/dist/blocks/reactions/index.js +13 -17
  271. package/dist/blocks/relations/index.d.ts +11 -21
  272. package/dist/blocks/relations/index.js +18 -23
  273. package/dist/blocks/reminders/index.d.ts +12 -22
  274. package/dist/blocks/reminders/index.js +21 -25
  275. package/dist/blocks/reviews/index.d.ts +9 -15
  276. package/dist/blocks/reviews/index.js +11 -14
  277. package/dist/blocks/saved-views/index.d.ts +11 -21
  278. package/dist/blocks/saved-views/index.js +16 -21
  279. package/dist/blocks/scores/index.d.ts +6 -12
  280. package/dist/blocks/scores/index.js +10 -13
  281. package/dist/blocks/search/index.d.ts +9 -19
  282. package/dist/blocks/search/index.js +15 -19
  283. package/dist/blocks/security-events/index.d.ts +10 -24
  284. package/dist/blocks/security-events/index.js +17 -23
  285. package/dist/blocks/segments/index.d.ts +10 -18
  286. package/dist/blocks/segments/index.js +11 -15
  287. package/dist/blocks/sequences/index.d.ts +9 -17
  288. package/dist/blocks/sequences/index.js +15 -19
  289. package/dist/blocks/service-accounts/index.d.ts +9 -15
  290. package/dist/blocks/service-accounts/index.js +11 -14
  291. package/dist/blocks/sessions/index.d.ts +4 -8
  292. package/dist/blocks/sessions/index.js +9 -11
  293. package/dist/blocks/settings/index.d.ts +8 -16
  294. package/dist/blocks/settings/index.js +14 -18
  295. package/dist/blocks/share-links/index.d.ts +9 -17
  296. package/dist/blocks/share-links/index.js +16 -20
  297. package/dist/blocks/shipments/index.d.ts +14 -24
  298. package/dist/blocks/shipments/index.js +25 -31
  299. package/dist/blocks/signatures/index.d.ts +10 -16
  300. package/dist/blocks/signatures/index.js +10 -13
  301. package/dist/blocks/signing-keys/index.d.ts +5 -9
  302. package/dist/blocks/signing-keys/index.js +8 -10
  303. package/dist/blocks/sla/index.d.ts +11 -19
  304. package/dist/blocks/sla/index.js +17 -21
  305. package/dist/blocks/sso/index.d.ts +7 -19
  306. package/dist/blocks/sso/index.js +14 -21
  307. package/dist/blocks/state-machine/index.d.ts +7 -13
  308. package/dist/blocks/state-machine/index.js +9 -12
  309. package/dist/blocks/subjects/index.d.ts +7 -11
  310. package/dist/blocks/subjects/index.js +12 -14
  311. package/dist/blocks/tags/index.d.ts +11 -21
  312. package/dist/blocks/tags/index.js +20 -25
  313. package/dist/blocks/tasks/index.d.ts +13 -27
  314. package/dist/blocks/tasks/index.js +22 -29
  315. package/dist/blocks/teams/index.d.ts +8 -14
  316. package/dist/blocks/teams/index.js +10 -13
  317. package/dist/blocks/templates/index.d.ts +12 -22
  318. package/dist/blocks/templates/index.js +16 -21
  319. package/dist/blocks/time-tracking/index.d.ts +31 -25
  320. package/dist/blocks/time-tracking/index.js +29 -29
  321. package/dist/blocks/timeline/index.d.ts +10 -14
  322. package/dist/blocks/timeline/index.js +11 -13
  323. package/dist/blocks/trash/index.d.ts +10 -18
  324. package/dist/blocks/trash/index.js +11 -14
  325. package/dist/blocks/undo/index.d.ts +4 -8
  326. package/dist/blocks/undo/index.js +6 -8
  327. package/dist/blocks/updated-at/index.d.ts +3 -7
  328. package/dist/blocks/updated-at/index.js +4 -5
  329. package/dist/blocks/usage/index.d.ts +6 -10
  330. package/dist/blocks/usage/index.js +10 -13
  331. package/dist/blocks/vercel-marketplace/index.d.ts +9 -17
  332. package/dist/blocks/vercel-marketplace/index.js +17 -21
  333. package/dist/blocks/versions/index.d.ts +10 -20
  334. package/dist/blocks/versions/index.js +17 -22
  335. package/dist/blocks/waitlist/index.d.ts +10 -16
  336. package/dist/blocks/waitlist/index.js +11 -14
  337. package/dist/blocks/webhooks/index.d.ts +16 -34
  338. package/dist/blocks/webhooks/index.js +33 -44
  339. package/dist/blocks/workflow-editor/index.d.ts +13 -21
  340. package/dist/blocks/workflow-editor/index.js +22 -27
  341. package/dist/blocks/workflows/index.d.ts +8 -14
  342. package/dist/blocks/workflows/index.js +14 -18
  343. package/dist/bookings-Br0VXzaf.d.ts +285 -0
  344. package/dist/bucket-DvG66r5G.d.ts +693 -0
  345. package/dist/build-Ckxct2EX.js +2065 -0
  346. package/dist/build-D1-V9dd8.js +732 -0
  347. package/dist/carrier-D2b_028L.d.ts +165 -0
  348. package/dist/casing-DQzG9ANZ.js +15 -0
  349. package/dist/channel-B_kufDZy.d.ts +101 -0
  350. package/dist/channels-BxeTTtCY.js +113 -0
  351. package/dist/chat-sdk/index.d.ts +174 -41
  352. package/dist/chat-sdk/index.js +425 -83
  353. package/dist/claim-names-BKig1LOk.js +24 -0
  354. package/dist/claims/index.d.ts +8 -0
  355. package/dist/claims/index.js +8 -0
  356. package/dist/claims-CqTr_N1n.js +98 -0
  357. package/dist/claims-DouHL7ZL.js +62 -0
  358. package/dist/cli/_format-Ba0DoWjl.js +99 -0
  359. package/dist/cli/add-BDLLVLI8.js +99 -0
  360. package/dist/cli/add-BaOCKKt6.js +1 -0
  361. package/dist/cli/add-D2pKTbPw.js +1222 -0
  362. package/dist/cli/agent-59XWXsRi.js +184 -0
  363. package/dist/cli/app-table-files-CimWi_eh.js +343 -0
  364. package/dist/cli/arazzo-1.0-D3OaSeZw.js +531 -0
  365. package/dist/cli/arazzo-1.1-DaT2KAkP.js +704 -0
  366. package/dist/cli/args-_ZVgRBkx.js +26 -0
  367. package/dist/cli/asyncapi-3.0.0-Ca-UwtUW.js +5592 -0
  368. package/dist/cli/asyncapi-3.1.0-DUxf5zNu.js +5832 -0
  369. package/dist/cli/authorization-DJkkOjjG.js +230 -0
  370. package/dist/cli/backfill-B1xAsdL4.js +292 -0
  371. package/dist/cli/bin.js +5 -5
  372. package/dist/cli/blocks-DtZtn-R4.js +1 -0
  373. package/dist/cli/blocks-rBeis04I.js +155 -0
  374. package/dist/cli/cache-CvBRwv02.js +643 -0
  375. package/dist/cli/codemod-DYbVbJ-e.js +2884 -0
  376. package/dist/cli/codemod-block-renames-Dt3X1Wvg.js +238 -0
  377. package/dist/cli/command-BpZ4AuhR.js +1021 -0
  378. package/dist/cli/compare-yl4sSwVn.js +8 -0
  379. package/dist/cli/completion-B08Q0xB3.js +29 -0
  380. package/dist/cli/completion-CwL7e93t.js +210 -0
  381. package/dist/cli/completion-DHTT6rjI.js +1 -0
  382. package/dist/cli/config-CrwCec-B.js +1 -0
  383. package/dist/cli/config-D-Upz3jV.js +46 -0
  384. package/dist/cli/config-DrrkMihk.js +2030 -0
  385. package/dist/cli/config-edit-C6sQ1MqT.js +619 -0
  386. package/dist/cli/config-group-D4JWh4kG.js +388 -0
  387. package/dist/cli/content-mapper-DrhtDsAm.js +181 -0
  388. package/dist/cli/db-B8zfxjl2.js +77 -0
  389. package/dist/cli/db-Diy1OebO.js +246 -0
  390. package/dist/cli/detect-BcUDaO8I.js +83 -0
  391. package/dist/cli/dist-CYnD1kyT.js +128 -0
  392. package/dist/cli/dist-MKwjiW2w.js +1114 -0
  393. package/dist/cli/doctor-Dn4TzGmw.js +4687 -0
  394. package/dist/cli/env-BAJn6wCA.js +142 -0
  395. package/dist/cli/env-BCuUsWOh.js +1109 -0
  396. package/dist/cli/env-D70ihdbB.js +1 -0
  397. package/dist/cli/env-UN6PJFX6.js +1 -0
  398. package/dist/cli/errors-DcJ_PayO.js +97 -0
  399. package/dist/cli/exec-CXBufciC.js +461 -0
  400. package/dist/cli/fastest-levenshtein-B_QF6At5.js +119 -0
  401. package/dist/cli/files-DQayErI8.js +999 -0
  402. package/dist/cli/fresh-import-CdO2oQaQ.js +39 -0
  403. package/dist/cli/gen-BbeS0KgF.js +390 -0
  404. package/dist/cli/guards-DxwRG0Uv.js +7 -0
  405. package/dist/cli/in-stack-diff-huI7fGMX.js +185 -0
  406. package/dist/cli/index.d.ts +1 -53
  407. package/dist/cli/index.js +10 -11
  408. package/dist/cli/init-C30xdMSs.js +556 -0
  409. package/dist/cli/io-CQzy8PEZ.js +36 -0
  410. package/dist/cli/json5-DhsZB2va.js +784 -0
  411. package/dist/cli/jsonc-DU9Clnrz.js +1 -0
  412. package/dist/cli/jsonc-u_UiXFxs.js +43 -0
  413. package/dist/cli/keys-CxajkV_7.js +105 -0
  414. package/dist/cli/legacy-prefix-D8Jfku6I.js +153 -0
  415. package/dist/cli/live-Ctc8Qh9Y.js +339 -0
  416. package/dist/cli/mcp-5J0kUOtD.js +240 -0
  417. package/dist/cli/metadata-DxhUNctA.js +149 -0
  418. package/dist/cli/migrate-ockrh3UX.js +45 -0
  419. package/dist/cli/migration-safety-CLrqC0D-.js +925 -0
  420. package/dist/cli/migrations-CZTg2UJM.js +116 -0
  421. package/dist/cli/module-migration-BptQzmj2.js +118 -0
  422. package/dist/cli/moved-BAFPdJz_.js +253 -0
  423. package/dist/cli/ohash-imLR_J5Y.js +276 -0
  424. package/dist/cli/openapi-3.0-BJiTNq_x.js +927 -0
  425. package/dist/cli/openapi-3.1-BcWCoii2.js +869 -0
  426. package/dist/cli/openapi-3.2-MXPkeoTk.js +1030 -0
  427. package/dist/cli/orphans-CPcR85QN.js +27 -0
  428. package/dist/cli/parse-BueItuNJ.js +181 -0
  429. package/dist/cli/powersync-CmsXOuui.js +1 -0
  430. package/dist/cli/powersync-DIvsipKr.js +375 -0
  431. package/dist/cli/preset-BQnjDCSR.js +100 -0
  432. package/dist/cli/print-DdHt8xCc.js +66 -0
  433. package/dist/cli/prompts-D9b6uf21.js +1133 -0
  434. package/dist/cli/providers-k-1cEna6.js +99 -0
  435. package/dist/cli/prune-workflows-Ddv-GfkO.js +153 -0
  436. package/dist/cli/redact--zOGdWzo.js +37 -0
  437. package/dist/cli/remove-DEEQDoc7.js +237 -0
  438. package/dist/cli/render-SjSVz8yK.js +2216 -0
  439. package/dist/cli/rolldown-runtime-DegdyBIC.js +25 -0
  440. package/dist/cli/run-DdhIK7-K.js +1451 -0
  441. package/dist/cli/run-Ixt9mEb6.js +703 -0
  442. package/dist/cli/run-dY9uOC3W.js +62 -0
  443. package/dist/cli/seed-BpaqqyO8.js +187 -0
  444. package/dist/cli/seed-ByLneY1H.js +1 -0
  445. package/dist/cli/shared-p6sxli_5.js +150 -0
  446. package/dist/cli/shell-C1U618XA.js +9 -0
  447. package/dist/cli/skills-jZThjL3B.js +120 -0
  448. package/dist/cli/snapshot-Dd_8B9g-.js +728 -0
  449. package/dist/cli/source-BYvVe_Es.js +317 -0
  450. package/dist/cli/source-args-Bz5QQne2.js +58 -0
  451. package/dist/cli/spec-BxQgllJY.js +7449 -0
  452. package/dist/cli/spec-liRzcZTa.js +1 -0
  453. package/dist/cli/sql-layout-DHwiUOaD.js +260 -0
  454. package/dist/cli/stack-147NqctC.js +134 -0
  455. package/dist/cli/stack-env-BQhbUFa7.js +92 -0
  456. package/dist/cli/stack-status-Mxgqb3I4.js +45 -0
  457. package/dist/cli/stacks-C5YL6Un9.js +230 -0
  458. package/dist/cli/style-B5-nByxb.js +34 -0
  459. package/dist/cli/supabase-toml-B6-eEV5p.js +1155 -0
  460. package/dist/cli/sync-CreQWj53.js +318 -0
  461. package/dist/cli/table-D9FbJS8h.js +88 -0
  462. package/dist/cli/toml-VX0BsvYq.js +422 -0
  463. package/dist/cli/topics-Cdg0V7Tt.js +29 -0
  464. package/dist/cli/trace-D3TNqWBg.js +6 -0
  465. package/dist/cli/upgrade-3NQOUO1_.js +270 -0
  466. package/dist/cli/upgrade-U7IKj45h.js +40 -0
  467. package/dist/cli/validate-C_WTnX1U.js +7426 -0
  468. package/dist/cli/version-mBwP-aMG.js +3 -0
  469. package/dist/cli/yaml-JsusTbcC.js +2250 -0
  470. package/dist/client/index.d.ts +7 -7
  471. package/dist/client/index.js +9 -12
  472. package/dist/client/native/index.d.ts +7 -23
  473. package/dist/client/native/index.js +15 -22
  474. package/dist/client-Bky2z09B.js +290 -0
  475. package/dist/clone-H_gCsL29.js +32 -0
  476. package/dist/cloud-event-CLvsaPqH.js +62 -0
  477. package/dist/cloud-event-DXWmXrus.d.ts +62 -0
  478. package/dist/codecs-B1VO2BGL.d.ts +220 -0
  479. package/dist/codecs-B9v5Y5HH.js +357 -0
  480. package/dist/commerce/index.d.ts +5 -13
  481. package/dist/commerce/index.js +13 -16
  482. package/dist/compiler-qlXlokKn.d.ts +12 -0
  483. package/dist/compose-BRBlPSEY.js +52 -0
  484. package/dist/composite-CIxjVcL1.d.ts +79 -0
  485. package/dist/composite-D2JnIiHt.js +125 -0
  486. package/dist/config/index.d.ts +6 -6
  487. package/dist/config/index.js +7 -7
  488. package/dist/config-Bu6pwqcO.js +1102 -0
  489. package/dist/config-MDRA2sre.js +1672 -0
  490. package/dist/connectors-Cf2LeAuZ.d.ts +145 -0
  491. package/dist/context-D7jICqdN.d.ts +4279 -0
  492. package/dist/context-DSevnLrT.js +40 -0
  493. package/dist/contract/index.d.ts +16 -0
  494. package/dist/contract/index.js +0 -0
  495. package/dist/controller-BJmh7gFm.js +78 -0
  496. package/dist/controller-DxtxeYdf.d.ts +50 -0
  497. package/dist/controller-y1kSMuCU.js +72 -0
  498. package/dist/conversion-Bj9j3KnG.js +76 -0
  499. package/dist/conversion-C9rndpEI.d.ts +84 -0
  500. package/dist/cookie-DDkqvqe4.d.ts +3 -0
  501. package/dist/cookie-DJI6xXJ9.js +4 -0
  502. package/dist/cors-9SDsndtb.d.ts +13 -0
  503. package/dist/cors-DrDFLMNn.js +23 -0
  504. package/dist/create/index.d.ts +4 -28
  505. package/dist/create/index.js +9 -15
  506. package/dist/create/lite/index.d.ts +5 -25
  507. package/dist/create/lite/index.js +14 -24
  508. package/dist/create/oauth/index.d.ts +1 -1
  509. package/dist/create/oauth/index.js +1 -2
  510. package/dist/create/supabase/index.d.ts +2 -4
  511. package/dist/create/supabase/index.js +3 -6
  512. package/dist/create-blocks-D7q1boXV.js +367 -0
  513. package/dist/credentials/index.d.ts +6 -10
  514. package/dist/credentials/index.js +11 -12
  515. package/dist/cron-BD8VrQQl.js +147 -0
  516. package/dist/cron-route-DSITg1yC.js +23 -0
  517. package/dist/csv-Bwn9insJ.js +88 -0
  518. package/dist/csv-Dd1iKsk-.d.ts +26 -0
  519. package/dist/data-engine-BbqQwso_.js +174 -0
  520. package/dist/data-engine-CMENsp3d.d.ts +269 -0
  521. package/dist/data-hooks-BToeAcQ_.js +277 -0
  522. package/dist/db-exception-Dv18UZ-I.js +30 -0
  523. package/dist/deal-forecast-CN_BEy9s.d.ts +21 -0
  524. package/dist/deal-forecast-DsVFoMkJ.js +38 -0
  525. package/dist/define-B6D55cO0.js +2073 -0
  526. package/dist/define-ITQA71fw.d.ts +1242 -0
  527. package/dist/define-block-22Jv4U_-.js +63 -0
  528. package/dist/define-block-COmMkx2x.d.ts +1669 -0
  529. package/dist/delegation-C2rLpkHO.js +147 -0
  530. package/dist/delivery-CWcbh87x.d.ts +69 -0
  531. package/dist/delivery-SmPHu2_H.js +28 -0
  532. package/dist/delivery-events-0mAEuscm.js +52 -0
  533. package/dist/documents-DeZw83ue.d.ts +150 -0
  534. package/dist/edge/index.d.ts +20 -26
  535. package/dist/edge/index.js +20 -24
  536. package/dist/elysia/index.d.ts +2 -6
  537. package/dist/elysia/index.js +4 -6
  538. package/dist/email-BRm6wMWQ.d.ts +40 -0
  539. package/dist/embeddings--v4BJdUL.js +127 -0
  540. package/dist/embeddings-rVR2AKVz.d.ts +76 -0
  541. package/dist/ended-NC_ZesY4.d.ts +22 -0
  542. package/dist/entitlements-Dydkg-TV.js +47 -0
  543. package/dist/entitlements-sLoj3M6Y.js +44 -0
  544. package/dist/entitlements-w04ivvAy.d.ts +70 -0
  545. package/dist/entity-naming-BES3pkQI.js +130 -0
  546. package/dist/entity-schema-DEIz0I8i.js +38 -0
  547. package/dist/env/index.d.ts +1 -1
  548. package/dist/env/index.js +1 -2
  549. package/dist/envelope-CapD-JtH.js +90 -0
  550. package/dist/errors-B7tCfCvX.js +327 -0
  551. package/dist/errors-BdjHv5SV.js +43 -0
  552. package/dist/errors-D3-4c-XF.js +102 -0
  553. package/dist/escape-like-CK6L7gkj.d.ts +26 -0
  554. package/dist/escape-like-gxNXs145.js +6 -0
  555. package/dist/eve/index.d.ts +247 -16
  556. package/dist/eve/index.js +334 -26
  557. package/dist/eve-DIKjuPp5.d.ts +213 -0
  558. package/dist/event-calendar-DUtFyRrv.d.ts +63 -0
  559. package/dist/event-map-DxfsFgQT.js +18 -0
  560. package/dist/events/index.d.ts +3 -3
  561. package/dist/events/index.js +7 -8
  562. package/dist/events-BRKIxVQD.js +25 -0
  563. package/dist/events-DVt3Z9hw.d.ts +850 -0
  564. package/dist/events-Da482tiF.js +81 -0
  565. package/dist/executor-BDMqPbVU.js +482 -0
  566. package/dist/executor-C0_TT717.js +840 -0
  567. package/dist/executor-CFmee_nV.d.ts +35 -0
  568. package/dist/executor-CHnoKOxk.d.ts +168 -0
  569. package/dist/executor-Dc4Pl44u.js +207 -0
  570. package/dist/executor-DqNRrFxx.d.ts +99 -0
  571. package/dist/expo/index.d.ts +5 -9
  572. package/dist/expo/index.js +10 -12
  573. package/dist/extension-DQ9-oOVC.js +58 -0
  574. package/dist/extension-WdHd5uqI.js +102 -0
  575. package/dist/extension-Z8Pe7fXA.js +120 -0
  576. package/dist/extension-rdpYvpyN.js +52 -0
  577. package/dist/extension-shared-DJb_PfD4.js +59 -0
  578. package/dist/extra-Dz9n5y1s.js +9 -0
  579. package/dist/field-errors-DKCaSlZw.d.ts +208 -0
  580. package/dist/field-formats-Cap-V7UP.js +101 -0
  581. package/dist/field-formats-DVukMbRa.d.ts +36 -0
  582. package/dist/fields-BBcdKD-S.js +107 -0
  583. package/dist/fields-CAVk9dxX.d.ts +76 -0
  584. package/dist/filter-evaluate-Bz3Fzhz2.d.ts +35 -0
  585. package/dist/filter-evaluate-D_LLfdtE.js +216 -0
  586. package/dist/filter-query-DV-x8fio.d.ts +131 -0
  587. package/dist/filter-query-Ds7Z6lgZ.js +565 -0
  588. package/dist/flags-0EXDD3Iz.js +361 -0
  589. package/dist/flags-6emyAXly.d.ts +315 -0
  590. package/dist/flags-sdk/index.d.ts +217 -28
  591. package/dist/flags-sdk/index.js +255 -35
  592. package/dist/form-definition-8cCCt5zj.js +362 -0
  593. package/dist/form-definition-BN8shngm.d.ts +117 -0
  594. package/dist/format-BT0Z3V54.d.ts +77 -0
  595. package/dist/framework-BFlaPuvv.d.ts +46 -0
  596. package/dist/framework-ChzJYkJW.js +58 -0
  597. package/dist/function-contract-Bf6llTkE.js +7 -0
  598. package/dist/function-contract-DgDBYbXu.d.ts +25 -0
  599. package/dist/gateway-DaekJ_Me.d.ts +120 -0
  600. package/dist/gateway-options-DQGQzdkD.js +26 -0
  601. package/dist/gateway-options-Mut8jih_.d.ts +27 -0
  602. package/dist/guards-CsRa6v57.js +11 -0
  603. package/dist/guest-actions-CEwttioE.js +8 -0
  604. package/dist/guest-actions-DfHHp98H.d.ts +3 -0
  605. package/dist/h3/index.d.ts +2 -6
  606. package/dist/h3/index.js +4 -6
  607. package/dist/h3/v1/index.d.ts +3 -5
  608. package/dist/h3/v1/index.js +4 -5
  609. package/dist/history-6KiVNWdH.js +269 -0
  610. package/dist/hmac-DNcfpmI9.js +22 -0
  611. package/dist/hono/index.d.ts +18 -22
  612. package/dist/hono/index.js +16 -17
  613. package/dist/http-BDC1IvBX.js +27 -0
  614. package/dist/http-BRUI3qim.js +140 -0
  615. package/dist/http-D4lH1xqY.js +39 -0
  616. package/dist/image-url-bsGeybeg.js +83 -0
  617. package/dist/impersonation-BOCJcsmS.d.ts +26 -0
  618. package/dist/impersonation-D-quM36V.js +61 -0
  619. package/dist/inbox-DavCzW7b.d.ts +326 -0
  620. package/dist/index-8w4OB5En.d.ts +102 -0
  621. package/dist/index-BIAtapnD.d.ts +570 -0
  622. package/dist/index-BWR29Vvw.d.ts +76 -0
  623. package/dist/index-BZCmy767.d.ts +234 -0
  624. package/dist/index-BdC2IqkU.d.ts +152 -0
  625. package/dist/index-BgkHbf9C.d.ts +637 -0
  626. package/dist/index-BvcMQYL-.d.ts +326 -0
  627. package/dist/index-CbUXFzQV.d.ts +107 -0
  628. package/dist/index-CiE37wKX.d.ts +289 -0
  629. package/dist/index-D18su_r5.d.ts +402 -0
  630. package/dist/index-DU0UwWvL.d.ts +667 -0
  631. package/dist/index-Dj4VKpYZ.d.ts +49 -0
  632. package/dist/index-Dvpu22CJ.d.ts +291 -0
  633. package/dist/index-IKfbX_39.d.ts +23 -0
  634. package/dist/index-M1izbwbN.d.ts +145 -0
  635. package/dist/index.d.ts +13 -41
  636. package/dist/index.js +29 -34
  637. package/dist/instance-property-BlH7QSDl.js +6 -0
  638. package/dist/instances-D31jrmKh.js +16636 -0
  639. package/dist/invalidate-DAB9CaPm.d.ts +19 -0
  640. package/dist/iso4217-oKsif_hW.js +175 -0
  641. package/dist/json-O5vFw243.js +21 -0
  642. package/dist/json-schema-D9eVL_xi.js +884 -0
  643. package/dist/jwks-cache-IZaiICAV.js +48 -0
  644. package/dist/jws-B8p0ppgh.js +204 -0
  645. package/dist/jws-CxgTsbgG.d.ts +64 -0
  646. package/dist/kit-9pZP5iLU.js +163 -0
  647. package/dist/kit-OgFOW9rX.d.ts +92 -0
  648. package/dist/knowledge-BBC2sfAY.d.ts +215 -0
  649. package/dist/knowledge-DdZzUTQ-.js +299 -0
  650. package/dist/lint/index.d.ts +1 -5
  651. package/dist/lint/index.js +8 -10
  652. package/dist/list/index.d.ts +3 -3
  653. package/dist/list/index.js +3 -3
  654. package/dist/list-query-C7V8kUaD.d.ts +220 -0
  655. package/dist/list-query-D-tgs1eY.js +558 -0
  656. package/dist/live-BVi3q4bX.js +277 -0
  657. package/dist/logger-0LfhvwE4.d.ts +16 -0
  658. package/dist/logger-BkF8ukXV.js +20 -0
  659. package/dist/lookup-upE-e1zw.js +17 -0
  660. package/dist/management-DtX4ic1F.d.ts +55 -0
  661. package/dist/mapper/bin.js +13 -17
  662. package/dist/mcp/index.d.ts +4 -299
  663. package/dist/mcp/index.js +71 -42
  664. package/dist/mcp/sdk/index.d.ts +7 -11
  665. package/dist/mcp/sdk/index.js +12 -14
  666. package/dist/message-Cc4bkdNw.d.ts +97 -0
  667. package/dist/messages-CRk1g6oe.js +512 -0
  668. package/dist/messaging-D5z2TR37.d.ts +295 -0
  669. package/dist/methods-BjfDv4Gy.js +9 -0
  670. package/dist/metric-definition-2KQYeUZ1.d.ts +67 -0
  671. package/dist/metric-definition-D4H6IQT7.js +116 -0
  672. package/dist/mfa-CM5r904M.d.ts +34 -0
  673. package/dist/model-Lxa_mOzB.d.ts +338 -0
  674. package/dist/model-messages-BcrkjsPE.js +205 -0
  675. package/dist/model-messages-CGSUU450.d.ts +32 -0
  676. package/dist/money-BgpAd7d3.d.ts +89 -0
  677. package/dist/money-DH--bbYr.js +196 -0
  678. package/dist/money-codec-SKPm8FPw.js +40 -0
  679. package/dist/my-work-kinds-DNPq3ccL.js +10 -0
  680. package/dist/nestjs/index.d.ts +3 -5
  681. package/dist/nestjs/index.js +5 -6
  682. package/dist/next/client/index.d.ts +1 -5
  683. package/dist/next/client/index.js +2 -4
  684. package/dist/next/image/index.d.ts +1 -3
  685. package/dist/next/image/index.js +2 -3
  686. package/dist/next/index.d.ts +98 -106
  687. package/dist/next/index.js +88 -87
  688. package/dist/node/index.d.ts +3 -3
  689. package/dist/node/index.js +6 -7
  690. package/dist/node-headers-C3FExlg9.js +54 -0
  691. package/dist/node-headers-TnS4T7V_.d.ts +25 -0
  692. package/dist/nuxt/index.d.ts +0 -2
  693. package/dist/nuxt/index.js +1 -2
  694. package/dist/operations-BNFbWv1t.js +28 -0
  695. package/dist/operations-CsCwruKT.d.ts +4 -0
  696. package/dist/optional-peer-5SOYr3lL.js +31 -0
  697. package/dist/options--rohtkkC.js +4 -0
  698. package/dist/options-1iHDmlZ5.js +8 -0
  699. package/dist/options-2QJXZPPS.js +4 -0
  700. package/dist/options-B-JqrC61.d.ts +8 -0
  701. package/dist/options-B3xH2JvJ.js +8 -0
  702. package/dist/options-B4sTqDrt.js +4 -0
  703. package/dist/options-B56njigZ.js +19 -0
  704. package/dist/options-B5A3UmKY.d.ts +17 -0
  705. package/dist/options-B6m9gYRH.d.ts +11 -0
  706. package/dist/options-B7Pl708M.js +8 -0
  707. package/dist/options-B7YrdiUc.js +11 -0
  708. package/dist/options-B8c2_hIB.js +9 -0
  709. package/dist/options-B9w_Y08G.d.ts +6 -0
  710. package/dist/options-BDF60ouf.js +4 -0
  711. package/dist/options-BDMPjyrI.js +4 -0
  712. package/dist/options-BHdHuY5r.js +14 -0
  713. package/dist/options-BLMeCbtT.js +31 -0
  714. package/dist/options-BLQePOPy.d.ts +8 -0
  715. package/dist/options-BLn1PFyu.js +4 -0
  716. package/dist/options-BMO-FnOT.js +7 -0
  717. package/dist/options-BNRvoEkj.js +4 -0
  718. package/dist/options-BPQOiVx2.js +7 -0
  719. package/dist/options-BSTJmfX4.js +10 -0
  720. package/dist/options-BTRH26MJ.js +9 -0
  721. package/dist/options-BTaQszYn.js +9 -0
  722. package/dist/options-BYo7hMHK.js +10 -0
  723. package/dist/options-B_bxCZYM.js +7 -0
  724. package/dist/options-BaBaVWS-.js +10 -0
  725. package/dist/options-BamaRO-q.d.ts +12 -0
  726. package/dist/options-BcBdiPSZ.js +7 -0
  727. package/dist/options-BfY4pyQE.js +23 -0
  728. package/dist/options-BgCS5ODi.js +9 -0
  729. package/dist/options-Bi96Lzuf.js +9 -0
  730. package/dist/options-BjEsSoFp.js +17 -0
  731. package/dist/options-Bkx8vwip.js +4 -0
  732. package/dist/options-BmFSI07A.js +4 -0
  733. package/dist/options-BmwDdKwE.js +7 -0
  734. package/dist/options-Bn3NjXfn.js +7 -0
  735. package/dist/options-BqK4xV67.js +13 -0
  736. package/dist/options-Bs2dC-at.js +11 -0
  737. package/dist/options-BvttpM1M.js +4 -0
  738. package/dist/options-Bwrwb8do.d.ts +10 -0
  739. package/dist/options-BxdqA2Ex.js +19 -0
  740. package/dist/options-BzxR82Tu.js +9 -0
  741. package/dist/options-C-NFS6e3.js +13 -0
  742. package/dist/options-C13-dVMH.js +7 -0
  743. package/dist/options-C1RIyAe1.js +7 -0
  744. package/dist/options-C1kZ3qLd.js +8 -0
  745. package/dist/options-C2RjdunU.js +27 -0
  746. package/dist/options-C4kpi6HE.js +8 -0
  747. package/dist/options-C5MfwOAO.js +8 -0
  748. package/dist/options-C5fKQ3EJ.d.ts +10 -0
  749. package/dist/options-CJR59q8s.js +17 -0
  750. package/dist/options-CJVYQue3.d.ts +10 -0
  751. package/dist/options-CLy7CcMn.js +8 -0
  752. package/dist/options-COfEYic3.js +8 -0
  753. package/dist/options-CRwTY_q2.d.ts +58 -0
  754. package/dist/options-CcW7h8mv.js +9 -0
  755. package/dist/options-Ceu2j1vv.js +7 -0
  756. package/dist/options-CgBKgmI8.js +7 -0
  757. package/dist/options-CgMiQGOF.js +9 -0
  758. package/dist/options-CptvcSmF.js +11 -0
  759. package/dist/options-CsLUAt04.js +8 -0
  760. package/dist/options-CtyjhSGk.js +15 -0
  761. package/dist/options-CuPWezcV.js +7 -0
  762. package/dist/options-CyDOOWlk.js +7 -0
  763. package/dist/options-CyYZvdSy.js +10 -0
  764. package/dist/options-CzIPn0fF.js +4 -0
  765. package/dist/options-CzWjw2HY.js +10 -0
  766. package/dist/options-CztbWdz9.js +4 -0
  767. package/dist/options-D4LuPM8a.js +4 -0
  768. package/dist/options-D4dxMGHF.js +7 -0
  769. package/dist/options-D5a9CHgP.js +7 -0
  770. package/dist/options-D6tpMRvp.d.ts +13 -0
  771. package/dist/options-D848Os4l.js +10 -0
  772. package/dist/options-DCZPW5gR.d.ts +15 -0
  773. package/dist/options-DFSHZFLN.js +4 -0
  774. package/dist/options-DFemc2im.js +9 -0
  775. package/dist/options-DFgHHwzD.js +12 -0
  776. package/dist/options-DNZ9r_Vo.d.ts +8 -0
  777. package/dist/options-DP7NwQPZ.js +4 -0
  778. package/dist/options-DPQaafyc.js +7 -0
  779. package/dist/options-DQkhhBLy.js +4 -0
  780. package/dist/options-DTTz33na.js +9 -0
  781. package/dist/options-DToWdVqW.js +4 -0
  782. package/dist/options-DUNUGuhM.js +4 -0
  783. package/dist/options-DWgpi5ns.js +7 -0
  784. package/dist/options-DeamnVOY.d.ts +12 -0
  785. package/dist/options-Dg7eK-_J.d.ts +8 -0
  786. package/dist/options-DiIlMZpc.js +8 -0
  787. package/dist/options-DjFbIRgV.js +16 -0
  788. package/dist/options-DjtCYRWb.js +4 -0
  789. package/dist/options-Dk6D88Zx.d.ts +6 -0
  790. package/dist/options-DpwRG4tO.js +8 -0
  791. package/dist/options-DvgKdZ2K.js +9 -0
  792. package/dist/options-DwIoRvic.js +4 -0
  793. package/dist/options-GwwLsKf5.js +8 -0
  794. package/dist/options-I1ZHfDP0.d.ts +58 -0
  795. package/dist/options-Itq7QYoW.js +20 -0
  796. package/dist/options-JnPEVbBJ.js +17 -0
  797. package/dist/options-Jwux4JDX.js +7 -0
  798. package/dist/options-Lg76d-cV.js +7 -0
  799. package/dist/options-Lh6uxepF.d.ts +24 -0
  800. package/dist/options-Oki2W_c3.js +4 -0
  801. package/dist/options-PM7IaIFP.js +10 -0
  802. package/dist/options-PTLBl6QT.js +7 -0
  803. package/dist/options-PheFo4JY.js +10 -0
  804. package/dist/options-SlC_jZ7y.js +4 -0
  805. package/dist/options-Sq4bYbf5.js +13 -0
  806. package/dist/options-XiD_Y3oK.js +14 -0
  807. package/dist/options-Z-bd_H1E.js +88 -0
  808. package/dist/options-ax_ssX_m.js +4 -0
  809. package/dist/options-bNB8_nlW.js +23 -0
  810. package/dist/options-eIEk0vqV.js +4 -0
  811. package/dist/options-eLIedotm.js +7 -0
  812. package/dist/options-jg0FMHA5.js +4 -0
  813. package/dist/options-mypVYaqR.js +9 -0
  814. package/dist/options-ompJjxkV.js +4 -0
  815. package/dist/options-pbc4H8_A.js +7 -0
  816. package/dist/options-uUGi0Phf.d.ts +14 -0
  817. package/dist/options-yRwYr4up.js +4 -0
  818. package/dist/options-z2Zhi97E.js +9 -0
  819. package/dist/options-zYV6M0vr.js +8 -0
  820. package/dist/orpc/index.d.ts +13 -19
  821. package/dist/orpc/index.js +20 -23
  822. package/dist/otel/index.d.ts +4 -6
  823. package/dist/otel/index.js +8 -10
  824. package/dist/outbox-7zgh-7nw.d.ts +197 -0
  825. package/dist/payments-B4JchZuJ.js +15 -0
  826. package/dist/payments-BBGSGRQ7.d.ts +112 -0
  827. package/dist/permissions-BDt27oYF.js +48 -0
  828. package/dist/permissions-BP593xxk.d.ts +44 -0
  829. package/dist/permissions-controller-B4uI5IPH.js +33 -0
  830. package/dist/pg-error-D92B6jlF.js +25 -0
  831. package/dist/plugin-Ca2qBiFZ.js +47 -0
  832. package/dist/pool-D-4HyhuW.d.ts +121 -0
  833. package/dist/pool-errors-JrZie6u3.js +26 -0
  834. package/dist/ports-BVLhLUvR.d.ts +87 -0
  835. package/dist/ports-CmEXVqhg.js +150 -0
  836. package/dist/postgres/index.d.ts +5 -11
  837. package/dist/postgres/index.js +7 -9
  838. package/dist/postgrest-DZtM2nIS.d.ts +51 -0
  839. package/dist/postgrest-executor-lf8Mt4J0.js +1064 -0
  840. package/dist/powersync/index.d.ts +7 -25
  841. package/dist/powersync/index.js +14 -24
  842. package/dist/preset/index.d.ts +3 -3
  843. package/dist/preset/index.js +3 -3
  844. package/dist/preset-om2rbdYw.js +1038 -0
  845. package/dist/problem-C0SVHhd3.js +161 -0
  846. package/dist/problem-NGBjN-TO.d.ts +77 -0
  847. package/dist/project-D4ArwcS5.js +1749 -0
  848. package/dist/provider-B6qpleR9.js +56 -0
  849. package/dist/provider-BI0KC4u5.d.ts +142 -0
  850. package/dist/providers-C9sBIBYE.js +62 -0
  851. package/dist/push-token-B0j171on.d.ts +22 -0
  852. package/dist/push-token-CO28k46S.js +15 -0
  853. package/dist/queries-BLrxg_GL.js +238 -0
  854. package/dist/query/index.d.ts +3 -3
  855. package/dist/query/index.js +11 -15
  856. package/dist/range-BN3kpJAE.d.ts +6 -0
  857. package/dist/range-Nrh_qtb_.js +6 -0
  858. package/dist/rank-keys-CEBzd9Xa.js +59 -0
  859. package/dist/rank-result-B_xLQCBV.d.ts +12 -0
  860. package/dist/rank-result-DzaTKKhH.js +17 -0
  861. package/dist/rate-limit-C89Yzwd9.d.ts +48 -0
  862. package/dist/rate-limit-CRhlLFhP.js +380 -0
  863. package/dist/rate-limit-DXJbLVg0.js +48 -0
  864. package/dist/ratelimit-headers-CpB-cDD6.js +61 -0
  865. package/dist/react/index.d.ts +11 -11
  866. package/dist/react/index.js +6 -6
  867. package/dist/react/native/index.d.ts +3 -5
  868. package/dist/react/native/index.js +5 -5
  869. package/dist/react/server.d.ts +13 -15
  870. package/dist/react/server.js +9 -10
  871. package/dist/react/session.d.ts +4 -6
  872. package/dist/react/session.js +2 -3
  873. package/dist/react-COIov1yC.js +1006 -0
  874. package/dist/react-CqOVutZj.js +80 -0
  875. package/dist/react-router/index.d.ts +7 -12
  876. package/dist/react-router/index.js +10 -12
  877. package/dist/read-set-DEDoIHMM.js +198 -0
  878. package/dist/realtime/index.d.ts +7 -7
  879. package/dist/realtime/index.js +6 -7
  880. package/dist/realtime-status-CocmAOPv.js +10 -0
  881. package/dist/realtime-status-D3oUx3o4.d.ts +6 -0
  882. package/dist/record-bindings-jTZw-GVe.js +25 -0
  883. package/dist/record-form-DU2EoVsv.d.ts +80 -0
  884. package/dist/record-type-oQxekQTX.js +219 -0
  885. package/dist/recordings-D69Va7gP.d.ts +117 -0
  886. package/dist/records/index.d.ts +10 -14
  887. package/dist/records/index.js +13 -16
  888. package/dist/refresh-B8t_KE3s.js +142 -0
  889. package/dist/refresh-BtbC2rZe.d.ts +52 -0
  890. package/dist/refusal-5c6UMpUP.js +63 -0
  891. package/dist/refusal-CGi-0Q18.d.ts +30 -0
  892. package/dist/relay-CllqA-lV.js +248 -0
  893. package/dist/resolve--LfVoOMg.d.ts +287 -0
  894. package/dist/resolve-FW8oeXvh.js +927 -0
  895. package/dist/resolved-names-DYYyh35i.js +130 -0
  896. package/dist/resource-BbWk4hoP.js +561 -0
  897. package/dist/resource-DQ4kIBpa.js +104 -0
  898. package/dist/resource-DWllVW8k.d.ts +124 -0
  899. package/dist/resource-execute-DUBYKTYU.d.ts +13 -0
  900. package/dist/resource-schemas-Bq0g2RCQ.js +81 -0
  901. package/dist/resource-types-RgaljPs0.d.ts +155 -0
  902. package/dist/resources-Bki1J4jy.d.ts +5 -0
  903. package/dist/resources-DYSx9NYM.js +63 -0
  904. package/dist/respond-BYOV7KZp.d.ts +108 -0
  905. package/dist/respond-DLH4tD2d.js +106 -0
  906. package/dist/result-8xza7w5W.js +145 -0
  907. package/dist/result-DTOQRyGY.d.ts +347 -0
  908. package/dist/rows-Ce8dsmfM.js +79 -0
  909. package/dist/rows-D-RqIsRz.js +38 -0
  910. package/dist/rrule-BLpe2449.js +289 -0
  911. package/dist/run-keys-BnzqxtYc.d.ts +59 -0
  912. package/dist/run-state-D0Tbl-nM.d.ts +11 -0
  913. package/dist/run-state-DGiyDQxH.js +12 -0
  914. package/dist/run-watch-DJk4Q603.js +52 -0
  915. package/dist/runtime-qslVrC9l.js +43 -0
  916. package/dist/sales-lines-DuNVoKHA.d.ts +36 -0
  917. package/dist/sales-lines-axwWhnLk.js +44 -0
  918. package/dist/sales-shared-CY3s_wBx.js +21 -0
  919. package/dist/sandboxes-B2hBoBvJ.d.ts +85 -0
  920. package/dist/schemas-CpoEiAeT.js +213 -0
  921. package/dist/scope-dD_OAgRU.js +89 -0
  922. package/dist/scores-Bvk_JgXL.js +176 -0
  923. package/dist/scores-FAORS4qU.d.ts +172 -0
  924. package/dist/search-DtbkD0h0.js +8 -0
  925. package/dist/server/index.d.ts +39 -70
  926. package/dist/server/index.js +55 -59
  927. package/dist/server-types-C2hlvhP4.d.ts +521 -0
  928. package/dist/session-B4VasaAA.d.ts +96 -0
  929. package/dist/session-status-D8CBxCqv.d.ts +80 -0
  930. package/dist/shared-Bmcnxwie.js +16 -0
  931. package/dist/shared-Ci1g9nl4.js +90 -0
  932. package/dist/shared-DsBcvj6q.d.ts +9 -0
  933. package/dist/sign-in-BMm1xhKq.js +730 -0
  934. package/dist/sign-in-C9pZE1kM.d.ts +53 -0
  935. package/dist/sign-in-CX1a5i2P.d.ts +52 -0
  936. package/dist/sign-in-CxdoTEp5.js +399 -0
  937. package/dist/signatures-CBn7w4VR.js +144 -0
  938. package/dist/signatures-jPr9JXyw.d.ts +41 -0
  939. package/dist/signers-6ih6i9aq.d.ts +380 -0
  940. package/dist/signing-keys-BC5_hJN5.js +163 -0
  941. package/dist/signing-keys-De09WNJ3.d.ts +117 -0
  942. package/dist/simplify-BzThKn5b.js +82 -0
  943. package/dist/snapshot-BGsJw9xn.d.ts +83 -0
  944. package/dist/snapshot-CVMSyTHH.js +138 -0
  945. package/dist/solid/index.d.ts +12 -22
  946. package/dist/solid/index.js +10 -16
  947. package/dist/solid-start/index.d.ts +6 -9
  948. package/dist/solid-start/index.js +8 -9
  949. package/dist/spec/index.d.ts +6 -48
  950. package/dist/spec/index.js +23 -39
  951. package/dist/spec-6Vr7sc0Z.js +123 -0
  952. package/dist/spec-pins-CuQ2anBw.d.ts +125 -0
  953. package/dist/spec-pins-FKUzgF6K.js +61 -0
  954. package/dist/sql/index.d.ts +6 -5
  955. package/dist/sql/index.js +5 -5
  956. package/dist/sql-C1K5JALb.js +420 -0
  957. package/dist/sql-DiUP7fKX.js +140711 -0
  958. package/dist/sql-type-XWMeZRAl.js +33 -0
  959. package/dist/sqlite/index.d.ts +3 -9
  960. package/dist/sqlite/index.js +5 -8
  961. package/dist/sso-CRnaFJh0.js +216 -0
  962. package/dist/sso-CuzAjsc8.d.ts +159 -0
  963. package/dist/ssr/index.d.ts +5 -5
  964. package/dist/ssr/index.js +3 -3
  965. package/dist/standard-BD2aOUsf.js +24 -0
  966. package/dist/standard-DRX6Ch1j.d.ts +5 -0
  967. package/dist/stats-BTJgRMEp.js +82 -0
  968. package/dist/statuses-BTrQ5H4S.js +27 -0
  969. package/dist/statuses-Bv-0XoYC.js +27 -0
  970. package/dist/storage/index.d.ts +3 -3
  971. package/dist/storage/index.js +27 -40
  972. package/dist/storage-api-COQr77e8.js +9 -0
  973. package/dist/store-CKKzmsWB.js +68 -0
  974. package/dist/store-c7QxUHX-.d.ts +81 -0
  975. package/dist/streams/index.d.ts +3 -7
  976. package/dist/streams/index.js +5 -6
  977. package/dist/streams/redis/index.d.ts +1 -3
  978. package/dist/streams/redis/index.js +6 -7
  979. package/dist/stripe/index.d.ts +1 -3
  980. package/dist/stripe/index.js +3 -4
  981. package/dist/stripe-Bl-sjnl6.d.ts +154 -0
  982. package/dist/stripe-DKRwRWew.js +31 -0
  983. package/dist/subject-readers-BARV5rNp.js +48 -0
  984. package/dist/subject-readers-BlD8tALG.d.ts +19 -0
  985. package/dist/subject-type-BarjdHZV.js +7 -0
  986. package/dist/subjects-BGwLJ3IB.d.ts +148 -0
  987. package/dist/subjects-Bv2dPflD.d.ts +86 -0
  988. package/dist/subscribers-C57054Pc.js +32 -0
  989. package/dist/summaries-CUemsYwV.d.ts +67 -0
  990. package/dist/supabase-mcp-DY32eoax.d.ts +44 -0
  991. package/dist/supabase-mcp-QvebHckf.js +27 -0
  992. package/dist/support-DxYI6sDM.d.ts +351 -0
  993. package/dist/support-view-CvDEgyGY.js +17 -0
  994. package/dist/support-view-DSmCett7.d.ts +15 -0
  995. package/dist/svelte/index.d.ts +11 -21
  996. package/dist/svelte/index.js +9 -15
  997. package/dist/sveltekit/index.d.ts +9 -14
  998. package/dist/sveltekit/index.js +12 -14
  999. package/dist/table-schema-CwXg7oBz.d.ts +77 -0
  1000. package/dist/table-schema-D-ss9ozY.js +291 -0
  1001. package/dist/tables-BSiVuKKx.js +72 -0
  1002. package/dist/tags--k2fbPfO.d.ts +28 -0
  1003. package/dist/tags-CW-KvjdL.js +38 -0
  1004. package/dist/tanstack-db/index.d.ts +4 -8
  1005. package/dist/tanstack-db/index.js +4 -6
  1006. package/dist/tanstack-start/index.d.ts +7 -12
  1007. package/dist/tanstack-start/index.js +8 -10
  1008. package/dist/tax-BD9dN1rx.d.ts +168 -0
  1009. package/dist/tax-BwckP5dv.js +139 -0
  1010. package/dist/tee-CVOMhEX-.js +100 -0
  1011. package/dist/template-CNq9xcfx.js +125 -0
  1012. package/dist/temporal-DKTdGK9i.js +94 -0
  1013. package/dist/temporal-required-w_2u4EDp.js +19 -0
  1014. package/dist/tenant-B3IIq8Eq.d.ts +14 -0
  1015. package/dist/tenant-Beqd7TTq.js +48 -0
  1016. package/dist/tenant-source-46lMuMEn.js +7 -0
  1017. package/dist/testing/index.d.ts +120 -127
  1018. package/dist/testing/index.js +277 -129
  1019. package/dist/timeline-Bq658xsi.d.ts +147 -0
  1020. package/dist/timeline-Bs-FGMIJ.js +49 -0
  1021. package/dist/timing-B6yHayKA.js +94 -0
  1022. package/dist/topic-D2MyBeaI.d.ts +411 -0
  1023. package/dist/topic-k17VvXRj.js +640 -0
  1024. package/dist/transport-CS4cVH4S.js +30 -0
  1025. package/dist/ttl-cache-C5S0L2wx.js +31 -0
  1026. package/dist/types-BBqP9H6w.d.ts +175 -0
  1027. package/dist/types-BFEKRmEK.d.ts +449 -0
  1028. package/dist/types-BkYEUWdz.d.ts +1095 -0
  1029. package/dist/types-C8UyJOPJ.d.ts +247 -0
  1030. package/dist/types-DCoqai8o.d.ts +215 -0
  1031. package/dist/types-Dh2OGEW5.d.ts +648 -0
  1032. package/dist/types-DnrJ_crV.js +28 -0
  1033. package/dist/types-TH3zlMiM.d.ts +192 -0
  1034. package/dist/types-d0JBRTAg.d.ts +660 -0
  1035. package/dist/undo-22ofP6Zp.d.ts +44 -0
  1036. package/dist/undo-Dki6Ujak.js +43 -0
  1037. package/dist/upload-claim-Bo2mpBz4.js +32 -0
  1038. package/dist/usage-CNCT6_3D.d.ts +230 -0
  1039. package/dist/user-change-Ngy8z1fZ.js +133 -0
  1040. package/dist/variants-BaMleC56.js +51 -0
  1041. package/dist/vault-yGQD5Rdl.d.ts +60 -0
  1042. package/dist/vercel-connect/index.d.ts +194 -20
  1043. package/dist/vercel-connect/index.js +265 -33
  1044. package/dist/vercel-sandbox/index.d.ts +166 -0
  1045. package/dist/vercel-sandbox/index.js +171 -0
  1046. package/dist/verify-BQu3eBNW.d.ts +144 -0
  1047. package/dist/verify-DY_j4GPZ.js +129 -0
  1048. package/dist/view-BfEqjZJ_.js +117 -0
  1049. package/dist/view-Cy2XxYp1.d.ts +107 -0
  1050. package/dist/vue/index.d.ts +12 -22
  1051. package/dist/vue/index.js +10 -16
  1052. package/dist/watch-topic-C2KxpeaB.js +56 -0
  1053. package/dist/watch-topic-q6krNw0T.d.ts +29 -0
  1054. package/dist/wire-DIoLA8VL.js +90 -0
  1055. package/dist/wiring-DJBSLdyF.js +12 -0
  1056. package/dist/workflow-sdk/builder/index.d.ts +12 -14
  1057. package/dist/workflow-sdk/builder/index.js +12 -11
  1058. package/dist/workflow-sdk/index.d.ts +62 -6
  1059. package/dist/workflow-sdk/index.js +75 -10
  1060. package/dist/workflow-sdk/world/index.d.ts +13 -20
  1061. package/dist/workflow-sdk/world/index.js +115 -26
  1062. package/dist/workflow-sdk-BL3wzkdp.js +2749 -0
  1063. package/dist/workflow-sdk-q2jnEaAJ.js +302 -0
  1064. package/dist/workflow-sdk-yIkECybp.d.ts +171 -0
  1065. package/dist/workflows-BljkWRxE.d.ts +256 -0
  1066. package/dist/yjs/index.d.ts +3 -5
  1067. package/dist/yjs/index.js +6 -7
  1068. package/package.json +56 -31
  1069. package/schemas/config-v1.json +60 -3
  1070. package/schemas/doctor-report-v1.json +1 -0
  1071. package/schemas/snapshot-v2.json +7 -0
  1072. package/skills/better-supabase/SKILL.md +4 -4
  1073. package/skills/better-supabase/references/block-extensions.md +2 -2
  1074. package/skills/better-supabase/references/troubleshooting.md +1 -1
  1075. package/skills/better-supabase/references/ui-recipes.md +73 -36
  1076. package/skills/better-supabase-api/SKILL.md +1 -1
  1077. package/skills/better-supabase-api/references/adapters.md +3 -3
  1078. package/skills/better-supabase-api/references/ai.md +8 -0
  1079. package/skills/better-supabase-auth/SKILL.md +19 -19
  1080. package/skills/better-supabase-auth/references/authorization-providers.md +1 -1
  1081. package/dist/access-sql-CTDNuxRv.js +0 -385
  1082. package/dist/actor-CoveJgya.d.ts +0 -106
  1083. package/dist/actor-go7p9-CJ.js +0 -150
  1084. package/dist/adapter-BTbj5N9C.js +0 -2251
  1085. package/dist/agents-CM_cCtcr.d.ts +0 -117
  1086. package/dist/ai-cache-BFRKxgZ4.js +0 -87
  1087. package/dist/ai-cache-BTGqckta.d.ts +0 -82
  1088. package/dist/ai-chat-B7_vQvxU.d.ts +0 -619
  1089. package/dist/ai-files-m_2z3rH1.js +0 -339
  1090. package/dist/ai-message-DfaP8sis.js +0 -14
  1091. package/dist/ai-schedules-CZEfo-_M.d.ts +0 -166
  1092. package/dist/anchors-7F34QyHa.d.ts +0 -40
  1093. package/dist/api-3C0AWFeP.js +0 -696
  1094. package/dist/api-59rv5hL6.d.ts +0 -495
  1095. package/dist/api-keys-JE-aykZE.d.ts +0 -213
  1096. package/dist/app-tables-B2mKMNRQ.d.ts +0 -28
  1097. package/dist/approvals-BfEafAzt.d.ts +0 -129
  1098. package/dist/assistant-B49qATbj.d.ts +0 -157
  1099. package/dist/attachments-BXbLnNxm.js +0 -376
  1100. package/dist/attributes-Bzf51_nc.js +0 -47
  1101. package/dist/auth-DyF_LRxd.js +0 -20
  1102. package/dist/auth-link-B4NL84XU.d.ts +0 -104
  1103. package/dist/auth-link-D3-bU6yz.js +0 -118
  1104. package/dist/auth-module-BbmX-N4L.js +0 -52
  1105. package/dist/auth-reply-Dj124sbX.d.ts +0 -11
  1106. package/dist/auth-reply-tlXB2FQ9.js +0 -31
  1107. package/dist/authorization-DfEkyFt_.d.ts +0 -3867
  1108. package/dist/authorization-hooks-BWhkMZfH.d.ts +0 -221
  1109. package/dist/authorizer-B6X09otb.d.ts +0 -118
  1110. package/dist/authorizer-BGhXaDmo.js +0 -172
  1111. package/dist/automation-D41DXyvT.js +0 -75
  1112. package/dist/automations-8L3NEuoq.js +0 -29
  1113. package/dist/automations-BKjJpktQ.js +0 -33
  1114. package/dist/automations-BMuqwZZn.js +0 -314
  1115. package/dist/automations-EzXteupo.js +0 -31
  1116. package/dist/availability-BdeKCHpl.d.ts +0 -236
  1117. package/dist/base64-B9Wlsdj7.js +0 -42
  1118. package/dist/batch-limit-DKVQDz4o.js +0 -5
  1119. package/dist/before-route-B23K2zYU.js +0 -30
  1120. package/dist/bind-DAx0bMSi.d.ts +0 -104
  1121. package/dist/block-authors-Bw3zdzgl.js +0 -14
  1122. package/dist/block-authors-DzXLUiIq.d.ts +0 -12
  1123. package/dist/block-env-Dz7Caxk0.d.ts +0 -32
  1124. package/dist/block-event-listener-Bu6G0TFH.js +0 -16
  1125. package/dist/block-events-IWAyafO3.js +0 -83
  1126. package/dist/block-fields-BE7pInWZ.d.ts +0 -58
  1127. package/dist/block-fields-BjXgX_5c.js +0 -140
  1128. package/dist/block-helpers-B0f0ZVb5.js +0 -437
  1129. package/dist/block-helpers-D5emQ2O6.d.ts +0 -62
  1130. package/dist/block-hooks-B8itxzEE.d.ts +0 -117
  1131. package/dist/block-hooks-DKtz0HRh.js +0 -130
  1132. package/dist/block-method-C9hWdHom.js +0 -21
  1133. package/dist/block-method-CiVa2G-J.d.ts +0 -14
  1134. package/dist/block-subjects-C1_9DkSA.d.ts +0 -6
  1135. package/dist/block-subjects-DFSuFY1a.js +0 -55
  1136. package/dist/block-tenant-DHp7subc.js +0 -14
  1137. package/dist/block-transport-9EUA3q_I.d.ts +0 -69
  1138. package/dist/bookings-xsmM2TA_.d.ts +0 -289
  1139. package/dist/bucket-SvRQwYS4.d.ts +0 -705
  1140. package/dist/build-CH2N3Yf0.js +0 -2073
  1141. package/dist/build-DbIRFcHQ.js +0 -735
  1142. package/dist/carrier-KzeYXVrW.d.ts +0 -169
  1143. package/dist/casing-DdFWEtqr.js +0 -16
  1144. package/dist/channel-JcMd5lNP.d.ts +0 -105
  1145. package/dist/channels-CfcFPuo_.js +0 -114
  1146. package/dist/claims-Bp9My7XP.js +0 -88
  1147. package/dist/claims-DTy6R6my.js +0 -63
  1148. package/dist/cli/_format-Cax5EsM9.js +0 -101
  1149. package/dist/cli/add-B9wP0YGU.js +0 -99
  1150. package/dist/cli/add-DjZXKd7X.js +0 -1231
  1151. package/dist/cli/add-ZcEOEK23.js +0 -1
  1152. package/dist/cli/agent-CbuPvI2x.js +0 -185
  1153. package/dist/cli/app-table-files-mtvjHa48.js +0 -346
  1154. package/dist/cli/arazzo-1.0-BalU61-_.js +0 -532
  1155. package/dist/cli/arazzo-1.1-Bnfasbun.js +0 -705
  1156. package/dist/cli/args-UEwg0l-N.js +0 -27
  1157. package/dist/cli/asyncapi-3.0.0-C78dBjR6.js +0 -5593
  1158. package/dist/cli/asyncapi-3.1.0-g-7aIfV1.js +0 -5833
  1159. package/dist/cli/backfill-Coshdvh_.js +0 -293
  1160. package/dist/cli/blocks-BWCuA0nq.js +0 -156
  1161. package/dist/cli/blocks-hiSazThw.js +0 -1
  1162. package/dist/cli/cache-x2wWAy0h.js +0 -607
  1163. package/dist/cli/codemod-BnjV7BpC.js +0 -2634
  1164. package/dist/cli/codemod-block-renames-BuSaTE_G.js +0 -239
  1165. package/dist/cli/command-CCAwhiOh.js +0 -1003
  1166. package/dist/cli/compare-BmIWVEui.js +0 -9
  1167. package/dist/cli/completion-BJaB84Pe.js +0 -211
  1168. package/dist/cli/completion-BkUhs1ms.js +0 -1
  1169. package/dist/cli/completion-DmUVsUVQ.js +0 -30
  1170. package/dist/cli/config-Cskysxp-.js +0 -2000
  1171. package/dist/cli/config-Df5cXWNN.js +0 -1
  1172. package/dist/cli/config-edit-CrWfk8s3.js +0 -621
  1173. package/dist/cli/config-group-CP-B9uRt.js +0 -390
  1174. package/dist/cli/config-zId1jkLx.js +0 -47
  1175. package/dist/cli/content-mapper-DvOSOdTE.js +0 -182
  1176. package/dist/cli/db-CQCLx7cx.js +0 -78
  1177. package/dist/cli/db-DXKyVEDF.js +0 -247
  1178. package/dist/cli/detect-D9JaAX20.js +0 -84
  1179. package/dist/cli/dist-D_VbPAMR.js +0 -129
  1180. package/dist/cli/dist-DuiMMRbJ.js +0 -1112
  1181. package/dist/cli/doctor-Ywy8oJEU.js +0 -4684
  1182. package/dist/cli/env-BK0xKMeU.js +0 -1113
  1183. package/dist/cli/env-Bat6ogep.js +0 -1
  1184. package/dist/cli/env-CNjT_uOV.js +0 -1
  1185. package/dist/cli/env-XMiKvhtV.js +0 -143
  1186. package/dist/cli/errors-BTe6A15O.js +0 -98
  1187. package/dist/cli/exec-Ca5s-ygi.js +0 -463
  1188. package/dist/cli/fastest-levenshtein-dhRRvrM2.js +0 -120
  1189. package/dist/cli/files-CX71yBm8.js +0 -1010
  1190. package/dist/cli/fresh-import-DzgsGHkX.js +0 -40
  1191. package/dist/cli/gen-B-FbQmG1.js +0 -394
  1192. package/dist/cli/guards-CUlDNYZs.js +0 -8
  1193. package/dist/cli/in-stack-diff-Cp-tVPj2.js +0 -186
  1194. package/dist/cli/init-fb9e1BKX.js +0 -559
  1195. package/dist/cli/io-DH1kcmmP.js +0 -37
  1196. package/dist/cli/json5-ChRycquj.js +0 -787
  1197. package/dist/cli/jsonc-C8M0EhHB.js +0 -1
  1198. package/dist/cli/jsonc-D5Fu67jw.js +0 -45
  1199. package/dist/cli/keys-ORiPz1sM.js +0 -106
  1200. package/dist/cli/legacy-prefix-R7UChFFl.js +0 -154
  1201. package/dist/cli/live-DIt7TP-N.js +0 -341
  1202. package/dist/cli/mcp-CVWwraga.js +0 -241
  1203. package/dist/cli/metadata-CannIjel.js +0 -150
  1204. package/dist/cli/migrate-Ht2TzIQF.js +0 -46
  1205. package/dist/cli/migration-safety-nNyB05I-.js +0 -928
  1206. package/dist/cli/migrations-bAd7dpk1.js +0 -117
  1207. package/dist/cli/module-migration-CkNux8dr.js +0 -119
  1208. package/dist/cli/moved-C3WyRHkA.js +0 -254
  1209. package/dist/cli/ohash-BjQY1cBb.js +0 -277
  1210. package/dist/cli/openapi-3.0-t7xwkuRH.js +0 -928
  1211. package/dist/cli/openapi-3.1-CVze7tBS.js +0 -870
  1212. package/dist/cli/openapi-3.2-CFoMYM01.js +0 -1031
  1213. package/dist/cli/orphans-BAboqyVM.js +0 -28
  1214. package/dist/cli/parse-DjHbTaFI.js +0 -182
  1215. package/dist/cli/powersync-B2v0tDwp.js +0 -377
  1216. package/dist/cli/powersync-D3mAQ6QE.js +0 -1
  1217. package/dist/cli/preset-BwmIfFnh.js +0 -101
  1218. package/dist/cli/print-CxQ0rBKT.js +0 -68
  1219. package/dist/cli/prompts-jqnr94b9.js +0 -1140
  1220. package/dist/cli/providers-DtI90lSw.js +0 -301
  1221. package/dist/cli/redact-KGAk2Ul9.js +0 -38
  1222. package/dist/cli/remove-DYtE4IZ4.js +0 -239
  1223. package/dist/cli/render-QGWfEoiB.js +0 -2225
  1224. package/dist/cli/rolldown-runtime-kJ_i4yPo.js +0 -26
  1225. package/dist/cli/run-B5aMwErM.js +0 -63
  1226. package/dist/cli/run-BNoJKf5I.js +0 -706
  1227. package/dist/cli/run-DiYX1XEa.js +0 -1459
  1228. package/dist/cli/seed-C-Hu2n_E.js +0 -188
  1229. package/dist/cli/seed-Cm-c0BDd.js +0 -1
  1230. package/dist/cli/shared-D_CFi5di.js +0 -151
  1231. package/dist/cli/shell-Btv_4Yhe.js +0 -10
  1232. package/dist/cli/skills-D98y0bSB.js +0 -121
  1233. package/dist/cli/snapshot-BlQ4DDcJ.js +0 -734
  1234. package/dist/cli/source-CelMBQMj.js +0 -320
  1235. package/dist/cli/source-args-v8ljFDfc.js +0 -59
  1236. package/dist/cli/spec-BxcoGE0h.js +0 -1
  1237. package/dist/cli/spec-iBx1LcYO.js +0 -7530
  1238. package/dist/cli/sql-layout-Dp4Rottt.js +0 -261
  1239. package/dist/cli/stack-B2slzrYH.js +0 -135
  1240. package/dist/cli/stack-env-3ziggrU3.js +0 -93
  1241. package/dist/cli/stack-status-BkkYRlXG.js +0 -46
  1242. package/dist/cli/stacks-CiDBH1dB.js +0 -232
  1243. package/dist/cli/style-Bm2X5JrN.js +0 -35
  1244. package/dist/cli/supabase-toml-CncmQbO0.js +0 -1164
  1245. package/dist/cli/sync-BnORI43S.js +0 -322
  1246. package/dist/cli/table-D6HUECKI.js +0 -89
  1247. package/dist/cli/toml-DB-MNnFs.js +0 -424
  1248. package/dist/cli/topics-BpdnYmWb.js +0 -30
  1249. package/dist/cli/trace-VbdO6bcN.js +0 -7
  1250. package/dist/cli/upgrade-CR6-WmIc.js +0 -272
  1251. package/dist/cli/upgrade-fz92aCnh.js +0 -41
  1252. package/dist/cli/validate-B3lF3-jB.js +0 -7522
  1253. package/dist/cli/version-Dz8ZlOuh.js +0 -4
  1254. package/dist/cli/yaml-CYCbJ6et.js +0 -2252
  1255. package/dist/client-C_mlji5R.js +0 -288
  1256. package/dist/clone-CkG0-hlI.js +0 -33
  1257. package/dist/cloud-event-0pQ9vFNS.d.ts +0 -64
  1258. package/dist/cloud-event-XsM53POL.js +0 -63
  1259. package/dist/codecs-CMWlhHZ0.d.ts +0 -222
  1260. package/dist/codecs-CSUFGrdP.js +0 -358
  1261. package/dist/compiler-BEeVWXPS.d.ts +0 -14
  1262. package/dist/compose-DKW0Tr3e.js +0 -53
  1263. package/dist/composite-B4qB6k31.js +0 -130
  1264. package/dist/composite-BJ9s-IJJ.d.ts +0 -83
  1265. package/dist/config-B7g-HDis.js +0 -1111
  1266. package/dist/config-R0m0fBiD.js +0 -1679
  1267. package/dist/connectors-uC5baoFV.d.ts +0 -147
  1268. package/dist/context-DBicfUNz.js +0 -41
  1269. package/dist/context-DWWoP1wK.d.ts +0 -4344
  1270. package/dist/controller-BEliOBOv.js +0 -79
  1271. package/dist/controller-Br9dGKGe.d.ts +0 -52
  1272. package/dist/controller-W97g2WGG.js +0 -73
  1273. package/dist/conversion-Dq1S7xzE.js +0 -77
  1274. package/dist/conversion-g8HzH9My.d.ts +0 -86
  1275. package/dist/cors-h_v7TPxl.js +0 -24
  1276. package/dist/cors-kLq6VM06.d.ts +0 -15
  1277. package/dist/create-blocks-BfrDUSM6.js +0 -370
  1278. package/dist/cron-DdT4ti8a.js +0 -148
  1279. package/dist/cron-route-FjKgRvTY.js +0 -24
  1280. package/dist/csv-2rXGPNtP.js +0 -89
  1281. package/dist/csv-DhHQS2x_.d.ts +0 -28
  1282. package/dist/data-engine-D1BkmBoR.js +0 -173
  1283. package/dist/data-engine-rvbR2C4F.d.ts +0 -273
  1284. package/dist/data-hooks-CdcZfVS1.js +0 -280
  1285. package/dist/db-exception-Lngc1W49.js +0 -31
  1286. package/dist/deal-forecast-CKBnRodz.js +0 -39
  1287. package/dist/deal-forecast-LwO-Z4_C.d.ts +0 -23
  1288. package/dist/define-D-dLADd5.js +0 -2084
  1289. package/dist/define-D8_9X5fZ.d.ts +0 -1263
  1290. package/dist/define-block-BGqOO8B3.js +0 -64
  1291. package/dist/define-block-DWVZSZv1.d.ts +0 -1687
  1292. package/dist/delegation-C7eWP2r8.d.ts +0 -14
  1293. package/dist/delegation-DGOIiT8k.js +0 -153
  1294. package/dist/delivery-Bm0jxmzI.js +0 -29
  1295. package/dist/delivery-events-DbL8IHIY.js +0 -53
  1296. package/dist/delivery-n6lZGuGx.d.ts +0 -71
  1297. package/dist/documents-BbwYyynk.d.ts +0 -152
  1298. package/dist/email-B3YxEzwC.d.ts +0 -42
  1299. package/dist/embeddings-I3s5sTDt.d.ts +0 -78
  1300. package/dist/embeddings-vVzseUw0.js +0 -128
  1301. package/dist/ended-EZzN9QTM.d.ts +0 -26
  1302. package/dist/entitlements-CBjm2lvD.d.ts +0 -54
  1303. package/dist/entitlements-tGL6-69B.js +0 -45
  1304. package/dist/entity-naming-Dtyq5sKE.js +0 -131
  1305. package/dist/entity-schema-B1YmMtP8.js +0 -39
  1306. package/dist/envelope-DEI2iX-d.js +0 -90
  1307. package/dist/errors-BVFgt8BZ.js +0 -328
  1308. package/dist/errors-CyxMxzlu.js +0 -44
  1309. package/dist/escape-like-DHfx6jRr.js +0 -7
  1310. package/dist/escape-like-PReMbEEU.d.ts +0 -30
  1311. package/dist/eve-BfhVFV33.d.ts +0 -157
  1312. package/dist/event-calendar-DVLs2wUO.d.ts +0 -65
  1313. package/dist/event-map-CtPFhcOp.js +0 -19
  1314. package/dist/events-B2qbZps6.d.ts +0 -854
  1315. package/dist/events-D6IZ5CE8.js +0 -82
  1316. package/dist/events-DuLhzjP6.js +0 -26
  1317. package/dist/executor-BfirBzOr.d.ts +0 -174
  1318. package/dist/executor-BlS0kCrN.d.ts +0 -104
  1319. package/dist/executor-C2Ne-Scm.js +0 -208
  1320. package/dist/executor-DXQIx4sW.d.ts +0 -37
  1321. package/dist/executor-DqIci3Jb.js +0 -486
  1322. package/dist/executor-WolvKszH.js +0 -843
  1323. package/dist/extension-DTaHjwdc.js +0 -59
  1324. package/dist/extension-DeAd_MqI.js +0 -121
  1325. package/dist/extension-DzCc0IOd.js +0 -103
  1326. package/dist/extension-mGylYROs.js +0 -53
  1327. package/dist/extension-shared-Djm8mGHD.js +0 -60
  1328. package/dist/extra-CGQ2_q3S.js +0 -10
  1329. package/dist/field-errors-CEjsMAgd.d.ts +0 -216
  1330. package/dist/field-formats-C6QKA3UR.js +0 -102
  1331. package/dist/field-formats-CAFNkKSN.d.ts +0 -38
  1332. package/dist/fields-BBm49w-E.js +0 -108
  1333. package/dist/fields-snbaZ14h.d.ts +0 -78
  1334. package/dist/filter-evaluate-BRpNiNPG.d.ts +0 -37
  1335. package/dist/filter-evaluate-lCToXzZI.js +0 -217
  1336. package/dist/filter-query-CQ6d5GnQ.js +0 -566
  1337. package/dist/filter-query-DBt7OKuH.d.ts +0 -133
  1338. package/dist/flags-DDKTThrO.d.ts +0 -246
  1339. package/dist/flags-DF_SCqp5.js +0 -279
  1340. package/dist/form-definition-BTpM_tz1.js +0 -363
  1341. package/dist/form-definition-BjEtH8BT.d.ts +0 -119
  1342. package/dist/format-u-65igKI.d.ts +0 -79
  1343. package/dist/framework-CqiZk89W.js +0 -58
  1344. package/dist/framework-DVYTtQXA.d.ts +0 -47
  1345. package/dist/function-contract-DxFNOmsm.d.ts +0 -27
  1346. package/dist/function-contract-pEmsaUIf.js +0 -8
  1347. package/dist/gateway-Ve7cByEr.d.ts +0 -115
  1348. package/dist/gateway-options-BlVCqgb8.d.ts +0 -29
  1349. package/dist/gateway-options-Cl74B7k6.js +0 -27
  1350. package/dist/guards-6F2bCtQR.js +0 -12
  1351. package/dist/guest-actions-1T1DeS5Y.d.ts +0 -5
  1352. package/dist/guest-actions-B7zdhfnh.js +0 -9
  1353. package/dist/history-GH1HJWQV.js +0 -271
  1354. package/dist/hmac-B3CTTlfv.js +0 -23
  1355. package/dist/http-7-UvHjQe.js +0 -28
  1356. package/dist/http-BjjojWg3.js +0 -40
  1357. package/dist/http-DzbloBR-.js +0 -141
  1358. package/dist/image-url-_d7xYsXK.js +0 -84
  1359. package/dist/impersonation-DM3oWNoD.js +0 -62
  1360. package/dist/impersonation-YTa9dZUv.d.ts +0 -28
  1361. package/dist/inbox-c8B86Trp.d.ts +0 -321
  1362. package/dist/index-B4wttiLh.d.ts +0 -407
  1363. package/dist/index-Clyd2Goi.d.ts +0 -338
  1364. package/dist/index-Cxsnd-OL.d.ts +0 -305
  1365. package/dist/index-D98bQs8a.d.ts +0 -665
  1366. package/dist/index-DIdPoQtO.d.ts +0 -240
  1367. package/dist/index-DbyDZZlc.d.ts +0 -53
  1368. package/dist/index-I8YLxKq8.d.ts +0 -729
  1369. package/dist/index-NRMMhhEi.d.ts +0 -104
  1370. package/dist/index-X2fkPUwb.d.ts +0 -51
  1371. package/dist/index-eRBuKtMt.d.ts +0 -158
  1372. package/dist/index-pZn6S_iq.d.ts +0 -149
  1373. package/dist/index-uIU65iEn.d.ts +0 -588
  1374. package/dist/instance-property-hRh88y_s.js +0 -7
  1375. package/dist/instances-DY_ORk5g.js +0 -16605
  1376. package/dist/invalidate-DMp4eqfF.d.ts +0 -21
  1377. package/dist/iso4217-B-durg_y.js +0 -176
  1378. package/dist/json-DaByVJpw.js +0 -22
  1379. package/dist/json-schema-DHJxiizN.js +0 -888
  1380. package/dist/jwks-cache-DEsKI0hJ.js +0 -49
  1381. package/dist/jws-D0toeQlA.d.ts +0 -66
  1382. package/dist/jws-DOgHJKHb.js +0 -205
  1383. package/dist/kit-B8yWCRN7.d.ts +0 -94
  1384. package/dist/kit-Bcd9wYCV.js +0 -133
  1385. package/dist/knowledge-CsLPACGJ.d.ts +0 -217
  1386. package/dist/knowledge-tCrrU99q.js +0 -300
  1387. package/dist/list-query-BcU8NnNL.d.ts +0 -222
  1388. package/dist/list-query-BnpA2BDg.js +0 -559
  1389. package/dist/live-C21DgbsD.js +0 -275
  1390. package/dist/logger-DWVYUmwi.d.ts +0 -18
  1391. package/dist/logger-glM28NVN.js +0 -21
  1392. package/dist/lookup-BaP5bI27.js +0 -18
  1393. package/dist/management-wtecfrNf.d.ts +0 -57
  1394. package/dist/message-Bg4TKA12.d.ts +0 -99
  1395. package/dist/messages-ecPW_nOv.js +0 -492
  1396. package/dist/messaging-DQP09JsY.d.ts +0 -297
  1397. package/dist/methods-Cund9ZBe.js +0 -11
  1398. package/dist/metric-definition-BjxVn4R5.js +0 -117
  1399. package/dist/metric-definition-EAYI1r2n.d.ts +0 -69
  1400. package/dist/mfa-oIOYTpvc.d.ts +0 -36
  1401. package/dist/model-hwpvole9.d.ts +0 -340
  1402. package/dist/model-messages-CkZSDDHP.js +0 -206
  1403. package/dist/model-messages-DrR4lZ_c.d.ts +0 -34
  1404. package/dist/money-BNRdJQzA.d.ts +0 -91
  1405. package/dist/money-BZl985O-.js +0 -197
  1406. package/dist/money-codec-BJuS2zEW.js +0 -41
  1407. package/dist/my-work-kinds-BU3SlA-6.js +0 -11
  1408. package/dist/node-headers-BPtMP4_V.d.ts +0 -27
  1409. package/dist/node-headers-C71zNQHe.js +0 -55
  1410. package/dist/operations-DVHRHvv6.js +0 -29
  1411. package/dist/operations-hm1Isvvs.d.ts +0 -6
  1412. package/dist/optional-peer-C1NbBRJm.js +0 -32
  1413. package/dist/options-3OYOU56e.js +0 -11
  1414. package/dist/options-56zYYXxc.js +0 -10
  1415. package/dist/options-5WvWOkAm.d.ts +0 -26
  1416. package/dist/options-62woPFn3.js +0 -12
  1417. package/dist/options-7ixoOoap.js +0 -10
  1418. package/dist/options-9dSU5RML.js +0 -5
  1419. package/dist/options-B0YZtAkb.d.ts +0 -15
  1420. package/dist/options-B2Kz_tCx.js +0 -10
  1421. package/dist/options-B5E2MGIz.js +0 -15
  1422. package/dist/options-B685YSzQ.js +0 -5
  1423. package/dist/options-B692WoK6.js +0 -9
  1424. package/dist/options-BHU1wc74.js +0 -5
  1425. package/dist/options-BHy0Z5Zd.js +0 -5
  1426. package/dist/options-BJtdsK7b.js +0 -8
  1427. package/dist/options-BKDxrPvE.js +0 -5
  1428. package/dist/options-BLfymS4s.js +0 -5
  1429. package/dist/options-BOCRbzh3.js +0 -5
  1430. package/dist/options-BOqfYsM1.js +0 -13
  1431. package/dist/options-BQWJqwHO.js +0 -9
  1432. package/dist/options-BQunK6_Y.js +0 -8
  1433. package/dist/options-BQyrZjwM.js +0 -28
  1434. package/dist/options-BR9xTHZW.js +0 -5
  1435. package/dist/options-BRUdd5jY.js +0 -8
  1436. package/dist/options-BSsYXjhC.js +0 -9
  1437. package/dist/options-BTmaRzx2.d.ts +0 -60
  1438. package/dist/options-BUCQYAeJ.d.ts +0 -10
  1439. package/dist/options-B_NrjVDt.d.ts +0 -12
  1440. package/dist/options-BawzwlmC.js +0 -11
  1441. package/dist/options-BbLDAp7G.d.ts +0 -10
  1442. package/dist/options-BfPsL7E2.js +0 -9
  1443. package/dist/options-Bfmwwc78.js +0 -8
  1444. package/dist/options-BhsdveDk.js +0 -21
  1445. package/dist/options-BomoTH-8.js +0 -5
  1446. package/dist/options-BtjkzIVh.js +0 -8
  1447. package/dist/options-Bvi9bl4H.js +0 -5
  1448. package/dist/options-BwKNmaJo.js +0 -5
  1449. package/dist/options-BxpLtyk-.js +0 -18
  1450. package/dist/options-BzB2QxL3.js +0 -5
  1451. package/dist/options-C078wBP0.js +0 -5
  1452. package/dist/options-C3AdsFJ6.js +0 -9
  1453. package/dist/options-C7C5OhmL.d.ts +0 -8
  1454. package/dist/options-C87u6eSa.js +0 -10
  1455. package/dist/options-CBAEGxwS.js +0 -8
  1456. package/dist/options-CDSCkYxu.d.ts +0 -14
  1457. package/dist/options-CDUr8zzX.js +0 -8
  1458. package/dist/options-CF6EVF_G.js +0 -17
  1459. package/dist/options-CFjGxfa8.js +0 -5
  1460. package/dist/options-CI6P0xhV.js +0 -10
  1461. package/dist/options-CJFMK9A_.js +0 -8
  1462. package/dist/options-CLpgx7en.js +0 -10
  1463. package/dist/options-CSCXNYJO.d.ts +0 -8
  1464. package/dist/options-CTXHj9zr.js +0 -16
  1465. package/dist/options-CTl8T88w.js +0 -11
  1466. package/dist/options-CUIOOv4z.js +0 -15
  1467. package/dist/options-CZDmtsbV.js +0 -8
  1468. package/dist/options-CZTscdPB.js +0 -5
  1469. package/dist/options-CZdKndeo.js +0 -9
  1470. package/dist/options-C_7g9TTq.d.ts +0 -12
  1471. package/dist/options-Cb2FOFj5.js +0 -5
  1472. package/dist/options-CbOstLa7.js +0 -5
  1473. package/dist/options-CcXgWlvm.js +0 -24
  1474. package/dist/options-CfVPctAw.js +0 -89
  1475. package/dist/options-Cjgaf8ub.js +0 -8
  1476. package/dist/options-CoSPgWKy.js +0 -9
  1477. package/dist/options-CpZ2HlSU.js +0 -32
  1478. package/dist/options-CsSe8Nba.js +0 -8
  1479. package/dist/options-CsvJR-r2.js +0 -9
  1480. package/dist/options-Cucv6sWP.js +0 -12
  1481. package/dist/options-CyjL9lTf.js +0 -5
  1482. package/dist/options-D-OOO9V2.d.ts +0 -10
  1483. package/dist/options-D0Y6ZMe8.js +0 -5
  1484. package/dist/options-D0bzZx9a.d.ts +0 -10
  1485. package/dist/options-D0sj5abR.js +0 -9
  1486. package/dist/options-D1hSuf50.d.ts +0 -12
  1487. package/dist/options-D610Fa6T.js +0 -5
  1488. package/dist/options-D96dScev.js +0 -24
  1489. package/dist/options-DFpyP1bg.js +0 -5
  1490. package/dist/options-DJEcS4DX.js +0 -5
  1491. package/dist/options-DJbN3bi9.js +0 -11
  1492. package/dist/options-DKoQoRCy.js +0 -13
  1493. package/dist/options-DM1qaMMQ.js +0 -9
  1494. package/dist/options-DNgSwhsm.js +0 -11
  1495. package/dist/options-DOIwzRXL.js +0 -16
  1496. package/dist/options-DRIgHh4O.d.ts +0 -16
  1497. package/dist/options-DRrZmJyI.js +0 -8
  1498. package/dist/options-DSCW40_5.js +0 -12
  1499. package/dist/options-DUMUsvml.js +0 -5
  1500. package/dist/options-DWwL5Kaz.js +0 -9
  1501. package/dist/options-DZHZYlpD.js +0 -10
  1502. package/dist/options-DZLkeqWn.js +0 -9
  1503. package/dist/options-DZRpXKQE.js +0 -5
  1504. package/dist/options-DZen3UiC.js +0 -14
  1505. package/dist/options-D_9Vxx7f.js +0 -8
  1506. package/dist/options-DcHl59RC.js +0 -11
  1507. package/dist/options-Dcaql09y.js +0 -11
  1508. package/dist/options-DcnBNYmV.js +0 -8
  1509. package/dist/options-DdpM-fiP.js +0 -9
  1510. package/dist/options-DhoLMknl.js +0 -10
  1511. package/dist/options-DlohRAYd.d.ts +0 -13
  1512. package/dist/options-Dpy-Ruo-.js +0 -14
  1513. package/dist/options-DsVuVRH3.d.ts +0 -17
  1514. package/dist/options-DtAJxfHS.js +0 -8
  1515. package/dist/options-Dz9Yo52Z.js +0 -8
  1516. package/dist/options-HnfETSHr.d.ts +0 -19
  1517. package/dist/options-LqUXTpML.js +0 -8
  1518. package/dist/options-MsloEAIB.js +0 -5
  1519. package/dist/options-P2FxqYpd.js +0 -17
  1520. package/dist/options-_1gAIMq7.d.ts +0 -60
  1521. package/dist/options-aT89JqlB.js +0 -5
  1522. package/dist/options-cVKZu9b0.js +0 -9
  1523. package/dist/options-eTepQ1rZ.js +0 -15
  1524. package/dist/options-fkShrmGQ.js +0 -8
  1525. package/dist/options-gUvfr3no.js +0 -11
  1526. package/dist/options-hynwKWuf.js +0 -20
  1527. package/dist/options-jsOCvLUz.js +0 -10
  1528. package/dist/options-o5wCw8H7.d.ts +0 -14
  1529. package/dist/options-p49DFg3H.js +0 -8
  1530. package/dist/options-pYNpXKcg.js +0 -8
  1531. package/dist/options-qtETCHzW.js +0 -10
  1532. package/dist/options-rnKlqYEr.js +0 -5
  1533. package/dist/options-sU_zGkiV.js +0 -10
  1534. package/dist/options-xq4MXG1M.js +0 -5
  1535. package/dist/options-zzlznRA7.js +0 -10
  1536. package/dist/outbox-BZ712Z3X.d.ts +0 -199
  1537. package/dist/payments-BXvabJOw.js +0 -16
  1538. package/dist/payments-BYcN34Fp.d.ts +0 -114
  1539. package/dist/permissions-controller-BMsqIE5T.js +0 -34
  1540. package/dist/pg-error-B5QLDcbG.js +0 -26
  1541. package/dist/plugin-AKwwe2gF.js +0 -48
  1542. package/dist/pool-DDR1ndk7.d.ts +0 -123
  1543. package/dist/pool-errors-JUBcGrre.js +0 -27
  1544. package/dist/ports-DOrPTJzl.d.ts +0 -89
  1545. package/dist/ports-DvpNseap.js +0 -152
  1546. package/dist/postgrest-AJc8hnJU.d.ts +0 -53
  1547. package/dist/postgrest-executor-B_Uezhrm.js +0 -1068
  1548. package/dist/preset-CXhpPmPV.js +0 -1042
  1549. package/dist/problem-Bf0cJ7tk.js +0 -162
  1550. package/dist/problem-DNwN8iGz.d.ts +0 -79
  1551. package/dist/project-DJ9Uo0sT.js +0 -1760
  1552. package/dist/provider-B6g7rBZX.js +0 -57
  1553. package/dist/provider-CWjzAIX9.d.ts +0 -112
  1554. package/dist/push-token-B4vcIU4s.d.ts +0 -24
  1555. package/dist/push-token-D6REHMMw.js +0 -16
  1556. package/dist/queries-BWYYS9um.js +0 -239
  1557. package/dist/range-DwpWe8e7.js +0 -7
  1558. package/dist/range-p5V4rBhZ.d.ts +0 -8
  1559. package/dist/rank-keys-DcPMt_Jk.js +0 -60
  1560. package/dist/rank-result-BBJIK-k_.js +0 -18
  1561. package/dist/rank-result-Bwe7igy-.d.ts +0 -14
  1562. package/dist/rate-limit-BWKGlhTM.js +0 -49
  1563. package/dist/rate-limit-Bztf32cl.d.ts +0 -50
  1564. package/dist/rate-limit-fZ_d8gSE.js +0 -380
  1565. package/dist/ratelimit-headers-kEcXyO3H.js +0 -62
  1566. package/dist/react-BKCnIuZs.js +0 -79
  1567. package/dist/react-mdVjpewL.js +0 -1016
  1568. package/dist/read-set-B1sDib5O.js +0 -199
  1569. package/dist/realtime-status-BhNkb-Ow.d.ts +0 -8
  1570. package/dist/realtime-status-asHvhiOh.js +0 -11
  1571. package/dist/record-bindings-Z51mGfhB.js +0 -26
  1572. package/dist/record-form-CubgBrtI.d.ts +0 -82
  1573. package/dist/record-type-BEUyEsFx.js +0 -221
  1574. package/dist/recordings-DeZYx-Kv.d.ts +0 -119
  1575. package/dist/refresh-D02Pbf5B.d.ts +0 -54
  1576. package/dist/refresh-DLBgnxjL.js +0 -144
  1577. package/dist/refusal-B0VmlAxF.d.ts +0 -32
  1578. package/dist/refusal-DDlInPff.js +0 -64
  1579. package/dist/relay-CIKcAVjf.js +0 -248
  1580. package/dist/resolve-B0mW2m7f.js +0 -932
  1581. package/dist/resolve-CtX6T0c0.d.ts +0 -288
  1582. package/dist/resolved-names-kMRjmSIy.js +0 -133
  1583. package/dist/resource-BUJcZKiW.js +0 -520
  1584. package/dist/resource-DvgXqZB_.js +0 -105
  1585. package/dist/resource-WxN0IsvB.d.ts +0 -123
  1586. package/dist/resource-execute-BzqR8DdD.d.ts +0 -15
  1587. package/dist/resource-schemas-up6bKOUi.js +0 -82
  1588. package/dist/resource-types-BVbHgTPg.d.ts +0 -157
  1589. package/dist/resources-BSbRa0Ab.d.ts +0 -7
  1590. package/dist/resources-jb3R6rEa.js +0 -64
  1591. package/dist/respond-CZMWbUs3.js +0 -107
  1592. package/dist/respond-Dzu_-EPH.d.ts +0 -112
  1593. package/dist/result-DZeA5KS6.d.ts +0 -351
  1594. package/dist/result-ntFBW2p2.js +0 -146
  1595. package/dist/rows-BdqXmiB-.js +0 -80
  1596. package/dist/rows-jijHLVE_.js +0 -39
  1597. package/dist/rrule-C9Ot6ax8.js +0 -290
  1598. package/dist/run-state-BMCD_1Lt.d.ts +0 -13
  1599. package/dist/run-state-CgBKzYMW.js +0 -13
  1600. package/dist/run-watch-B-LoK5m1.js +0 -53
  1601. package/dist/runtime-LRJM7UqY.js +0 -44
  1602. package/dist/sales-lines-BsmrNHe9.d.ts +0 -38
  1603. package/dist/sales-lines-DO7oRu1o.js +0 -45
  1604. package/dist/sales-shared-BuTA8JK7.js +0 -22
  1605. package/dist/schemas-CLOTvdsC.js +0 -216
  1606. package/dist/scope-DgWjuXUw.js +0 -90
  1607. package/dist/scores-Y8TvyJi1.d.ts +0 -174
  1608. package/dist/scores-bY2Is0kx.js +0 -177
  1609. package/dist/search-Cn_DGluL.js +0 -9
  1610. package/dist/server-types-BkTIxW_H.d.ts +0 -597
  1611. package/dist/session-BOzx2qHC.d.ts +0 -100
  1612. package/dist/session-status-BP8eYVnA.d.ts +0 -82
  1613. package/dist/shared-BeHTi8Fu.js +0 -17
  1614. package/dist/shared-Bf-I13Ht.js +0 -91
  1615. package/dist/shared-CRRfQAKG.d.ts +0 -11
  1616. package/dist/sign-in-BzihC_8k.d.ts +0 -50
  1617. package/dist/sign-in-CmPK1AgM.js +0 -402
  1618. package/dist/sign-in-CuZ1Ag7O.js +0 -718
  1619. package/dist/sign-in-D54FLMQy.d.ts +0 -55
  1620. package/dist/signatures-CX1b4WHa.js +0 -145
  1621. package/dist/signatures-Dkx9OE8j.d.ts +0 -43
  1622. package/dist/signers-ZmxO1I05.d.ts +0 -390
  1623. package/dist/signing-keys-CWtpMask.js +0 -164
  1624. package/dist/signing-keys-udgP7Aod.d.ts +0 -119
  1625. package/dist/simplify-DDO0j0LI.js +0 -83
  1626. package/dist/spec-BMvCCNnd.js +0 -124
  1627. package/dist/spec-pins-BZkKfwY8.d.ts +0 -127
  1628. package/dist/spec-pins-D3zDek-u.js +0 -62
  1629. package/dist/sql-CYt7EhH0.js +0 -421
  1630. package/dist/sql-DHp0L7zK.js +0 -138385
  1631. package/dist/sql-type-iUSZpaUu.js +0 -34
  1632. package/dist/sso-CkU_4mtK.d.ts +0 -161
  1633. package/dist/sso-DdDpJQzw.js +0 -217
  1634. package/dist/standard-BA3mLh6w.js +0 -25
  1635. package/dist/standard-DBV730sF.d.ts +0 -7
  1636. package/dist/stats-BHl1-zj9.js +0 -83
  1637. package/dist/statuses-Alll5Ip6.js +0 -29
  1638. package/dist/statuses-zRcc2TeZ.js +0 -28
  1639. package/dist/storage-api-Dg78Wqsg.js +0 -10
  1640. package/dist/store-CpheI-lN.d.ts +0 -83
  1641. package/dist/store-McN-2esd.js +0 -69
  1642. package/dist/stripe-BJUfp5jM.js +0 -32
  1643. package/dist/stripe-X22LjuH-.d.ts +0 -156
  1644. package/dist/subject-readers-CB5Te02u.d.ts +0 -21
  1645. package/dist/subject-readers-VHcrWhmq.js +0 -49
  1646. package/dist/subject-type-BRnK7Av3.js +0 -8
  1647. package/dist/subjects-BYCL-6hA.d.ts +0 -145
  1648. package/dist/subjects-CiBNKy2y.d.ts +0 -90
  1649. package/dist/subscribers-BvZxcd63.js +0 -33
  1650. package/dist/summaries-8jQTELIX.d.ts +0 -69
  1651. package/dist/supabase-mcp-Dz9DgrKP.js +0 -28
  1652. package/dist/supabase-mcp-Z4vtsuoO.d.ts +0 -46
  1653. package/dist/support-BxyPOFk4.d.ts +0 -357
  1654. package/dist/support-view-g4YLBeqX.js +0 -18
  1655. package/dist/support-view-nqUWKHEs.d.ts +0 -17
  1656. package/dist/table-schema-BlF6k62Q.d.ts +0 -81
  1657. package/dist/table-schema-C80xItaV.js +0 -293
  1658. package/dist/tables-Cb-3_VWc.js +0 -73
  1659. package/dist/tags-CIZTqtlY.js +0 -39
  1660. package/dist/tags-Cm48BsOa.d.ts +0 -30
  1661. package/dist/tax-BkCNWWMc.js +0 -140
  1662. package/dist/tax-DPShHual.d.ts +0 -170
  1663. package/dist/tee-V97_v1ZS.js +0 -101
  1664. package/dist/template-Drgg3v2J.js +0 -126
  1665. package/dist/temporal-Dbo0fLzc.js +0 -95
  1666. package/dist/temporal-required-DcLhnDhQ.js +0 -20
  1667. package/dist/tenant-BgIiMQpo.js +0 -27
  1668. package/dist/tenant-FfgNhd5x.d.ts +0 -17
  1669. package/dist/tenant-source-bqWpSr86.js +0 -8
  1670. package/dist/timeline-DqEoD8bb.d.ts +0 -151
  1671. package/dist/timeline-Dz3hO2I6.js +0 -50
  1672. package/dist/timing-dypS0nxW.js +0 -95
  1673. package/dist/topic-BaUElNw2.d.ts +0 -415
  1674. package/dist/topic-DnsNG4Kj.js +0 -643
  1675. package/dist/ttl-cache-Bhr9swjT.js +0 -32
  1676. package/dist/types-B-D6fYx2.d.ts +0 -194
  1677. package/dist/types-CK2X2wCB.d.ts +0 -618
  1678. package/dist/types-CMN0h_Ix.d.ts +0 -461
  1679. package/dist/types-CPl9uJ0G.d.ts +0 -912
  1680. package/dist/types-CwQgFo8c.d.ts +0 -177
  1681. package/dist/types-DMihLukJ.d.ts +0 -251
  1682. package/dist/types-R6syp1el.js +0 -29
  1683. package/dist/types-iCyZ3lMx.d.ts +0 -217
  1684. package/dist/types-nspa5I-a.d.ts +0 -664
  1685. package/dist/undo-0HkWXASn.d.ts +0 -46
  1686. package/dist/undo-BbftL9-4.js +0 -44
  1687. package/dist/upload-claim-B1ZU8ydB.js +0 -33
  1688. package/dist/usage-BkWAPkg2.d.ts +0 -232
  1689. package/dist/user-change-DgWC6RRC.js +0 -135
  1690. package/dist/variants-Cy--Ub-a.js +0 -53
  1691. package/dist/vault-BkdPmL7f.d.ts +0 -62
  1692. package/dist/verify-41mZmspj.d.ts +0 -146
  1693. package/dist/verify-7EucfCnv.js +0 -130
  1694. package/dist/view-C8Ve14ja.js +0 -247
  1695. package/dist/view-C8_xvD-j.d.ts +0 -97
  1696. package/dist/watch-topic-BabDTZ-L.d.ts +0 -31
  1697. package/dist/watch-topic-CuaWfCuv.js +0 -57
  1698. package/dist/wire-ChYn1g21.js +0 -91
  1699. package/dist/wiring-CDNuQoJJ.js +0 -13
  1700. package/dist/workflow-sdk-Cf0LAOFF.js +0 -242
  1701. package/dist/workflow-sdk-DJJkP0dT.js +0 -2545
  1702. package/dist/workflow-sdk-rg3IbCZC.d.ts +0 -163
  1703. package/dist/workflows-xL6t0TXx.d.ts +0 -258
@@ -0,0 +1,2260 @@
1
+ import { c as mapDbError, n as dbError, o as isDbError, r as dbErrorOf } from "./errors-B7tCfCvX.js";
2
+ import { n as isRecord } from "./guards-CsRa6v57.js";
3
+ import { t as temporal } from "./temporal-required-w_2u4EDp.js";
4
+ import { a as ok, r as err, s as toDbError, t as AsyncResult } from "./result-8xza7w5W.js";
5
+ import { n as postgrestExecutor } from "./postgrest-executor-lf8Mt4J0.js";
6
+ import { n as StatsRecorder } from "./stats-BTJgRMEp.js";
7
+ import { o as problemResponse } from "./problem-C0SVHhd3.js";
8
+ import { i as forwardBlockEvents, t as DEFAULT_TYPE_PREFIX } from "./cloud-event-CLvsaPqH.js";
9
+ import { loadEnv } from "./env/index.js";
10
+ import { i as userContext, t as actClaim } from "./impersonation-D-quM36V.js";
11
+ import { t as fromPgError } from "./pg-error-D92B6jlF.js";
12
+ import { a as narrowCap, i as delegatedClaims, r as contextClaims } from "./delegation-C2rLpkHO.js";
13
+ import { o as sessionMemo, s as snapshotOf, t as authOfSnapshot } from "./snapshot-CVMSyTHH.js";
14
+ import { c as primaryCookieWrite, d as withPrimaryPin, l as replicaState, n as refreshFor, r as shouldCheckSession, s as pinnedUntil, u as routedExecutor } from "./refresh-B8t_KE3s.js";
15
+ import { t as authContext } from "./context-DSevnLrT.js";
16
+ import { c as AUTH_CACHE_HEADERS, d as clearSessionAtScopes, f as parseCookies, g as sessionCookieName, h as serializeCookie, i as resolveAuth, n as prefetchJwks, r as requestToken } from "./resolve-FW8oeXvh.js";
17
+ import { s as requestMemo, t as bindAuthorizer } from "./authorizer-BtIPDO-c.js";
18
+ import { t as credentialProviderOf } from "./provider-B6qpleR9.js";
19
+ import { i as guard, n as defaultExpose, o as respond, r as defaultPrefetchJwks, t as assertCookieRefresh } from "./respond-DLH4tD2d.js";
20
+ import { createClient } from "@supabase/supabase-js";
21
+ import { defineMiddleware, getEnv, pipeline, seedContext } from "@supabase/middleware";
22
+ import { PostgrestClient } from "@supabase/postgrest-js";
23
+ // src/server/delete-account.ts
24
+ const REMOVE_BATCH = 1e3;
25
+ /** Maps an `AuthApiError` from `auth.admin.deleteUser` to a `DbError`. */
26
+ function fromAuthError(raw) {
27
+ if (isDbError(raw)) return raw;
28
+ const failure = typeof raw === "object" && raw !== null ? raw : {};
29
+ const message = failure.message ?? "Auth request failed";
30
+ const base = {
31
+ table: "auth.users",
32
+ ...failure.code ? { code: failure.code } : {}
33
+ };
34
+ if (failure.code === "user_not_found" || failure.status === 404) return dbError("not_found", message, base);
35
+ if (/database error deleting user/i.test(message)) return dbError("conflict", message, {
36
+ ...base,
37
+ hint: "A foreign key to auth.users without on delete cascade or set null blocks the delete (doctor BS406)"
38
+ });
39
+ if (failure.status === 401) return dbError("unauthorized", message, base);
40
+ if (failure.status === 403) return dbError("forbidden", message, base);
41
+ return failure.name === "AuthRetryableFetchError" || (failure.status ?? 0) >= 500 ? dbError("network", message, base) : dbError("unexpected", message, base);
42
+ }
43
+ const UUID$2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
44
+ const PROBE = "better_supabase.delete_account_probe";
45
+ /**
46
+ * The database error that refuses deleting `userId`, from the delete and its
47
+ * deferred checks run in a `do` block that always fails, so nothing is deleted.
48
+ * Undefined when the delete itself would pass.
49
+ */
50
+ async function databaseRefusal(sql, userId) {
51
+ if (!UUID$2.test(userId)) return;
52
+ try {
53
+ await sql.queryRaw(`do $$
54
+ begin
55
+ delete from auth.users where id = '${userId}';
56
+ set constraints all immediate;
57
+ raise exception '${PROBE}';
58
+ end;
59
+ $$`);
60
+ } catch (cause) {
61
+ const raw = isDbError(cause) ? void 0 : fromPgError(cause);
62
+ const error = isDbError(cause) ? cause : raw && mapDbError(raw);
63
+ if (!error || error.message === PROBE) return;
64
+ return {
65
+ ...error,
66
+ table: "auth.users"
67
+ };
68
+ }
69
+ }
70
+ /**
71
+ * Deletes the Auth user, then removes their Storage objects, then announces the
72
+ * delete. Rows referencing `auth.users` follow their foreign keys. The objects
73
+ * are listed first and removed only once the user is gone, so a delete the
74
+ * database refuses leaves them in place.
75
+ *
76
+ * `server.deleteAccount` calls it with the server's service client. Apps on the
77
+ * `@supabase/server` pipeline call it with theirs:
78
+ * `deleteAccount(betterSupabase, ctx.supabaseAdmin, userId)`.
79
+ */
80
+ function deleteAccount(betterSupabase, service, userId, options = {}) {
81
+ return AsyncResult.from(async () => {
82
+ const client = typeof service === "function" ? service() : service;
83
+ const listedPaths = [];
84
+ for (const bucket of options.buckets ?? []) {
85
+ const param = bucket.owner;
86
+ if (!param) continue;
87
+ options.signal?.throwIfAborted();
88
+ const listed = await bucket.connect(client, { allTenants: true }).list({ [param]: userId }, options.signal ? { signal: options.signal } : {});
89
+ if (!listed.ok) return listed;
90
+ listedPaths.push([bucket, listed.data.map((object) => object.path).filter((path) => {
91
+ return bucket.match(path)?.[param] === userId;
92
+ })]);
93
+ }
94
+ options.signal?.throwIfAborted();
95
+ let alreadyGone = false;
96
+ try {
97
+ const { error } = await client.auth.admin.deleteUser(userId);
98
+ const failure = error ? fromAuthError(error) : void 0;
99
+ if (failure?.kind === "not_found") alreadyGone = true;
100
+ else if (failure) {
101
+ const refusal = options.sql && (failure.kind === "conflict" || failure.kind === "network" || failure.kind === "unexpected") ? await databaseRefusal(options.sql, userId) : void 0;
102
+ return err(refusal ?? failure);
103
+ }
104
+ } catch (cause) {
105
+ return err(fromAuthError(cause));
106
+ }
107
+ const removed = {};
108
+ for (const [bucket, paths] of listedPaths) {
109
+ const storage = bucket.connect(client, { allTenants: true });
110
+ for (let start = 0; start < paths.length; start += REMOVE_BATCH) {
111
+ const batch = await storage.remove(paths.slice(start, start + REMOVE_BATCH));
112
+ if (!batch.ok) return batch;
113
+ }
114
+ removed[bucket.id] = paths.length;
115
+ }
116
+ if (alreadyGone) return ok({
117
+ userId,
118
+ removed
119
+ });
120
+ const context = options.context ?? {};
121
+ betterSupabase.events.emit("mutation", {
122
+ table: "auth.users",
123
+ kind: "delete",
124
+ rows: [{ id: userId }],
125
+ context
126
+ });
127
+ for (const table of options.cascades ?? []) betterSupabase.events.emit("mutation", {
128
+ table,
129
+ kind: "delete",
130
+ rows: [],
131
+ context
132
+ });
133
+ return ok({
134
+ userId,
135
+ removed
136
+ });
137
+ });
138
+ }
139
+ // src/server/suspend-account.ts
140
+ const UUID$1 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
141
+ const FOREVER = "876000h";
142
+ const END_SESSIONS = `with ended as (
143
+ delete from auth.sessions where user_id = $1::uuid returning id
144
+ ), tokens as (
145
+ delete from auth.refresh_tokens where user_id = $1::text
146
+ )
147
+ select count(*)::int as ended from ended`;
148
+ function invalidUser(userId) {
149
+ return dbError("invalid_request", `"${userId}" is not a user id`, { table: "auth.users" });
150
+ }
151
+ function fromSqlError(cause) {
152
+ const known = dbErrorOf(cause);
153
+ if (known) return known;
154
+ const raw = fromPgError(cause);
155
+ if (raw) return {
156
+ ...mapDbError(raw),
157
+ table: "auth.sessions"
158
+ };
159
+ return dbError("unexpected", cause instanceof Error ? cause.message : "Ending the sessions failed", { table: "auth.sessions" });
160
+ }
161
+ async function deleteSessions(sql, userId) {
162
+ const [row] = await sql.queryRaw(END_SESSIONS, [userId]);
163
+ return row?.ended ?? 0;
164
+ }
165
+ function endSessions(sql, userId) {
166
+ return AsyncResult.from(async () => {
167
+ if (!UUID$1.test(userId)) return err(invalidUser(userId));
168
+ try {
169
+ return ok({
170
+ userId,
171
+ ended: await deleteSessions(sql, userId)
172
+ });
173
+ } catch (cause) {
174
+ return err(fromSqlError(cause));
175
+ }
176
+ });
177
+ }
178
+ const LAST_SIGN_INS = `select user_id, last_sign_in_at
179
+ from better_supabase.last_sign_ins($1::uuid[])`;
180
+ /**
181
+ * The last sign-in of each user, in one query (`better_supabase.last_sign_ins`
182
+ * from the `sessions` module, which only the service role may call). Users that
183
+ * don't exist are missing from the map.
184
+ */
185
+ function lastSignIns(sql, userIds) {
186
+ return AsyncResult.from(async () => {
187
+ const invalid = userIds.find((userId) => !UUID$1.test(userId));
188
+ if (invalid !== void 0) return err(invalidUser(invalid));
189
+ if (userIds.length === 0) return ok(/* @__PURE__ */ new Map());
190
+ try {
191
+ const rows = await sql.queryRaw(LAST_SIGN_INS, [[...new Set(userIds)]]);
192
+ return ok(new Map(rows.map((row) => [row.user_id, {
193
+ userId: row.user_id,
194
+ lastSignInAt: row.last_sign_in_at === null ? null : temporal().Instant.from(row.last_sign_in_at instanceof Date ? row.last_sign_in_at.toISOString() : row.last_sign_in_at)
195
+ }])));
196
+ } catch (cause) {
197
+ return err(fromSqlError(cause));
198
+ }
199
+ });
200
+ }
201
+ async function ban(client, userId, duration) {
202
+ try {
203
+ const { error } = await client.auth.admin.updateUserById(userId, { ban_duration: duration });
204
+ return error ? fromAuthError(error) : void 0;
205
+ } catch (cause) {
206
+ return fromAuthError(cause);
207
+ }
208
+ }
209
+ function suspendAccount(service, sql, userId, options) {
210
+ return AsyncResult.from(async () => {
211
+ if (!UUID$1.test(userId)) return err(invalidUser(userId));
212
+ const client = typeof service === "function" ? service() : service;
213
+ const { suspended } = options;
214
+ if (suspended) {
215
+ const refused = await ban(client, userId, options.duration ?? FOREVER);
216
+ if (refused) return err(refused);
217
+ if (options.endSessions !== true) return ok({
218
+ userId,
219
+ suspended,
220
+ ended: 0
221
+ });
222
+ }
223
+ let ended;
224
+ try {
225
+ ended = await deleteSessions(sql, userId);
226
+ } catch (cause) {
227
+ return err(fromSqlError(cause));
228
+ }
229
+ if (!suspended) {
230
+ const refused = await ban(client, userId, "none");
231
+ if (refused) return err(refused);
232
+ }
233
+ return ok({
234
+ userId,
235
+ suspended,
236
+ ended
237
+ });
238
+ });
239
+ }
240
+ // src/server/audit.ts
241
+ /** The CloudEvents `source` of the events the server sends to its `audit` sink. */
242
+ const SERVER_EVENT_SOURCE = "/better-supabase/server";
243
+ const OFF = { account: () => void 0 };
244
+ /**
245
+ * The server's audit trail: account actions are sent to `sink` as CloudEvents
246
+ * typed `dev.better-supabase.account.*` with subject `users/<id>`, and
247
+ * `support.denied` block events are forwarded to it.
248
+ */
249
+ function serverAudit(betterSupabase, sink) {
250
+ if (sink === void 0) return OFF;
251
+ const { events } = betterSupabase;
252
+ forwardBlockEvents(betterSupabase, sink, {
253
+ source: SERVER_EVENT_SOURCE,
254
+ types: ["support.denied"]
255
+ });
256
+ const report = (cause) => {
257
+ events.logger.error("audit sink failed", { cause });
258
+ };
259
+ return { account(type, userId, data) {
260
+ const event = {
261
+ specversion: "1.0",
262
+ id: crypto.randomUUID(),
263
+ source: SERVER_EVENT_SOURCE,
264
+ type: `${DEFAULT_TYPE_PREFIX}.${type}`,
265
+ subject: `users/${userId}`,
266
+ time: (/* @__PURE__ */ new Date()).toISOString(),
267
+ datacontenttype: "application/json",
268
+ data: {
269
+ userId,
270
+ ...data
271
+ }
272
+ };
273
+ try {
274
+ events.track(Promise.resolve(sink.send([event])).catch(report));
275
+ } catch (cause) {
276
+ report(cause);
277
+ }
278
+ } };
279
+ }
280
+ // src/core/contracts/authorization-hooks.ts
281
+ /** Types `hooks` and freezes it; better-supabase never mutates a provider. */
282
+ function defineAuthorizationHooks(hooks) {
283
+ return Object.freeze(hooks);
284
+ }
285
+ /** The error for hooks built for another API version, or `undefined` for version 1. */
286
+ function hooksApiProblem(hooks) {
287
+ if (hooks.apiVersion === 1) return;
288
+ return `authorization hooks "${typeof hooks.name === "string" ? hooks.name : "provider"}" target API ${String(hooks.apiVersion)}; this better-supabase supports 1.`;
289
+ }
290
+ // src/server/clients.ts
291
+ const STATELESS = {
292
+ persistSession: false,
293
+ autoRefreshToken: false,
294
+ detectSessionInUrl: false
295
+ };
296
+ /**
297
+ * The Supabase and PostgREST clients of one server: shared service and anon
298
+ * clients, per-request user clients.
299
+ */
300
+ function createClients(input) {
301
+ const { options, env, definitionExecutor, lite, createClient } = input;
302
+ let adminClient;
303
+ let anonClient;
304
+ const secretKey = () => {
305
+ const key = env().secretKey;
306
+ if (!key) throw new TypeError("admin() needs SUPABASE_SECRET_KEY; it is not set");
307
+ return key;
308
+ };
309
+ const customFetch = options.fetch ? { fetch: options.fetch } : void 0;
310
+ const urlLengthLimit = options.db?.urlLengthLimit ?? definitionExecutor.urlLengthLimit;
311
+ const db = {
312
+ ...options.db?.timeout === void 0 ? {} : { timeout: options.db.timeout },
313
+ ...options.db?.retry === void 0 ? {} : { retry: options.db.retry },
314
+ ...urlLengthLimit === void 0 ? {} : { urlLengthLimit }
315
+ };
316
+ const dbOptions = Object.keys(db).length > 0 ? { db } : {};
317
+ const sharedGlobal = {
318
+ ...customFetch ? { global: customFetch } : {},
319
+ ...dbOptions
320
+ };
321
+ /**
322
+ * Postgrest-js options a bare `PostgrestClient` takes; `timeout` is the
323
+ * executor's.
324
+ */
325
+ const restOptions = {
326
+ ...db.retry === void 0 ? {} : { retry: db.retry },
327
+ ...urlLengthLimit === void 0 ? {} : { urlLengthLimit }
328
+ };
329
+ const rpcUnavailable = lite?.rpcUnavailable;
330
+ const executorOptions = {
331
+ ...definitionExecutor,
332
+ ...urlLengthLimit === void 0 ? {} : { urlLengthLimit },
333
+ ...db.timeout === void 0 ? {} : { timeout: db.timeout },
334
+ ...db.retry === void 0 ? {} : { retry: db.retry },
335
+ ...rpcUnavailable === void 0 ? {} : { rpcUnavailable }
336
+ };
337
+ /** Set when `db` options or the backend need an executor built with them. */
338
+ const tunedExecutor = options.db !== void 0 || rpcUnavailable !== void 0;
339
+ const serviceClient = () => {
340
+ adminClient ??= createClient(env().url, secretKey(), {
341
+ auth: STATELESS,
342
+ ...sharedGlobal
343
+ });
344
+ return adminClient;
345
+ };
346
+ const readUrl = () => options.readUrl === false ? void 0 : options.readUrl?.replace(/\/+$/, "") ?? env().readUrl;
347
+ const apiKeyClient = () => {
348
+ throw new TypeError("ctx.supabase and ctx.db.$client are not available for an API key: ctx.db and ctx.sql run over direct Postgres with the key's claims");
349
+ };
350
+ /** Clients for the primary share the service and anon clients; others don't. */
351
+ const supabaseAt = (url, auth, headers = {}) => {
352
+ const custom = Object.keys(headers).length > 0;
353
+ const global = custom ? {
354
+ global: {
355
+ headers,
356
+ ...customFetch
357
+ },
358
+ ...dbOptions
359
+ } : sharedGlobal;
360
+ const shared = !custom && url === env().url;
361
+ switch (auth.kind) {
362
+ case "user": return createClient(url, env().publishableKey, {
363
+ accessToken: () => Promise.resolve(auth.token),
364
+ ...global
365
+ });
366
+ case "secret": return shared ? serviceClient() : createClient(url, secretKey(), {
367
+ auth: STATELESS,
368
+ ...global
369
+ });
370
+ case "none":
371
+ case "invalid":
372
+ if (!shared) return createClient(url, env().publishableKey, {
373
+ auth: STATELESS,
374
+ ...global
375
+ });
376
+ anonClient ??= createClient(url, env().publishableKey, {
377
+ auth: STATELESS,
378
+ ...sharedGlobal
379
+ });
380
+ return anonClient;
381
+ case "apiKey": return apiKeyClient();
382
+ default: return auth;
383
+ }
384
+ };
385
+ const supabaseFor = (auth, headers = {}) => supabaseAt(env().url, auth, headers);
386
+ const restUrls = /* @__PURE__ */ new Map();
387
+ const restUrl = (url) => {
388
+ let rest = restUrls.get(url);
389
+ if (rest === void 0) {
390
+ rest = new URL("rest/v1", url.endsWith("/") ? url : `${url}/`).href;
391
+ restUrls.set(url, rest);
392
+ }
393
+ return rest;
394
+ };
395
+ /**
396
+ * The client queries run on. Requests need only PostgREST, so they skip
397
+ * building Realtime, Storage and Auth clients per request; the shared service
398
+ * and anon clients for the primary are built once anyway.
399
+ */
400
+ const restAt = (url, auth, headers = {}) => {
401
+ let key;
402
+ let bearer;
403
+ switch (auth.kind) {
404
+ case "user":
405
+ key = env().publishableKey;
406
+ bearer = auth.token;
407
+ break;
408
+ case "secret":
409
+ case "none":
410
+ case "invalid":
411
+ if (Object.keys(headers).length === 0 && url === env().url) return supabaseAt(url, auth, headers);
412
+ key = auth.kind === "secret" ? secretKey() : env().publishableKey;
413
+ bearer = key;
414
+ break;
415
+ case "apiKey": return apiKeyClient();
416
+ default: return auth;
417
+ }
418
+ return new PostgrestClient(restUrl(url), {
419
+ headers: {
420
+ ...headers,
421
+ apikey: key,
422
+ Authorization: `Bearer ${bearer}`
423
+ },
424
+ ...customFetch,
425
+ ...restOptions
426
+ });
427
+ };
428
+ return {
429
+ executorOptions,
430
+ tunedExecutor,
431
+ serviceClient,
432
+ readUrl,
433
+ apiKeyClient,
434
+ supabaseFor,
435
+ restAt
436
+ };
437
+ }
438
+ // src/server/entries/core.ts
439
+ const cores = /* @__PURE__ */ new WeakMap();
440
+ /** Records the core behind `server`, so `serverCore` finds it on copies too. */
441
+ function registerCore(server, core) {
442
+ cores.set(server, core);
443
+ }
444
+ /**
445
+ * Copies the registration from `from` to `to` (`extendServer` builds a new
446
+ * object).
447
+ */
448
+ function shareCore(from, to) {
449
+ const core = cores.get(from);
450
+ if (core) cores.set(to, core);
451
+ }
452
+ /** The core of a server built by `createServer` or one of the adapter factories. */
453
+ function serverCore(server) {
454
+ const core = cores.get(server);
455
+ if (!core) throw new TypeError("better-supabase: this server was not built by createServer(); pass the definition or a server from createServer");
456
+ return core;
457
+ }
458
+ const CALL = Symbol("better-supabase.call");
459
+ const supportLookups = /* @__PURE__ */ new WeakMap();
460
+ /**
461
+ * Starts the support lookup for a signed-in caller, so `withTenant` can run the
462
+ * tenant resolver while the support store answers. Other callers never have a
463
+ * support session, so they skip it.
464
+ */
465
+ function startSupportLookup(core, request, session) {
466
+ if (session.auth.kind !== "user" || supportLookups.has(session)) return;
467
+ const lookup = core.support(request, session.auth);
468
+ lookup.catch(() => void 0);
469
+ supportLookups.set(session, lookup);
470
+ }
471
+ /**
472
+ * The support session of a resolved request: the started lookup, else a new
473
+ * one.
474
+ */
475
+ function supportLookup(core, request, session) {
476
+ return supportLookups.get(session) ?? core.support(request, session.auth);
477
+ }
478
+ /** The call state on a context seeded by `server.context()`, if any. */
479
+ function callOf(ctx) {
480
+ return ctx[CALL];
481
+ }
482
+ // src/server/entries/context.ts
483
+ /**
484
+ * Entry contributing `ctx.bsb`, the request's `ServerContext`: `auth`, `db`,
485
+ * `sql`, `supabase`, `replica`, `stats()` and the rest, each built on first
486
+ * read. In a support session `auth`, `db` and `sql` are the target's.
487
+ */
488
+ function withServerContext(core) {
489
+ return defineMiddleware({
490
+ key: "bsb",
491
+ run: () => (request, ctx) => {
492
+ const options = callOf(ctx)?.options ?? {};
493
+ const bsb = core.context(ctx.session, request, ctx.support ? {
494
+ ...options,
495
+ support: ctx.support
496
+ } : options, ctx.tenant);
497
+ return Promise.resolve({ bsb });
498
+ }
499
+ })();
500
+ }
501
+ // src/server/entries/session.ts
502
+ function checkFor(policy, request) {
503
+ if (policy === void 0 || typeof policy === "boolean") return policy ?? false;
504
+ return policy === "navigation" ? shouldCheckSession(request) : policy(request);
505
+ }
506
+ /**
507
+ * Runs `hook` for a resolution with an outage and returns its response when the
508
+ * session couldn't be kept.
509
+ */
510
+ async function outageResponse(hook, resolution, request, logger) {
511
+ const outage = resolution.outage;
512
+ if (!hook || !outage) return;
513
+ try {
514
+ const response = await hook(outage, request);
515
+ return outage.kept || !(response instanceof Response) ? void 0 : response;
516
+ } catch (cause) {
517
+ logger.warn("onAuthOutage threw", { cause });
518
+ return;
519
+ }
520
+ }
521
+ /**
522
+ * Appends `Max-Age=0` writes for the session cookie at the old scopes, and the
523
+ * no-store headers.
524
+ */
525
+ function clearOldScopes(response, request, name, scopes) {
526
+ const writes = clearSessionAtScopes(parseCookies(request.headers.get("cookie")), name, scopes);
527
+ if (writes.length === 0) return response;
528
+ const headers = new Headers(response.headers);
529
+ for (const write of writes) headers.append("set-cookie", serializeCookie(write));
530
+ for (const [key, value] of Object.entries(AUTH_CACHE_HEADERS)) headers.set(key, value);
531
+ return new Response(response.body, {
532
+ status: response.status,
533
+ statusText: response.statusText,
534
+ headers
535
+ });
536
+ }
537
+ /**
538
+ * Entry contributing `ctx.session`, the request's `AuthResolution`: a bearer
539
+ * token first, the session cookie second. It is the only entry with a response
540
+ * seam for cookies: on the way out it adds the refreshed session cookies and
541
+ * the no-store headers, and hands pending event sends to `waitUntil`.
542
+ */
543
+ function withSession(core, config = {}) {
544
+ return defineMiddleware({
545
+ key: "session",
546
+ run: () => async function* run(request, ctx) {
547
+ const call = callOf(ctx)?.options;
548
+ const refresh = call ? call.refresh ?? false : refreshFor(config.refresh, request);
549
+ const cookies = call ? call.cookies : config.cookies;
550
+ const verifySession = !call && checkFor(config.verifySession, request);
551
+ const session = await core.resolve(request, {
552
+ ...refresh === void 0 ? {} : { refresh },
553
+ ...cookies === void 0 ? {} : { cookies },
554
+ ...verifySession ? { verifySession } : {},
555
+ ...config.encode === void 0 ? {} : { encode: config.encode }
556
+ });
557
+ const outage = await outageResponse(config.onAuthOutage, session, request, core.events.logger);
558
+ if (outage) return session.apply(outage);
559
+ try {
560
+ const response = yield { session };
561
+ const applied = session.apply(response);
562
+ return config.cookieScopes?.length ? clearOldScopes(applied, request, core.sessionCookie(), config.cookieScopes) : applied;
563
+ } finally {
564
+ if (config.waitUntil && core.events.pending) config.waitUntil(core.events.settled());
565
+ }
566
+ }
567
+ })();
568
+ }
569
+ // src/server/entries/support.ts
570
+ /**
571
+ * Entry contributing `ctx.support`: the support session ("view as user") the
572
+ * request's support cookie names, when `ServerOptions.support` is set and the
573
+ * caller is the admin who started it. `undefined` otherwise.
574
+ */
575
+ function withSupport(core) {
576
+ return defineMiddleware({
577
+ key: "support",
578
+ run: () => async (request, ctx) => {
579
+ return { support: callOf(ctx)?.options.support ?? await supportLookup(core, request, ctx.session) };
580
+ }
581
+ })();
582
+ }
583
+ // src/server/entries/tenant.ts
584
+ /**
585
+ * Entry contributing `ctx.tenant`: the active tenant from
586
+ * `ServerOptions.tenant` (a URL slug, a header), or `undefined`. It becomes
587
+ * `context.tenant` for `membershipsExtension()`, the `better_supabase.tenant`
588
+ * setting over Postgres and the `x-bsb-tenant` header over PostgREST. It starts
589
+ * the support lookup that `withSupport` awaits, so both run at once.
590
+ */
591
+ function withTenant(core) {
592
+ return defineMiddleware({
593
+ key: "tenant",
594
+ run: () => async (request, ctx) => {
595
+ const options = callOf(ctx)?.options;
596
+ if (options?.support === void 0) startSupportLookup(core, request, ctx.session);
597
+ return { tenant: options?.tenant ?? await core.tenant(request, ctx.session.auth) };
598
+ }
599
+ })();
600
+ }
601
+ // src/server/lite.ts
602
+ /** Lite's default driver, the one `lite init` scaffolds. */
603
+ const DEFAULT_LITE_DRIVER = "sqlite-postgres";
604
+ /**
605
+ * Whether the driver stores data in SQLite, where Lite has no database
606
+ * functions.
607
+ */
608
+ function isSqliteDriver(driver) {
609
+ switch (driver) {
610
+ case "sqlite-postgres":
611
+ case "sqlite": return true;
612
+ case "pglite":
613
+ case "postgres": return false;
614
+ default: return driver;
615
+ }
616
+ }
617
+ function liteRpcUnavailable(driver) {
618
+ return `rpc() is not available on Supabase Lite with the ${driver} driver. Set [db] driver = "pglite" or "postgres" in supabase/config.toml, or call an HTTP endpoint instead.`;
619
+ }
620
+ /** What `backend: "lite"` changes in `createServer`; `undefined` for Supabase. */
621
+ function liteBackend(options, env) {
622
+ if (options.backend !== "lite") return;
623
+ const driver = options.liteDriver ?? DEFAULT_LITE_DRIVER;
624
+ if (options.postgres && driver !== "postgres") throw new TypeError(`Supabase Lite with the ${driver} driver has no Postgres connection for ctx.sql. Remove the postgres option, or run Lite with [db] driver = "postgres".`);
625
+ return {
626
+ auth() {
627
+ if (options.auth?.jwtSecret !== void 0) return options.auth;
628
+ const jwtSecret = env().jwtSecret;
629
+ if (jwtSecret === void 0) throw new TypeError("backend: \"lite\" needs SUPABASE_JWT_SECRET, the auth.jwt_secret Supabase Lite signs user tokens with");
630
+ return {
631
+ ...options.auth,
632
+ jwtSecret
633
+ };
634
+ },
635
+ rpcUnavailable: isSqliteDriver(driver) ? liteRpcUnavailable(driver) : void 0
636
+ };
637
+ }
638
+ // src/server/refusing-executor.ts
639
+ /**
640
+ * An executor for credentials that did not verify: every query, function call
641
+ * and batch answers `error`, so a handler that skips the route guard gets a 401
642
+ * `Result` and never queries as anon.
643
+ */
644
+ function refusingExecutor(error) {
645
+ const refuse = () => err(error);
646
+ return {
647
+ name: "refused",
648
+ functionSources: true,
649
+ execute: () => Promise.resolve(refuse()),
650
+ rpc: () => Promise.resolve(refuse()),
651
+ batch: (ops) => Promise.resolve(ops.map(() => refuse()))
652
+ };
653
+ }
654
+ // src/server/request-ids.ts
655
+ const REQUEST_ID_PATTERN = /^[A-Za-z0-9._:;,@/+=-]{1,128}$/;
656
+ function requestIdOrUndefined(value) {
657
+ return typeof value === "string" && REQUEST_ID_PATTERN.test(value) ? value : void 0;
658
+ }
659
+ function sessionWith(ids, tenant, readOnly = false) {
660
+ const settings = {
661
+ ...ids.requestId === void 0 ? {} : { "better_supabase.request_id": ids.requestId },
662
+ ...ids.correlationId === void 0 ? {} : { "better_supabase.correlation_id": ids.correlationId },
663
+ ...tenant === void 0 ? {} : { "better_supabase.tenant": tenant }
664
+ };
665
+ const hasSettings = Object.keys(settings).length > 0;
666
+ if (!hasSettings && !readOnly) return;
667
+ return {
668
+ ...readOnly ? { readOnly: true } : {},
669
+ ...hasSettings ? { settings } : {}
670
+ };
671
+ }
672
+ function requestIdPolicy(options = {}) {
673
+ const on = options !== false;
674
+ const settings = on ? options : {};
675
+ const requestHeader = (settings.requestHeader ?? "x-request-id").toLowerCase();
676
+ const correlationHeader = (settings.correlationHeader ?? "x-correlation-id").toLowerCase();
677
+ const incoming = on && (settings.incoming ?? true);
678
+ const generate = on && (settings.generate ?? true);
679
+ const generated = /* @__PURE__ */ new WeakMap();
680
+ const fromHeader = (request, name) => incoming && request ? requestIdOrUndefined(request.headers.get(name)) : void 0;
681
+ const generatedFor = (request) => {
682
+ if (!generate || !request) return;
683
+ const known = generated.get(request);
684
+ if (known !== void 0) return known;
685
+ const id = crypto.randomUUID();
686
+ generated.set(request, id);
687
+ return id;
688
+ };
689
+ return {
690
+ forRequest(request, explicit) {
691
+ const requestId = requestIdOrUndefined(explicit.requestId) ?? fromHeader(request, requestHeader) ?? generatedFor(request);
692
+ const correlationId = requestIdOrUndefined(explicit.correlationId) ?? fromHeader(request, correlationHeader) ?? requestId;
693
+ return {
694
+ ...requestId === void 0 ? {} : { requestId },
695
+ ...correlationId === void 0 ? {} : { correlationId }
696
+ };
697
+ },
698
+ headers: (ids) => ({
699
+ ...ids.requestId === void 0 ? {} : { [requestHeader]: ids.requestId },
700
+ ...ids.correlationId === void 0 ? {} : { [correlationHeader]: ids.correlationId }
701
+ })
702
+ };
703
+ }
704
+ // src/server/server-types.ts
705
+ /** The header `current_tenant_id()` reads over the Data API. */
706
+ const TENANT_HEADER = "x-bsb-tenant";
707
+ // src/server/sessions.ts
708
+ const ANON = {
709
+ kind: "none",
710
+ reason: "none"
711
+ };
712
+ /**
713
+ * The verified state behind a snapshot this process built, `anon` once it
714
+ * expired, and `invalid` for a forged or deserialized one.
715
+ */
716
+ function authFor(session) {
717
+ const source = authOfSnapshot(session);
718
+ if (!source) return {
719
+ kind: "invalid",
720
+ reason: "token",
721
+ error: dbError("unauthorized", "The session snapshot is invalid")
722
+ };
723
+ if (session.expiresAt !== null && session.expiresAt * 1e3 <= Date.now()) return {
724
+ kind: "none",
725
+ reason: "expired"
726
+ };
727
+ return source;
728
+ }
729
+ /** The members of `BetterServer` that the verified-session memo backs. */
730
+ function serverSessions(options) {
731
+ const memo = options.memo === false ? void 0 : sessionMemo((verified) => verified.auth.expiresAt, options.memo);
732
+ const verified = (auth, token) => {
733
+ if (auth.kind !== "user" || auth.token !== token) return null;
734
+ const snapshot = snapshotOf(auth);
735
+ return snapshot ? {
736
+ auth,
737
+ snapshot
738
+ } : null;
739
+ };
740
+ const snapshot = async (request) => {
741
+ const token = options.custom ? null : requestToken(request, options.cookieName(), options.cookies);
742
+ if (!token || !memo) {
743
+ const resolution = await options.resolve(request, { refresh: false });
744
+ return snapshotOf(resolution.auth);
745
+ }
746
+ return (await memo.get(token, async () => {
747
+ const resolution = await options.resolve(request, { refresh: false });
748
+ return verified(resolution.auth, token);
749
+ }))?.snapshot ?? null;
750
+ };
751
+ const contextFromSession = (session, contextOptions) => {
752
+ const auth = session ? authFor(session) : ANON;
753
+ return Promise.resolve(options.contextFor(auth, contextOptions ?? {}));
754
+ };
755
+ const evict = (userId) => {
756
+ memo?.evict((session) => session.auth.user.id === userId);
757
+ };
758
+ return {
759
+ snapshot,
760
+ contextFromSession,
761
+ sessions: {
762
+ stats: () => memo?.stats() ?? {
763
+ hits: 0,
764
+ misses: 0,
765
+ size: 0
766
+ },
767
+ seed: async (auth) => {
768
+ const found = auth.kind === "user" ? verified(auth, auth.token) : null;
769
+ if (found && memo) await memo.seed(found.auth.token, found);
770
+ },
771
+ evict,
772
+ clear: () => memo?.clear()
773
+ },
774
+ evictSession: async (userId) => {
775
+ evict(userId);
776
+ await options.versions?.evict(userId);
777
+ }
778
+ };
779
+ }
780
+ // src/auth/support-cookie.ts
781
+ /** The cookie that carries the support session id. */
782
+ const SUPPORT_COOKIE = "bsb-support";
783
+ /**
784
+ * Seconds until the session expires, rounded up so the cookie never outlives it
785
+ * by less than a second.
786
+ */
787
+ function supportCookieMaxAge(session, now = Date.now()) {
788
+ return Math.max(0, Math.ceil((session.expiresAt.epochMilliseconds - now) / 1e3));
789
+ }
790
+ /**
791
+ * `Set-Cookie` for a session: HttpOnly, SameSite=Lax, gone when the session
792
+ * expires.
793
+ */
794
+ function supportCookie(session, options = {}, now = Date.now()) {
795
+ return cookieLine(options, encodeURIComponent(session.id), supportCookieMaxAge(session, now));
796
+ }
797
+ /** `Set-Cookie` that removes the support cookie. */
798
+ function clearSupportCookie(options = {}) {
799
+ return cookieLine(options, "", 0);
800
+ }
801
+ function cookieLine(options, value, maxAge) {
802
+ return [
803
+ `${options.name ?? "bsb-support"}=${value}`,
804
+ `Path=${options.path ?? "/"}`,
805
+ `Max-Age=${String(maxAge)}`,
806
+ "HttpOnly",
807
+ "SameSite=Lax",
808
+ ...options.secure === false ? [] : ["Secure"]
809
+ ].join("; ");
810
+ }
811
+ /** The support session id in a `Cookie` header, or `undefined`. */
812
+ function supportCookieValue(cookieHeader, name = SUPPORT_COOKIE) {
813
+ if (!cookieHeader) return;
814
+ for (const part of cookieHeader.split(";")) {
815
+ const index = part.indexOf("=");
816
+ if (index === -1 || part.slice(0, index).trim() !== name) continue;
817
+ let value;
818
+ try {
819
+ value = decodeURIComponent(part.slice(index + 1).trim());
820
+ } catch {
821
+ return;
822
+ }
823
+ return value === "" ? void 0 : value;
824
+ }
825
+ }
826
+ // src/server/support-off.ts
827
+ const NOT_CONFIGURED = "Support sessions need createServer(betterSupabase, { support: supportSessions({ store }) })";
828
+ const notConfigured = () => AsyncResult.err(dbError("unexpected", NOT_CONFIGURED));
829
+ /** `bsb.support` without `ServerOptions.support`: every call fails. */
830
+ const supportOff = {
831
+ start: notConfigured,
832
+ request: notConfigured,
833
+ approve: notConfigured,
834
+ stop: notConfigured,
835
+ revoke: notConfigured,
836
+ current: () => Promise.resolve(void 0),
837
+ resolve: () => Promise.resolve(void 0),
838
+ list: notConfigured,
839
+ expire: notConfigured,
840
+ expireRoute: () => () => Promise.resolve(problemResponse(dbError("unexpected", NOT_CONFIGURED))),
841
+ sessionIdOf: () => void 0,
842
+ clearCookie: () => clearSupportCookie()
843
+ };
844
+ // src/server/support-storage.ts
845
+ const VISIBLE_OBJECT = "select exists (select 1 from storage.objects o where o.bucket_id = $1 and o.name = $2) as visible";
846
+ const VISIBLE_OBJECTS = `select n.path from unnest($2::text[]) as n(path)
847
+ where exists (select 1 from storage.objects o where o.bucket_id = $1 and o.name = n.path)`;
848
+ const OBJECT_INFO = "select to_jsonb(o) as object from storage.objects o where o.bucket_id = $1 and o.name = $2";
849
+ const SEARCH = `select s.name, s.id::text as id, s.updated_at, s.created_at, s.last_accessed_at, s.metadata
850
+ from storage.search($1::text, $2::text, $3::int, $4::int, $5::int, $6::text, $7::text, $8::text) s`;
851
+ const SEARCH_V2 = `select s.key, s.name, s.id::text as id, s.updated_at, s.created_at, s.last_accessed_at, s.metadata
852
+ from storage.search_v2($1::text, $2::text, $3::int, $4::int, $5::text, $6::text, $7::text, $8::text) s`;
853
+ const SAVEPOINT = "better_supabase_support_write";
854
+ const INSERT_OBJECT = `insert into storage.objects (bucket_id, name, owner, owner_id, user_metadata)
855
+ values ($1, $2, $3::uuid, $4, $5::jsonb)`;
856
+ const CURRENT_VERSION_INDEX = `select exists (select 1 from pg_indexes
857
+ where schemaname = 'storage' and tablename = 'objects' and indexname = 'idx_objects_current_version') as versioned`;
858
+ const upsertObject = (versioned) => `${INSERT_OBJECT}
859
+ on conflict ${versioned ? "(bucket_id, name collate \"C\") where archived_at is null" : "(bucket_id, name)"} do update
860
+ set owner = excluded.owner, owner_id = excluded.owner_id, user_metadata = excluded.user_metadata`;
861
+ const SOURCE_OBJECT = "select name, owner_id from storage.objects where bucket_id = $1 and name = $2";
862
+ const MOVE_OBJECT = `update storage.objects
863
+ set bucket_id = $3, name = $4, owner = $5::uuid, owner_id = $6
864
+ where bucket_id = $1 and name = $2
865
+ returning name`;
866
+ const ALLOW_DELETE = "select set_config('storage.allow_delete_query', 'true', true)";
867
+ const DELETE_OBJECTS = "delete from storage.objects where bucket_id = $1 and name = any($2::text[]) returning name";
868
+ const OWN_UPLOAD = `update storage.objects set owner = $3::uuid, owner_id = $4
869
+ where bucket_id = $1 and name = $2 and user_metadata ->> 'supportSessionId' = $5`;
870
+ const OWN_COPY = `update storage.objects
871
+ set owner = $3::uuid, owner_id = $4, user_metadata = coalesce(user_metadata, '{}'::jsonb) || $5::jsonb
872
+ where bucket_id = $1 and name = $2 and owner_id is null`;
873
+ const ownSignedUpload = (versioned) => `update storage.objects
874
+ set owner = $3::uuid, owner_id = $4, user_metadata = coalesce(user_metadata, '{}'::jsonb) || $5::jsonb
875
+ where bucket_id = $1 and name = $2 and owner_id is null and updated_at >= $6::timestamptz${versioned ? " and archived_at is null" : ""}
876
+ returning name`;
877
+ const signedUploadOwner = (versioned) => `select owner_id, updated_at >= $3::timestamptz as recent
878
+ from storage.objects where bucket_id = $1 and name = $2${versioned ? " and archived_at is null" : ""}`;
879
+ const OWN_MOVE = `update storage.objects
880
+ set owner = $3::uuid, owner_id = $4, user_metadata = coalesce(user_metadata, '{}'::jsonb) || $5::jsonb
881
+ where bucket_id = $1 and name = $2 and owner_id is not distinct from $6`;
882
+ const UUID = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i;
883
+ const STALE = {
884
+ name: "StorageApiError",
885
+ message: "The object was stored before the support session started",
886
+ status: 403,
887
+ statusCode: "403",
888
+ code: "AccessDenied"
889
+ };
890
+ const OWNED = {
891
+ name: "StorageApiError",
892
+ message: "The object belongs to another user",
893
+ status: 403,
894
+ statusCode: "403",
895
+ code: "AccessDenied"
896
+ };
897
+ const HIDDEN_URL = "Either the object does not exist or you do not have access to it";
898
+ const LIST_SORT_COLUMNS = /* @__PURE__ */ new Set([
899
+ "name",
900
+ "updated_at",
901
+ "created_at",
902
+ "last_accessed_at"
903
+ ]);
904
+ const LIST_V2_SORT_COLUMNS = /* @__PURE__ */ new Set([
905
+ "name",
906
+ "updated_at",
907
+ "created_at"
908
+ ]);
909
+ const FLAT_SORT_COLUMNS = /* @__PURE__ */ new Set(["updated_at", "created_at"]);
910
+ const SORT_ORDERS = /* @__PURE__ */ new Set(["asc", "desc"]);
911
+ const CURSOR_PARTS = {
912
+ l: "startAfter",
913
+ o: "sortOrder",
914
+ c: "sortColumn",
915
+ a: "sortColumnAfter"
916
+ };
917
+ const isCursorKey = (key) => Object.hasOwn(CURSOR_PARTS, key);
918
+ /**
919
+ * The path storage-js sends for an upload: no leading or trailing `/`, and no
920
+ * empty folders.
921
+ */
922
+ function normalizePath(path) {
923
+ return path.replaceAll(/^\/|\/$/g, "").replaceAll(/\/+/g, "/");
924
+ }
925
+ /** `undefined` for an empty string, which storage-api treats as absent. */
926
+ const filled = (value) => value === "" ? void 0 : value;
927
+ /** `LIKE` escaping as storage-api applies it. */
928
+ function escapeLike(text) {
929
+ return text.replaceAll("\\", "\\\\").replaceAll(/([%_])/g, "\\$1");
930
+ }
931
+ function iso(value) {
932
+ if (value instanceof Date) return value.toISOString();
933
+ if (typeof value !== "string") return value;
934
+ const time = Date.parse(value);
935
+ return Number.isNaN(time) ? value : new Date(time).toISOString();
936
+ }
937
+ /** Storage-api's continuation token: `key:value` lines, base64 encoded. */
938
+ function encodeCursor(cursor) {
939
+ const text = Object.entries(CURSOR_PARTS).flatMap(([key, part]) => cursor[part] ? [`${key}:${cursor[part]}`] : []).join("\n");
940
+ let binary = "";
941
+ for (const byte of new TextEncoder().encode(text)) binary += String.fromCodePoint(byte);
942
+ return btoa(binary);
943
+ }
944
+ function decodeCursor(token) {
945
+ let text;
946
+ try {
947
+ text = new TextDecoder().decode(Uint8Array.from(atob(token), (char) => char.codePointAt(0) ?? 0));
948
+ } catch {
949
+ return;
950
+ }
951
+ const cursor = {
952
+ startAfter: "",
953
+ sortOrder: "asc"
954
+ };
955
+ for (const part of text.split("\n")) {
956
+ const match = /^(\S):(.*)/.exec(part);
957
+ const key = match?.[1];
958
+ if (!key || !isCursorKey(key)) return;
959
+ cursor[CURSOR_PARTS[key]] = match[2] ?? "";
960
+ }
961
+ return cursor;
962
+ }
963
+ const apiError = (status, message, code) => ({
964
+ name: "StorageApiError",
965
+ message,
966
+ status,
967
+ statusCode: String(status),
968
+ code
969
+ });
970
+ const ownerOf = (userId) => UUID.test(userId) ? userId : null;
971
+ const stampOf = (session) => ({
972
+ supportSessionId: session.id,
973
+ supportAdminId: session.adminId
974
+ });
975
+ const failed = (error) => ({
976
+ data: null,
977
+ error
978
+ });
979
+ /**
980
+ * Storage answers a hidden object like a missing one: HTTP 400 with
981
+ * `statusCode` 404.
982
+ */
983
+ const NOT_FOUND = {
984
+ name: "StorageApiError",
985
+ message: "Object not found",
986
+ status: 400,
987
+ statusCode: "404",
988
+ code: "NoSuchKey"
989
+ };
990
+ const invalid = (message) => apiError(400, message, "InvalidRequest");
991
+ /**
992
+ * A database failure as a Storage `error` that `fromStorageError` passes
993
+ * through unchanged.
994
+ */
995
+ function sqlFailure(cause) {
996
+ const raw = fromPgError(cause);
997
+ return {
998
+ name: "DbError",
999
+ ...raw ? mapDbError(raw) : toDbError(cause)
1000
+ };
1001
+ }
1002
+ /**
1003
+ * An RLS or duplicate failure of a dry run, as Storage reports it for the
1004
+ * target's own request.
1005
+ */
1006
+ function refusedWrite(cause) {
1007
+ const raw = fromPgError(cause);
1008
+ if (raw?.code === "42501") return apiError(403, raw.message === void 0 || raw.message.includes("row-level security") ? "new row violates row-level security policy" : raw.message, "AccessDenied");
1009
+ if (raw?.code === "23505") return apiError(409, "The resource already exists", "Duplicate");
1010
+ }
1011
+ async function settled(run) {
1012
+ try {
1013
+ return await run();
1014
+ } catch (cause) {
1015
+ return failed(sqlFailure(cause));
1016
+ }
1017
+ }
1018
+ function listProblem(options) {
1019
+ const { limit, offset, sortBy } = options;
1020
+ if (limit !== void 0 && (!Number.isInteger(limit) || limit < 1)) return "body/limit must be an integer of at least 1";
1021
+ if (offset !== void 0 && (!Number.isInteger(offset) || offset < 0)) return "body/offset must be an integer of at least 0";
1022
+ if (sortBy?.column !== void 0 && !LIST_SORT_COLUMNS.has(sortBy.column)) return "body/sortBy/column must be name, updated_at, created_at or last_accessed_at";
1023
+ if (sortBy?.order !== void 0 && !SORT_ORDERS.has(sortBy.order)) return "body/sortBy/order must be asc or desc";
1024
+ }
1025
+ function listV2Problem(options) {
1026
+ const { limit, sortBy } = options;
1027
+ if (limit !== void 0 && (!Number.isInteger(limit) || limit < 1)) return "body/limit must be an integer of at least 1";
1028
+ if (sortBy !== void 0 && !LIST_V2_SORT_COLUMNS.has(sortBy.column)) return "body/sortBy/column must be name, updated_at or created_at";
1029
+ if (sortBy?.order !== void 0 && !SORT_ORDERS.has(sortBy.order)) return "body/sortBy/order must be asc or desc";
1030
+ }
1031
+ /** The query storage-api runs for a `list-v2` page without a delimiter. */
1032
+ function flatPage(bucket, prefix, maxKeys, cursor, column, order) {
1033
+ const values = [bucket, maxKeys];
1034
+ const conditions = ["bucket_id = $1"];
1035
+ const sortColumn = column && FLAT_SORT_COLUMNS.has(column) ? column : void 0;
1036
+ const sortOrder = order && SORT_ORDERS.has(order) ? order : "asc";
1037
+ const operator = sortOrder === "asc" ? ">" : "<";
1038
+ const param = () => `$${String(values.length)}`;
1039
+ if (prefix) {
1040
+ values.push(`${escapeLike(prefix)}%`);
1041
+ conditions.push(`name like ${param()}`);
1042
+ }
1043
+ const startAfter = cursor?.startAfter;
1044
+ if (startAfter && sortColumn && cursor.sortColumnAfter) {
1045
+ values.push(cursor.sortColumnAfter);
1046
+ const afterParam = param();
1047
+ values.push(startAfter);
1048
+ conditions.push(`row(date_trunc('milliseconds', ${sortColumn}), name collate "C") ${operator} row(coalesce(nullif(${afterParam}, '')::timestamptz, 'epoch'::timestamptz), ${param()})`);
1049
+ } else if (startAfter) {
1050
+ values.push(startAfter);
1051
+ conditions.push(`name collate "C" ${operator} ${param()}`);
1052
+ }
1053
+ return {
1054
+ text: `select id::text as id, name, metadata, updated_at, created_at, last_accessed_at
1055
+ from storage.objects
1056
+ where ${conditions.join(" and ")}
1057
+ order by ${sortColumn ? `${sortColumn} ${sortOrder}, ` : ""}name collate "C" ${sortOrder}
1058
+ limit $2::int`,
1059
+ values
1060
+ };
1061
+ }
1062
+ /**
1063
+ * Groups the entries below the next delimiter into folders, as storage-api
1064
+ * does.
1065
+ */
1066
+ function delimited(entries, prefix) {
1067
+ const grouped = [];
1068
+ let previous = "";
1069
+ for (const entry of entries) {
1070
+ const name = String(entry["name"]);
1071
+ const index = name.replace(prefix, "").indexOf("/");
1072
+ if (index === -1) {
1073
+ grouped.push(entry);
1074
+ continue;
1075
+ }
1076
+ const folder = name.slice(0, prefix.length + index + 1);
1077
+ if (folder === previous) continue;
1078
+ previous = folder;
1079
+ grouped.push({
1080
+ id: null,
1081
+ name: folder
1082
+ });
1083
+ }
1084
+ return grouped;
1085
+ }
1086
+ const text = (value) => typeof value === "string" ? value : void 0;
1087
+ const metadataOf = (value) => isRecord(value) ? value : null;
1088
+ function listEntryOf(row) {
1089
+ return {
1090
+ name: String(row["name"]),
1091
+ id: text(row["id"]) ?? null,
1092
+ updated_at: text(iso(row["updated_at"])) ?? null,
1093
+ created_at: text(iso(row["created_at"])) ?? null,
1094
+ last_accessed_at: text(iso(row["last_accessed_at"])) ?? null,
1095
+ metadata: metadataOf(row["metadata"])
1096
+ };
1097
+ }
1098
+ function folderOf(row) {
1099
+ const name = String(row["name"]);
1100
+ const key = text(row["key"]);
1101
+ return {
1102
+ name: name.endsWith("/") ? name : `${name}/`,
1103
+ ...key === void 0 ? {} : { key }
1104
+ };
1105
+ }
1106
+ function objectOf(row) {
1107
+ const key = text(row["key"]);
1108
+ const lastAccessed = text(iso(row["last_accessed_at"]));
1109
+ return {
1110
+ name: String(row["name"]),
1111
+ ...key === void 0 ? {} : { key },
1112
+ id: text(row["id"]) ?? "",
1113
+ updated_at: text(iso(row["updated_at"])) ?? "",
1114
+ created_at: text(iso(row["created_at"])) ?? "",
1115
+ ...lastAccessed === void 0 ? {} : { last_accessed_at: lastAccessed },
1116
+ metadata: metadataOf(row["metadata"])
1117
+ };
1118
+ }
1119
+ function infoOf(row) {
1120
+ const metadata = isRecord(row["metadata"]) ? row["metadata"] : {};
1121
+ const size = metadata["size"];
1122
+ const contentType = text(metadata["mimetype"]);
1123
+ const cacheControl = text(metadata["cacheControl"]);
1124
+ const etag = text(metadata["eTag"]);
1125
+ const lastModified = text(iso(row["updated_at"]));
1126
+ const userMetadata = row["user_metadata"];
1127
+ const archivedAt = row["archived_at"];
1128
+ const deleteMarker = row["is_delete_marker"];
1129
+ const versioned = row["is_versioned"];
1130
+ return {
1131
+ id: text(row["id"]) ?? "",
1132
+ name: text(row["name"]) ?? "",
1133
+ version: text(row["version"]) ?? "",
1134
+ bucketId: text(row["bucket_id"]) ?? "",
1135
+ createdAt: text(iso(row["created_at"])) ?? "",
1136
+ ...typeof size === "number" ? { size } : {},
1137
+ ...contentType === void 0 ? {} : { contentType },
1138
+ ...cacheControl === void 0 ? {} : { cacheControl },
1139
+ ...etag === void 0 ? {} : { etag },
1140
+ ...lastModified === void 0 ? {} : { lastModified },
1141
+ ...isRecord(userMetadata) ? { metadata: userMetadata } : {},
1142
+ ...archivedAt === void 0 ? {} : { archivedAt: text(iso(archivedAt)) ?? null },
1143
+ ...typeof deleteMarker === "boolean" ? { isDeleteMarker: deleteMarker } : {},
1144
+ ...typeof versioned === "boolean" ? { isVersioned: versioned } : {}
1145
+ };
1146
+ }
1147
+ /**
1148
+ * Storage for a support session, with the same `from(bucket)` file API as
1149
+ * `supabase.storage`, so `bucket.connect()` and the blocks take it.
1150
+ *
1151
+ * Storage policies read `auth.uid()` from the request's token, and there is no
1152
+ * token for the target, so reads go through Postgres as the target. `exists`,
1153
+ * `info`, `list` and `listV2` run entirely there: the listings call the
1154
+ * invoker-rights `storage.search` functions storage-api calls, so RLS filters
1155
+ * each page as it would for the target's own request. `download` and the signed
1156
+ * URLs first check there that the target may see the object, then the service
1157
+ * client serves it. A hidden object answers like a missing one. `getPublicUrl`
1158
+ * is built without a check, as it is built without a request.
1159
+ *
1160
+ * In a writable session, `upload`, `update`, `remove`, `copy` and `move` first
1161
+ * run the row change Storage would make as the target, inside a savepoint that
1162
+ * is rolled back, so the policies on `storage.objects` decide as for the
1163
+ * target's own request. Then the service client writes, the admin connection
1164
+ * makes the target the owner of the stored object, and its `user_metadata`
1165
+ * records the session id and the admin's id. A refused dry run resolves to
1166
+ * Storage's `403`.
1167
+ *
1168
+ * `createSignedUploadUrl` runs the same dry run as `upload` before the service
1169
+ * client signs the URL. The object a browser uploads there has no owner, so
1170
+ * `claimSignedUpload(bucket, path)` finishes the upload: it checks again that
1171
+ * the target may insert at the path, then makes the target the owner of an
1172
+ * object without one that was stored after `session.startedAt`, and stamps the
1173
+ * session on its `user_metadata`. An older object, or one another user owns, is
1174
+ * refused with a `403`. `uploadToSignedUrl` claims what it stores and removes
1175
+ * it when the claim fails. Every write in a read-only session resolves to a
1176
+ * `403` `SUPPORT_READ_ONLY` error, and without `adminSql`, `session` or a `sql`
1177
+ * client with `transaction` to a `403` `SUPPORT_STORAGE_WRITES` error.
1178
+ */
1179
+ function supportStorage(options) {
1180
+ const readOnly = options.readOnly ?? true;
1181
+ const { adminSql, session, sql } = options;
1182
+ const writer = !readOnly && adminSql && session && sql.transaction ? {
1183
+ adminSql,
1184
+ session
1185
+ } : void 0;
1186
+ const refusal = readOnly ? apiError(403, "The support session is read-only", "SUPPORT_READ_ONLY") : apiError(403, "Storage writes in a support session need adminSql, session and a sql client with transaction", "SUPPORT_STORAGE_WRITES");
1187
+ const refuse = () => Promise.resolve(failed(refusal));
1188
+ const rows = (query, values) => sql.queryRaw(query, values);
1189
+ let versioned;
1190
+ const isVersioned = () => versioned ??= rows(CURRENT_VERSION_INDEX, []).then(([row]) => row?.["versioned"] === true).catch((cause) => {
1191
+ versioned = void 0;
1192
+ throw cause;
1193
+ });
1194
+ const upsertStatement = () => isVersioned().then(upsertObject);
1195
+ const rehearse = async (run) => {
1196
+ if (!sql.transaction) return refusal;
1197
+ try {
1198
+ return await sql.transaction(async (client) => {
1199
+ await client.queryRaw(`savepoint ${SAVEPOINT}`);
1200
+ try {
1201
+ return await run(client);
1202
+ } finally {
1203
+ await client.queryRaw(`rollback to savepoint ${SAVEPOINT}`);
1204
+ }
1205
+ });
1206
+ } catch (cause) {
1207
+ const refused = refusedWrite(cause);
1208
+ if (refused) return refused;
1209
+ throw cause;
1210
+ }
1211
+ };
1212
+ const rehearseStore = (bucket, active, name, statement, metadata) => rehearse(async (client) => {
1213
+ await client.queryRaw(statement, [
1214
+ bucket,
1215
+ name,
1216
+ ownerOf(active.targetUserId),
1217
+ active.targetUserId,
1218
+ JSON.stringify(metadata)
1219
+ ]);
1220
+ return null;
1221
+ });
1222
+ const claimFor = async (bucket, { adminSql: ownerSql, session: active }, name) => {
1223
+ const objectVersioned = await isVersioned();
1224
+ const since = active.startedAt.toString();
1225
+ const own = async () => {
1226
+ const [claimed] = await ownerSql.queryRaw(ownSignedUpload(objectVersioned), [
1227
+ bucket,
1228
+ name,
1229
+ ownerOf(active.targetUserId),
1230
+ active.targetUserId,
1231
+ JSON.stringify(stampOf(active)),
1232
+ since
1233
+ ]);
1234
+ return claimed !== void 0;
1235
+ };
1236
+ const inspect = async () => {
1237
+ const [found] = await ownerSql.queryRaw(signedUploadOwner(objectVersioned), [
1238
+ bucket,
1239
+ name,
1240
+ since
1241
+ ]);
1242
+ return found;
1243
+ };
1244
+ if (await own()) return {
1245
+ data: { path: name },
1246
+ error: null
1247
+ };
1248
+ let found = await inspect();
1249
+ if (found?.["owner_id"] === null && found["recent"] === true) {
1250
+ if (await own()) return {
1251
+ data: { path: name },
1252
+ error: null
1253
+ };
1254
+ found = await inspect();
1255
+ }
1256
+ if (!found) return failed(NOT_FOUND);
1257
+ if (found["owner_id"] === active.targetUserId) return {
1258
+ data: { path: name },
1259
+ error: null
1260
+ };
1261
+ return found["recent"] === true ? failed(OWNED) : failed(STALE);
1262
+ };
1263
+ const claimSignedUpload = (bucket, path) => {
1264
+ if (!writer) return refuse();
1265
+ return settled(async () => {
1266
+ const name = normalizePath(path);
1267
+ const active = writer.session;
1268
+ const refused = await rehearse(async (client) => {
1269
+ try {
1270
+ await client.queryRaw(INSERT_OBJECT, [
1271
+ bucket,
1272
+ name,
1273
+ ownerOf(active.targetUserId),
1274
+ active.targetUserId,
1275
+ JSON.stringify(stampOf(active))
1276
+ ]);
1277
+ } catch (cause) {
1278
+ if (fromPgError(cause)?.code === "23505") return null;
1279
+ throw cause;
1280
+ }
1281
+ return NOT_FOUND;
1282
+ });
1283
+ if (refused) return failed(refused);
1284
+ return claimFor(bucket, writer, name);
1285
+ });
1286
+ };
1287
+ return {
1288
+ claimSignedUpload,
1289
+ from(bucket) {
1290
+ const admin = () => options.admin.from(bucket);
1291
+ const visible = async (path) => {
1292
+ const [row] = await rows(VISIBLE_OBJECT, [bucket, path]);
1293
+ return row?.["visible"] === true;
1294
+ };
1295
+ const checked = (path, read) => settled(async () => {
1296
+ const name = normalizePath(path);
1297
+ if (!await visible(name)) return failed(NOT_FOUND);
1298
+ return read(name);
1299
+ });
1300
+ const list = (path, listOptions = {}) => settled(async () => {
1301
+ const problem = listProblem(listOptions);
1302
+ if (problem) return failed(invalid(problem));
1303
+ let prefix = path ?? "";
1304
+ if (prefix.length > 0 && !prefix.endsWith("/")) prefix = `${prefix}/`;
1305
+ const column = listOptions.sortBy?.column ?? "name";
1306
+ const escape = column !== "name";
1307
+ const safePrefix = escape ? escapeLike(prefix) : prefix;
1308
+ const search = listOptions.search ?? "";
1309
+ const safeSearch = escape ? escapeLike(search) : search;
1310
+ return {
1311
+ data: (await rows(SEARCH, [
1312
+ safePrefix,
1313
+ bucket,
1314
+ listOptions.limit ?? 100,
1315
+ (safePrefix + safeSearch).split("/").length,
1316
+ listOptions.offset ?? 0,
1317
+ safeSearch,
1318
+ column,
1319
+ listOptions.sortBy?.order ?? "asc"
1320
+ ])).map(listEntryOf),
1321
+ error: null
1322
+ };
1323
+ });
1324
+ const listV2 = (listOptions = {}) => settled(async () => {
1325
+ const problem = listV2Problem(listOptions);
1326
+ if (problem) return failed(invalid(problem));
1327
+ const limit = Math.min(listOptions.limit ?? 1e3, 1e3);
1328
+ const prefix = listOptions.prefix ?? "";
1329
+ const cursor = listOptions.cursor ? decodeCursor(listOptions.cursor) : void 0;
1330
+ if (listOptions.cursor && !cursor) return failed(apiError(400, "Invalid continuation token", "InvalidParameter"));
1331
+ const sortOrder = filled(cursor?.sortOrder) ?? listOptions.sortBy?.order;
1332
+ const sortColumn = filled(cursor?.sortColumn) ?? listOptions.sortBy?.column;
1333
+ let found;
1334
+ if (listOptions.with_delimiter) found = await rows(SEARCH_V2, [
1335
+ prefix,
1336
+ bucket,
1337
+ limit + 1,
1338
+ prefix ? prefix.split("/").length : 1,
1339
+ cursor?.startAfter ?? "",
1340
+ sortOrder ?? "asc",
1341
+ sortColumn ?? "name",
1342
+ filled(cursor?.sortColumnAfter) ?? null
1343
+ ]);
1344
+ else {
1345
+ const page = flatPage(bucket, listOptions.prefix, limit + 1, cursor, sortColumn, sortOrder);
1346
+ found = await rows(page.text, page.values);
1347
+ }
1348
+ const entries = listOptions.with_delimiter ? delimited(found, prefix) : found;
1349
+ const hasNext = entries.length > limit;
1350
+ const count = hasNext ? limit : entries.length;
1351
+ const folders = [];
1352
+ const objects = [];
1353
+ for (const entry of entries.slice(0, count)) if (entry["id"] === null || entry["id"] === void 0) folders.push(folderOf(entry));
1354
+ else objects.push(objectOf(entry));
1355
+ const last = entries[count - 1];
1356
+ const after = last && sortColumn && sortColumn !== "name" ? iso(last[sortColumn]) : void 0;
1357
+ const nextCursor = hasNext && last ? encodeCursor({
1358
+ startAfter: String(last["name"]),
1359
+ ...sortOrder ? { sortOrder } : {},
1360
+ ...sortColumn ? { sortColumn } : {},
1361
+ ...typeof after === "string" ? { sortColumnAfter: new Date(after).toISOString() } : {}
1362
+ }) : void 0;
1363
+ return {
1364
+ data: {
1365
+ hasNext,
1366
+ ...nextCursor === void 0 ? {} : { nextCursor },
1367
+ folders,
1368
+ objects
1369
+ },
1370
+ error: null
1371
+ };
1372
+ });
1373
+ const createSignedUploadUrl = (path, uploadOptions) => {
1374
+ if (!writer) return refuse();
1375
+ return settled(async () => {
1376
+ const name = normalizePath(path);
1377
+ const statement = uploadOptions?.upsert === true ? await upsertStatement() : INSERT_OBJECT;
1378
+ const refused = await rehearseStore(bucket, writer.session, name, statement, stampOf(writer.session));
1379
+ if (refused) return failed(refused);
1380
+ return admin().createSignedUploadUrl(name, uploadOptions);
1381
+ });
1382
+ };
1383
+ const uploadToSignedUrl = (path, token, body, fileOptions = {}) => {
1384
+ if (!writer) return refuse();
1385
+ return settled(async () => {
1386
+ const name = normalizePath(path);
1387
+ const metadata = {
1388
+ ...fileOptions.metadata,
1389
+ ...stampOf(writer.session)
1390
+ };
1391
+ const statement = fileOptions.upsert === true ? await upsertStatement() : INSERT_OBJECT;
1392
+ const refused = await rehearseStore(bucket, writer.session, name, statement, metadata);
1393
+ if (refused) return failed(refused);
1394
+ const reply = await admin().uploadToSignedUrl(name, token, body, {
1395
+ ...fileOptions,
1396
+ metadata
1397
+ });
1398
+ if (reply.error) return reply;
1399
+ const claimed = await claimFor(bucket, writer, name).catch((cause) => failed(sqlFailure(cause)));
1400
+ if (claimed.error) {
1401
+ await admin().remove([name]);
1402
+ return claimed;
1403
+ }
1404
+ return reply;
1405
+ });
1406
+ };
1407
+ const store = (method) => (path, body, fileOptions = {}) => {
1408
+ if (!writer) return refuse();
1409
+ const { adminSql: ownerSql, session: active } = writer;
1410
+ return settled(async () => {
1411
+ const name = normalizePath(path);
1412
+ const owner = ownerOf(active.targetUserId);
1413
+ const metadata = {
1414
+ ...fileOptions.metadata,
1415
+ ...stampOf(active)
1416
+ };
1417
+ const statement = method === "update" || fileOptions.upsert === true ? await upsertStatement() : INSERT_OBJECT;
1418
+ const refused = await rehearseStore(bucket, active, name, statement, metadata);
1419
+ if (refused) return failed(refused);
1420
+ const reply = await admin()[method](name, body, {
1421
+ ...fileOptions,
1422
+ metadata
1423
+ });
1424
+ if (reply.error) return reply;
1425
+ try {
1426
+ await ownerSql.queryRaw(OWN_UPLOAD, [
1427
+ bucket,
1428
+ name,
1429
+ owner,
1430
+ active.targetUserId,
1431
+ active.id
1432
+ ]);
1433
+ } catch (cause) {
1434
+ await admin().remove([name]);
1435
+ return failed(sqlFailure(cause));
1436
+ }
1437
+ return reply;
1438
+ });
1439
+ };
1440
+ const relocate = (method) => (from, to, destination = {}) => {
1441
+ if (!writer) return refuse();
1442
+ const { adminSql: ownerSql, session: active } = writer;
1443
+ return settled(async () => {
1444
+ const source = normalizePath(from);
1445
+ const name = normalizePath(to);
1446
+ const target = destination.destinationBucket ?? bucket;
1447
+ const owner = ownerOf(active.targetUserId);
1448
+ const stamp = JSON.stringify(stampOf(active));
1449
+ let previousOwner = null;
1450
+ const refused = await rehearse(async (client) => {
1451
+ const [found] = await client.queryRaw(SOURCE_OBJECT, [bucket, source]);
1452
+ if (!found) return NOT_FOUND;
1453
+ previousOwner = text(found["owner_id"]) ?? null;
1454
+ if (method === "copy") {
1455
+ await client.queryRaw(INSERT_OBJECT, [
1456
+ target,
1457
+ name,
1458
+ owner,
1459
+ active.targetUserId,
1460
+ stamp
1461
+ ]);
1462
+ return null;
1463
+ }
1464
+ const [moved] = await client.queryRaw(MOVE_OBJECT, [
1465
+ bucket,
1466
+ source,
1467
+ target,
1468
+ name,
1469
+ owner,
1470
+ active.targetUserId
1471
+ ]);
1472
+ return moved ? null : NOT_FOUND;
1473
+ });
1474
+ if (refused) return failed(refused);
1475
+ const reply = await admin()[method](source, name, destination);
1476
+ if (reply.error) return reply;
1477
+ try {
1478
+ await (method === "copy" ? ownerSql.queryRaw(OWN_COPY, [
1479
+ target,
1480
+ name,
1481
+ owner,
1482
+ active.targetUserId,
1483
+ stamp
1484
+ ]) : ownerSql.queryRaw(OWN_MOVE, [
1485
+ target,
1486
+ name,
1487
+ owner,
1488
+ active.targetUserId,
1489
+ stamp,
1490
+ previousOwner
1491
+ ]));
1492
+ } catch (cause) {
1493
+ const written = options.admin.from(target);
1494
+ await (method === "copy" ? written.remove([name]) : written.move(name, source, { destinationBucket: bucket }));
1495
+ return failed(sqlFailure(cause));
1496
+ }
1497
+ return reply;
1498
+ });
1499
+ };
1500
+ const remove = (paths) => {
1501
+ if (!writer) return refuse();
1502
+ return settled(async () => {
1503
+ const entries = paths.map((entry) => typeof entry === "string" ? normalizePath(entry) : {
1504
+ ...entry,
1505
+ path: normalizePath(entry.path)
1506
+ });
1507
+ const names = entries.map((entry) => typeof entry === "string" ? entry : entry.path);
1508
+ const removable = /* @__PURE__ */ new Set();
1509
+ const refused = await rehearse(async (client) => {
1510
+ await client.queryRaw(ALLOW_DELETE);
1511
+ const deleted = await client.queryRaw(DELETE_OBJECTS, [bucket, [...new Set(names)]]);
1512
+ for (const row of deleted) removable.add(String(row["name"]));
1513
+ return null;
1514
+ });
1515
+ if (refused) return failed(refused);
1516
+ const permitted = entries.filter((_, index) => removable.has(names[index] ?? ""));
1517
+ if (permitted.length === 0) return {
1518
+ data: [],
1519
+ error: null
1520
+ };
1521
+ return admin().remove(permitted);
1522
+ });
1523
+ };
1524
+ return {
1525
+ exists: (path) => settled(async () => ({
1526
+ data: await visible(normalizePath(path)),
1527
+ error: null
1528
+ })).then((reply) => reply.error === null ? reply : {
1529
+ data: false,
1530
+ error: reply.error
1531
+ }),
1532
+ info: (path, infoOptions) => settled(async () => {
1533
+ const versionId = infoOptions?.versionId;
1534
+ const name = normalizePath(path);
1535
+ const [row] = await rows(versionId === void 0 ? OBJECT_INFO : `${OBJECT_INFO} and o.version = $3`, versionId === void 0 ? [bucket, name] : [
1536
+ bucket,
1537
+ name,
1538
+ versionId
1539
+ ]);
1540
+ const object = row?.["object"];
1541
+ return isRecord(object) ? {
1542
+ data: infoOf(object),
1543
+ error: null
1544
+ } : failed(NOT_FOUND);
1545
+ }),
1546
+ download: (path, downloadOptions, parameters) => checked(path, (name) => admin().download(name, downloadOptions, parameters)),
1547
+ createSignedUrl: (path, expiresIn, urlOptions) => checked(path, (name) => admin().createSignedUrl(name, expiresIn, urlOptions)),
1548
+ createSignedUrls: (paths, expiresIn, urlOptions) => settled(async () => {
1549
+ const names = paths.map(normalizePath);
1550
+ const seen = new Set((await rows(VISIBLE_OBJECTS, [bucket, names])).map((row) => String(row["path"])));
1551
+ const shown = [...new Set(names.filter((name) => seen.has(name)))];
1552
+ const signed = /* @__PURE__ */ new Map();
1553
+ if (shown.length > 0) {
1554
+ const reply = await admin().createSignedUrls(shown, expiresIn, urlOptions);
1555
+ if (reply.error) return failed(reply.error);
1556
+ for (const entry of reply.data) if (entry.path !== null) signed.set(entry.path, entry);
1557
+ }
1558
+ return {
1559
+ data: names.map((name) => signed.get(name) ?? {
1560
+ error: HIDDEN_URL,
1561
+ path: name,
1562
+ signedUrl: null
1563
+ }),
1564
+ error: null
1565
+ };
1566
+ }),
1567
+ getPublicUrl: (path, urlOptions) => admin().getPublicUrl(path, urlOptions),
1568
+ list,
1569
+ listV2,
1570
+ upload: store("upload"),
1571
+ update: store("update"),
1572
+ createSignedUploadUrl,
1573
+ uploadToSignedUrl,
1574
+ remove,
1575
+ copy: relocate("copy"),
1576
+ move: relocate("move"),
1577
+ purgeCache: (path, cacheOptions, parameters) => writer ? checked(path, (name) => admin().purgeCache(name, cacheOptions, parameters)) : refuse()
1578
+ };
1579
+ }
1580
+ };
1581
+ }
1582
+ // src/server/server.ts
1583
+ /** The header `better_supabase.acting_member()` reads for a service caller. */
1584
+ const ACTOR_HEADER = "x-bsb-actor";
1585
+ const APPROVAL_PATTERN = /^[A-Za-z0-9._:;,@/+=-]{1,256}$/;
1586
+ /** The environment as `getEnv` resolves it, one variable at a time. */
1587
+ const RUNTIME_ENV = new Proxy({}, { get: (_target, key) => typeof key === "string" ? getEnv(key) : void 0 });
1588
+ /**
1589
+ * `options.env` as given when it is loaded already, parsed when it is a
1590
+ * variable map (never merged with the runtime's), else the runtime's.
1591
+ */
1592
+ function envOf(env) {
1593
+ if (env === void 0) return loadEnv(RUNTIME_ENV);
1594
+ return isLoadedEnv(env) ? env : loadEnv(env);
1595
+ }
1596
+ /**
1597
+ * An `EnvSource` holds only strings, so a `URL` in `jwksUrl` means a loaded
1598
+ * env.
1599
+ */
1600
+ function isLoadedEnv(env) {
1601
+ return env.jwksUrl instanceof URL;
1602
+ }
1603
+ const needsPostgres = (method) => dbError("invalid_request", `${method} needs createServer(betterSupabase, { postgres: createPostgres() })`);
1604
+ /**
1605
+ * A framework adapter's server: `server` plus the adapter's own methods,
1606
+ * without reading the lazy `env` getter. `extra` can't replace a `BetterServer`
1607
+ * method.
1608
+ */
1609
+ function extendServer(server, extra) {
1610
+ const extended = Object.defineProperties({}, {
1611
+ ...Object.getOwnPropertyDescriptors(server),
1612
+ ...Object.getOwnPropertyDescriptors(extra)
1613
+ });
1614
+ shareCore(server, extended);
1615
+ return extended;
1616
+ }
1617
+ /**
1618
+ * Server-side entry point for APIs, jobs, MCP servers and framework adapters.
1619
+ * Holds the secrets; `betterSupabase` stays isomorphic.
1620
+ */
1621
+ function createServer(betterSupabase, options = {}) {
1622
+ const credentials = options.credentials === void 0 ? {} : { credentials: credentialProviderOf(options.credentials) };
1623
+ let loaded;
1624
+ const env = () => loaded ??= envOf(options.env);
1625
+ const lite = liteBackend(options, env);
1626
+ if (lite === void 0 && (options.prefetchJwks ?? defaultPrefetchJwks()) && options.auth?.jwks === void 0) try {
1627
+ prefetchJwks({
1628
+ ...options.auth,
1629
+ env: env()
1630
+ });
1631
+ } catch {}
1632
+ const { executorOptions, tunedExecutor, serviceClient, readUrl, apiKeyClient, supabaseFor, restAt } = createClients({
1633
+ options,
1634
+ env,
1635
+ definitionExecutor: betterSupabase.executorOptions(),
1636
+ lite,
1637
+ createClient
1638
+ });
1639
+ /** `$client` stays the full Supabase client, built when first read. */
1640
+ const withLazyClient = (db, client) => Object.defineProperty(db, "$client", {
1641
+ get: client,
1642
+ enumerable: true,
1643
+ configurable: true
1644
+ });
1645
+ const dbFor = (auth, context = {}) => {
1646
+ let supabase;
1647
+ const rest = restAt(env().url, auth);
1648
+ const storage = { from: (bucket) => (supabase ??= supabaseFor(auth)).storage.from(bucket) };
1649
+ const db = betterSupabase.connect(rest, {
1650
+ ...authContext(auth),
1651
+ ...context
1652
+ }, auth.kind === "invalid" ? {
1653
+ executor: refusingExecutor(auth.error),
1654
+ storage
1655
+ } : tunedExecutor ? {
1656
+ executor: postgrestExecutor(rest, executorOptions),
1657
+ storage
1658
+ } : { storage });
1659
+ return withLazyClient(db, () => supabase ??= supabaseFor(auth));
1660
+ };
1661
+ const sqlFor = (claims, context, stats, session, storage) => {
1662
+ if (!options.postgres) throw new TypeError("Direct Postgres access needs createServer(betterSupabase, { postgres: createPostgres() })");
1663
+ return betterSupabase.connect(session ? options.postgres.executorFor(claims, session) : options.postgres.executorFor(claims), context, {
1664
+ ...stats ? { stats } : {},
1665
+ ...storage ? { storage } : {}
1666
+ });
1667
+ };
1668
+ /** `ServerOptions.tenant` outside `context()`, where it can't be awaited. */
1669
+ const syncTenant = (request, auth) => {
1670
+ const tenant = options.tenant?.(request, auth);
1671
+ if (tenant !== void 0 && typeof tenant !== "string") throw new TypeError("ServerOptions.tenant returned a promise: use context(request), or pass { tenant } to contextFromResolution");
1672
+ return tenant;
1673
+ };
1674
+ const pinMs = options.replicas?.pinMs ?? 5e3;
1675
+ const idPolicy = requestIdPolicy(options.requestIds);
1676
+ const approvalHeader = options.approval?.header?.toLowerCase();
1677
+ /**
1678
+ * The request ids, and the approval id from `contextOptions.approval` or the
1679
+ * configured header. Without `ServerOptions.approval.header` no header is
1680
+ * read.
1681
+ */
1682
+ const scopeIds = (request, contextOptions) => {
1683
+ const approval = contextOptions.approval ?? (approvalHeader && request ? request.headers.get(approvalHeader) ?? void 0 : void 0);
1684
+ return {
1685
+ ...idPolicy.forRequest(request, contextOptions),
1686
+ ...approval !== void 0 && APPROVAL_PATTERN.test(approval) ? { approval } : {}
1687
+ };
1688
+ };
1689
+ if (options.support && !options.postgres) throw new TypeError("Support sessions need createServer(betterSupabase, { postgres: createPostgres(), support })");
1690
+ const hooksProblem = options.authorization === void 0 ? void 0 : hooksApiProblem(options.authorization);
1691
+ if (hooksProblem !== void 0) throw new TypeError(hooksProblem);
1692
+ const audit = serverAudit(betterSupabase, options.audit);
1693
+ const support = options.support ? options.support.create(betterSupabase.events, options.auth?.claims ?? betterSupabase.claimsSchema, betterSupabase.temporal, options.authorization) : supportOff;
1694
+ /**
1695
+ * The authorization scope of one context: its memo and the request id every
1696
+ * check in the scope shares.
1697
+ */
1698
+ const authzScope = (ids) => ({
1699
+ memo: requestMemo(),
1700
+ ...ids.requestId === void 0 ? {} : { requestId: ids.requestId },
1701
+ ...ids.approval === void 0 ? {} : { approval: ids.approval }
1702
+ });
1703
+ /**
1704
+ * The target's context in a support session. Queries run over direct Postgres
1705
+ * with the target's claims plus `act`, read-only unless the session allows
1706
+ * writes; nothing reaches Supabase with the admin's token.
1707
+ */
1708
+ const supportContextFor = (resolution, active, parent, tenant, ids) => {
1709
+ const { session, claims } = active;
1710
+ const record = (key) => {
1711
+ const value = claims[key];
1712
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? Object.fromEntries(Object.entries(value)) : void 0;
1713
+ };
1714
+ const appMetadata = record("app_metadata");
1715
+ const userMetadata = record("user_metadata");
1716
+ const user = {
1717
+ id: session.targetUserId,
1718
+ role: typeof claims["role"] === "string" ? claims["role"] : "authenticated",
1719
+ ...typeof claims["email"] === "string" ? { email: claims["email"] } : {},
1720
+ ...appMetadata ? { appMetadata } : {},
1721
+ ...userMetadata ? { userMetadata } : {}
1722
+ };
1723
+ const auth = {
1724
+ kind: "user",
1725
+ token: "",
1726
+ claims,
1727
+ user,
1728
+ source: "support",
1729
+ expiresAt: Math.floor(session.expiresAt.epochMilliseconds / 1e3)
1730
+ };
1731
+ const scope = tenant ?? session.tenant;
1732
+ const base = userContext(user, claims);
1733
+ const authz = authzScope(ids);
1734
+ const context = {
1735
+ ...base,
1736
+ ...scope === void 0 ? {} : { tenant: scope },
1737
+ ...authz
1738
+ };
1739
+ const sessionOptions = sessionWith(ids, scope, session.readOnly);
1740
+ const recorder = new StatsRecorder(parent);
1741
+ const sqlClaims = claims;
1742
+ const unavailable = () => {
1743
+ throw new TypeError("ctx.supabase and ctx.db.$client are not available in a support session; ctx.db and ctx.sql run as the target");
1744
+ };
1745
+ let db;
1746
+ let sql;
1747
+ let storage;
1748
+ const targetStorage = () => {
1749
+ const postgres = options.postgres;
1750
+ if (!postgres) throw new TypeError("Support sessions need createServer(betterSupabase, { postgres: createPostgres(), support })");
1751
+ let asTarget;
1752
+ const target = () => asTarget ??= postgres.asUser(sqlClaims, sessionOptions);
1753
+ storage ??= supportStorage({
1754
+ admin: { from: (bucket) => serviceClient().storage.from(bucket) },
1755
+ sql: {
1756
+ queryRaw: (text, params) => target().queryRaw(text, params),
1757
+ transaction: (fn) => target().transaction?.(fn) ?? Promise.reject(/* @__PURE__ */ new TypeError("The target's SQL client has no transaction"))
1758
+ },
1759
+ adminSql: postgres.admin,
1760
+ session,
1761
+ readOnly: session.readOnly
1762
+ });
1763
+ return storage;
1764
+ };
1765
+ return {
1766
+ ...credentials,
1767
+ ...ids,
1768
+ memo: authz.memo,
1769
+ auth,
1770
+ resolution,
1771
+ support: active,
1772
+ get storage() {
1773
+ return targetStorage();
1774
+ },
1775
+ get supabase() {
1776
+ return unavailable();
1777
+ },
1778
+ get db() {
1779
+ db ??= Object.defineProperty(sqlFor(sqlClaims, context, recorder, sessionOptions, targetStorage()), "$client", {
1780
+ get: unavailable,
1781
+ enumerable: true,
1782
+ configurable: true
1783
+ });
1784
+ return db;
1785
+ },
1786
+ get sql() {
1787
+ sql ??= sqlFor(sqlClaims, context, recorder, sessionOptions, targetStorage());
1788
+ return sql;
1789
+ },
1790
+ replica: void 0,
1791
+ stats: () => recorder.snapshot(),
1792
+ apply: (response) => resolution.apply(response),
1793
+ cookies: () => resolution.cookies
1794
+ };
1795
+ };
1796
+ /**
1797
+ * An API key's context. There is no JWT for PostgREST, so `ctx.db` and
1798
+ * `ctx.sql` run over direct Postgres with the key's synthesized claims,
1799
+ * scoped to its organization unless the tenant option names another.
1800
+ */
1801
+ const apiKeyContextFor = (resolution, auth, parent, tenant, ids) => {
1802
+ const scope = tenant ?? auth.organizationId;
1803
+ const base = authContext(auth);
1804
+ const authz = authzScope(ids);
1805
+ const context = {
1806
+ ...base,
1807
+ ...scope === void 0 ? {} : { tenant: scope },
1808
+ ...authz
1809
+ };
1810
+ const session = sessionWith(ids, scope);
1811
+ const recorder = new StatsRecorder(parent);
1812
+ let db;
1813
+ let sql;
1814
+ return {
1815
+ ...credentials,
1816
+ ...ids,
1817
+ memo: authz.memo,
1818
+ auth: resolution.auth,
1819
+ resolution,
1820
+ get supabase() {
1821
+ return apiKeyClient();
1822
+ },
1823
+ get db() {
1824
+ db ??= Object.defineProperty(sqlFor(auth.claims, context, recorder, session), "$client", {
1825
+ get: apiKeyClient,
1826
+ enumerable: true,
1827
+ configurable: true
1828
+ });
1829
+ return db;
1830
+ },
1831
+ get sql() {
1832
+ sql ??= sqlFor(auth.claims, context, recorder, session);
1833
+ return sql;
1834
+ },
1835
+ replica: void 0,
1836
+ stats: () => recorder.snapshot(),
1837
+ apply: (response) => resolution.apply(response),
1838
+ cookies: () => resolution.cookies
1839
+ };
1840
+ };
1841
+ /**
1842
+ * Clients and repositories are built on first access: most scopes use one of
1843
+ * them.
1844
+ */
1845
+ const contextFor = (resolution, requestHeaders, parent, until = 0, tenant, active, ids = {}) => {
1846
+ if (active) return supportContextFor(resolution, active, parent, tenant, ids);
1847
+ const { auth } = resolution;
1848
+ if (auth.kind === "apiKey") return apiKeyContextFor(resolution, auth, parent, tenant, ids);
1849
+ const authz = authzScope(ids);
1850
+ const context = {
1851
+ ...authContext(auth),
1852
+ ...tenant === void 0 ? {} : { tenant },
1853
+ ...authz
1854
+ };
1855
+ const clientHeaders = tenant === void 0 ? requestHeaders : {
1856
+ ...requestHeaders,
1857
+ [TENANT_HEADER]: tenant
1858
+ };
1859
+ const headers = {
1860
+ ...idPolicy.headers(ids),
1861
+ ...clientHeaders
1862
+ };
1863
+ const sharesClient = auth.kind !== "user";
1864
+ const session = sessionWith(ids, tenant);
1865
+ const recorder = new StatsRecorder(parent);
1866
+ let supabase;
1867
+ let db;
1868
+ let sql;
1869
+ const sqlClaims = auth.kind === "user" ? auth.claims : auth.kind === "none" ? { role: "anon" } : void 0;
1870
+ const client = () => supabase ??= supabaseFor(auth, sharesClient ? clientHeaders : headers);
1871
+ let replica;
1872
+ const replicaUrl = () => {
1873
+ const url = readUrl();
1874
+ if (url) replica ??= replicaState(until);
1875
+ return url;
1876
+ };
1877
+ return {
1878
+ ...credentials,
1879
+ ...ids,
1880
+ memo: authz.memo,
1881
+ auth,
1882
+ resolution,
1883
+ get supabase() {
1884
+ return client();
1885
+ },
1886
+ get db() {
1887
+ if (db) return db;
1888
+ const url = replicaUrl();
1889
+ const rest = (sharesClient ? void 0 : supabase) ?? restAt(env().url, auth, headers);
1890
+ const connected = betterSupabase.connect(rest, context, {
1891
+ stats: recorder,
1892
+ storage: { from: (bucket) => client().storage.from(bucket) },
1893
+ ...auth.kind === "invalid" ? { executor: refusingExecutor(auth.error) } : url && replica ? { executor: routedExecutor(postgrestExecutor(rest, executorOptions), postgrestExecutor(restAt(url, auth, headers), executorOptions), replica) } : tunedExecutor ? { executor: postgrestExecutor(rest, executorOptions) } : {}
1894
+ });
1895
+ db = withLazyClient(connected, client);
1896
+ return db;
1897
+ },
1898
+ get replica() {
1899
+ replicaUrl();
1900
+ return replica;
1901
+ },
1902
+ get sql() {
1903
+ if (!options.postgres || !sqlClaims) return;
1904
+ sql ??= sqlFor(sqlClaims, context, recorder, session);
1905
+ return sql;
1906
+ },
1907
+ stats: () => recorder.snapshot(),
1908
+ apply: (response) => withPrimaryPin(resolution.apply(response), replica, pinMs),
1909
+ cookies: () => {
1910
+ const pin = primaryCookieWrite(replica, pinMs);
1911
+ return pin ? [...resolution.cookies, pin] : resolution.cookies;
1912
+ }
1913
+ };
1914
+ };
1915
+ const fromResolution = (resolution, request, contextOptions, tenant) => contextFor(resolution, options.headers?.(request) ?? {}, contextOptions.stats, contextOptions.pinnedUntil ?? (readUrl() ? pinnedUntil(resolution.requestCookies) : 0), tenant, contextOptions.support, scopeIds(request, contextOptions));
1916
+ const resolve = async (request, resolveOptions = {}) => {
1917
+ const claims = options.auth?.claims ?? betterSupabase.claimsSchema;
1918
+ const userMetadata = betterSupabase.userMetadataSchema;
1919
+ const resolution = await resolveAuth(request, {
1920
+ logger: betterSupabase.events.logger,
1921
+ ...lite ? lite.auth() : options.auth,
1922
+ ...claims ? { claims } : {},
1923
+ ...userMetadata ? { userMetadata } : {},
1924
+ env: env(),
1925
+ ...resolveOptions.refresh === void 0 ? {} : { refresh: resolveOptions.refresh },
1926
+ ...resolveOptions.cookies === void 0 ? {} : { cookies: resolveOptions.cookies },
1927
+ ...resolveOptions.verifySession ? { verifySession: true } : {},
1928
+ ...resolveOptions.leeway === void 0 ? {} : { leeway: resolveOptions.leeway },
1929
+ ...resolveOptions.onTiming ? { onTiming: resolveOptions.onTiming } : {},
1930
+ ...resolveOptions.encode === void 0 ? {} : { cookie: {
1931
+ ...options.auth?.cookie,
1932
+ encode: resolveOptions.encode
1933
+ } },
1934
+ onRefresh: (event) => {
1935
+ options.auth?.onRefresh?.(event);
1936
+ betterSupabase.events.emit("refresh", event);
1937
+ }
1938
+ });
1939
+ if (betterSupabase.events.has("auth")) {
1940
+ const { auth } = resolution;
1941
+ betterSupabase.events.emit("auth", {
1942
+ source: auth.kind === "user" ? auth.source === "cookie" ? "cookie" : "bearer" : auth.kind === "secret" || auth.kind === "apiKey" ? "bearer" : "none",
1943
+ ok: auth.kind !== "invalid",
1944
+ ...auth.kind === "user" ? {
1945
+ userId: auth.user.id,
1946
+ rawSource: auth.source
1947
+ } : {},
1948
+ ...auth.kind === "none" || auth.kind === "invalid" ? { reason: auth.reason } : {}
1949
+ });
1950
+ }
1951
+ return resolution;
1952
+ };
1953
+ /**
1954
+ * One context per request and `refresh`/`cookies` pair: Server Components ask
1955
+ * repeatedly.
1956
+ */
1957
+ const contextMemo = /* @__PURE__ */ new WeakMap();
1958
+ const authorizer = bindAuthorizer(options.authorizer, options.versions ? { versions: options.versions } : {});
1959
+ const custom = lite !== void 0 || (options.auth?.resolvers?.length ?? 0) > 0;
1960
+ const { snapshot, contextFromSession, sessions, evictSession } = serverSessions({
1961
+ resolve,
1962
+ cookieName: () => options.auth?.cookie?.name ?? sessionCookieName(env().url),
1963
+ cookies: options.auth?.cookies !== false,
1964
+ custom,
1965
+ memo: options.sessions,
1966
+ versions: options.versions,
1967
+ contextFor: (auth, contextOptions) => contextFor({
1968
+ auth,
1969
+ cookies: [],
1970
+ headers: {},
1971
+ requestCookies: [],
1972
+ apply: (response) => response
1973
+ }, {}, contextOptions.stats, contextOptions.pinnedUntil, contextOptions.tenant, contextOptions.support, scopeIds(void 0, contextOptions))
1974
+ });
1975
+ const server = {
1976
+ get env() {
1977
+ return env();
1978
+ },
1979
+ events: betterSupabase.events,
1980
+ authorizer,
1981
+ authorization: options.authorization,
1982
+ versions: options.versions,
1983
+ snapshot,
1984
+ contextFromSession,
1985
+ sessions,
1986
+ evictSession,
1987
+ resolve,
1988
+ supabaseFor,
1989
+ dbFor: (auth, context, dbOptions) => dbOptions?.support ? supportContextFor({
1990
+ auth,
1991
+ cookies: [],
1992
+ headers: {},
1993
+ requestCookies: [],
1994
+ apply: (response) => response
1995
+ }, dbOptions.support, void 0, context?.tenant, {}).db : dbFor(auth, context),
1996
+ contextFor: (auth, contextOptions = {}) => contextFor({
1997
+ auth,
1998
+ cookies: [],
1999
+ headers: {},
2000
+ requestCookies: [],
2001
+ apply: (response) => response
2002
+ }, {}, contextOptions.stats, contextOptions.pinnedUntil, contextOptions.tenant, contextOptions.support, scopeIds(void 0, contextOptions)),
2003
+ context(request, contextOptions = {}) {
2004
+ const { refresh, cookies, ...rest } = contextOptions;
2005
+ const key = Object.keys(rest).length === 0 ? `${String(refresh ?? false)}:${String(cookies ?? true)}` : void 0;
2006
+ let byOptions = key ? contextMemo.get(request) : void 0;
2007
+ const known = key ? byOptions?.get(key) : void 0;
2008
+ if (known) return known;
2009
+ const resolving = (async () => {
2010
+ const call = { options: contextOptions };
2011
+ await fold(request, {
2012
+ ...seedContext(),
2013
+ [CALL]: call
2014
+ });
2015
+ return call.context;
2016
+ })();
2017
+ if (key) {
2018
+ if (!byOptions) {
2019
+ byOptions = /* @__PURE__ */ new Map();
2020
+ contextMemo.set(request, byOptions);
2021
+ }
2022
+ const memo = byOptions;
2023
+ memo.set(key, resolving);
2024
+ resolving.catch(() => {
2025
+ if (memo.get(key) === resolving) memo.delete(key);
2026
+ });
2027
+ }
2028
+ return resolving;
2029
+ },
2030
+ contextFromResolution: (resolution, request, contextOptions = {}) => fromResolution(resolution, request, contextOptions, contextOptions.tenant ?? syncTenant(request, resolution.auth)),
2031
+ admin: (context = {}, adminOptions = {}) => {
2032
+ const client = adminOptions.as === void 0 ? serviceClient() : supabaseFor({
2033
+ kind: "secret",
2034
+ keyName: "secret"
2035
+ }, { [ACTOR_HEADER]: adminOptions.as });
2036
+ const db = betterSupabase.connect(client, {
2037
+ actor: {
2038
+ id: "service",
2039
+ kind: "service",
2040
+ role: "service_role"
2041
+ },
2042
+ claims: { role: "service_role" },
2043
+ ...context
2044
+ }, tunedExecutor ? { executor: postgrestExecutor(client, executorOptions) } : {});
2045
+ return Object.defineProperty(db, "$authAdmin", { get: () => client.auth.admin });
2046
+ },
2047
+ support,
2048
+ deleteAccount: (userId, deleteOptions) => deleteAccount(betterSupabase, serviceClient, userId, {
2049
+ ...options.postgres ? { sql: options.postgres.admin } : {},
2050
+ ...deleteOptions
2051
+ }).map((deleted) => {
2052
+ audit.account("account.deleted", userId, { removed: deleted.removed });
2053
+ return deleted;
2054
+ }),
2055
+ endSessions: (userId) => options.postgres ? endSessions(options.postgres.admin, userId).map((ended) => {
2056
+ audit.account("account.sessions_ended", userId, { ended: ended.ended });
2057
+ return ended;
2058
+ }) : AsyncResult.err(needsPostgres("endSessions")),
2059
+ suspendAccount: (userId, suspendOptions) => options.postgres ? suspendAccount(serviceClient, options.postgres.admin, userId, suspendOptions).map((suspended) => {
2060
+ audit.account(suspended.suspended ? "account.suspended" : "account.unsuspended", userId, {
2061
+ ended: suspended.ended,
2062
+ ...suspendOptions.duration === void 0 ? {} : { duration: suspendOptions.duration }
2063
+ });
2064
+ return suspended;
2065
+ }) : AsyncResult.err(needsPostgres("suspendAccount")),
2066
+ actingAs: (userId, claims = {}, impersonation) => {
2067
+ const full = {
2068
+ role: "authenticated",
2069
+ ...claims,
2070
+ sub: userId,
2071
+ ...impersonation ? { act: actClaim(impersonation) } : {}
2072
+ };
2073
+ return sqlFor(full, {
2074
+ actor: {
2075
+ id: userId,
2076
+ kind: "user",
2077
+ role: full.role ?? "authenticated",
2078
+ ...impersonation ? { impersonator: impersonation.actor } : {}
2079
+ },
2080
+ claims: full
2081
+ });
2082
+ },
2083
+ forContext: (context, forOptions = {}) => AsyncResult.from(async () => {
2084
+ const subject = await ticketSubject(context, forOptions.ticket ?? options.authorization?.tickets?.subject);
2085
+ if (!subject.ok) return subject;
2086
+ const target = subject.data;
2087
+ const { tenant } = target;
2088
+ const checked = contextClaims(target);
2089
+ if (!checked.ok) return err(dbError("forbidden", checked.message));
2090
+ if (!options.postgres) return err(dbError("invalid_request", "Direct Postgres access needs createServer(betterSupabase, { postgres: createPostgres() })"));
2091
+ const userId = checked.claims.sub;
2092
+ const extra = await options.claimsFor?.(userId, target) ?? {};
2093
+ const permissions = narrowCap(await delegationCap(target, userId, options.authorization?.delegation?.permissions), forOptions.permissions);
2094
+ const built = contextClaims(target, {
2095
+ extra,
2096
+ ...forOptions.reason === void 0 ? {} : { reason: forOptions.reason },
2097
+ ...permissions === void 0 ? {} : { permissions }
2098
+ });
2099
+ if (!built.ok) return err(dbError("forbidden", built.message));
2100
+ const { claims, impersonator, readOnly } = built;
2101
+ const session = sessionWith({}, tenant, readOnly);
2102
+ return ok(sqlFor(claims, {
2103
+ actor: {
2104
+ id: userId,
2105
+ kind: "user",
2106
+ role: "authenticated",
2107
+ ...impersonator ? { impersonator } : {}
2108
+ },
2109
+ claims,
2110
+ ...tenant === void 0 ? {} : { tenant }
2111
+ }, void 0, session));
2112
+ })
2113
+ };
2114
+ const core = {
2115
+ events: betterSupabase.events,
2116
+ pinMs,
2117
+ resolve,
2118
+ sessionCookie: () => options.auth?.cookie?.name ?? sessionCookieName(env().url),
2119
+ tenant: (request, auth) => options.tenant?.(request, auth),
2120
+ support: (request, auth) => support.current(request, auth),
2121
+ context: (resolution, request, contextOptions, tenant) => fromResolution(resolution, request, contextOptions, tenant)
2122
+ };
2123
+ registerCore(server, core);
2124
+ const fold = pipeline([
2125
+ withSession(core),
2126
+ withTenant(core),
2127
+ withSupport(core),
2128
+ withServerContext(core)
2129
+ ], (_request, ctx) => {
2130
+ const call = callOf(ctx);
2131
+ if (call) call.context = ctx.bsb;
2132
+ return Promise.resolve(new Response(null, { status: 204 }));
2133
+ });
2134
+ return server;
2135
+ }
2136
+ /**
2137
+ * The permission keys the provider's `delegation.permissions` hook grants a
2138
+ * delegated context, `undefined` for a context that is not delegated or without
2139
+ * the hook. A throw or an answer that is not a list of strings grants nothing.
2140
+ */
2141
+ async function delegationCap(context, userId, permissions) {
2142
+ if (permissions === void 0) return;
2143
+ const delegated = delegatedClaims(context.claims ?? {});
2144
+ if (!delegated.ok || delegated.delegation === void 0) return;
2145
+ const { client_id, scope, authorization_details } = delegated.delegation;
2146
+ try {
2147
+ const keys = await permissions({
2148
+ userId,
2149
+ ...context.tenant === void 0 ? {} : { tenant: context.tenant },
2150
+ ...client_id === void 0 ? {} : { clientId: client_id },
2151
+ scopes: scope === void 0 ? [] : scope.split(" "),
2152
+ ...authorization_details === void 0 ? {} : { authorizationDetails: authorization_details }
2153
+ });
2154
+ return Array.isArray(keys) && keys.every((key) => typeof key === "string") ? keys : [];
2155
+ } catch {
2156
+ return [];
2157
+ }
2158
+ }
2159
+ /**
2160
+ * The context `forContext` runs as: `context` itself, or for a context with a
2161
+ * ticket, the context `resolve` returns for it. A ticket without a resolver, a
2162
+ * `null` answer and a throw are `forbidden`; none of them fall back to the
2163
+ * recorded actor.
2164
+ */
2165
+ async function ticketSubject(context, resolve) {
2166
+ const ticket = context["ticket"];
2167
+ if (ticket === void 0) return ok(context);
2168
+ if (typeof ticket !== "string" || ticket === "") return err(dbError("forbidden", "forContext got an invalid ticket"));
2169
+ if (resolve === void 0) return err(dbError("forbidden", "forContext got a ticket but no ticket resolver: pass { ticket } or authorization.tickets.subject"));
2170
+ let resolved;
2171
+ try {
2172
+ resolved = await resolve(ticket);
2173
+ } catch {
2174
+ resolved = null;
2175
+ }
2176
+ if (typeof resolved !== "object" || resolved === null) return err(dbError("forbidden", "The ticket resolver refused the ticket"));
2177
+ return ok(resolved);
2178
+ }
2179
+ // src/server/adapter.ts
2180
+ /** Hands event sink sends still running to `waitUntil`; a no-op without either. */
2181
+ function flushEvents(server, waitUntil) {
2182
+ if (waitUntil && server.events.pending) waitUntil(server.events.settled());
2183
+ }
2184
+ /**
2185
+ * Runs `run`, then hands pending event sink sends to `waitUntil` even when it
2186
+ * throws.
2187
+ */
2188
+ async function withFlush(server, waitUntil, run) {
2189
+ try {
2190
+ return await run();
2191
+ } finally {
2192
+ flushEvents(server, waitUntil);
2193
+ }
2194
+ }
2195
+ /** The 500 for an error a handler threw; the message only when `expose` is set. */
2196
+ function unexpectedResponse(cause, options) {
2197
+ return problemResponse(dbError("unexpected", options.expose && cause instanceof Error ? cause.message : "Internal server error"), options);
2198
+ }
2199
+ /**
2200
+ * Runs `run` as the request's caller, the way every built-in adapter does:
2201
+ * resolves the context, applies the guard (401/403 Problem Details), turns the
2202
+ * return value into a response with `respond()`, turns other thrown errors into
2203
+ * a 500, adds the context's cookies with `ctx.apply()` and hands pending event
2204
+ * sink sends to `waitUntil`.
2205
+ *
2206
+ * ```ts
2207
+ * export default {
2208
+ * fetch: (request, env, ctx) =>
2209
+ * handle(server, request, (c) => c.db.notes.list(), {
2210
+ * waitUntil: (p) => ctx.waitUntil(p),
2211
+ * }),
2212
+ * };
2213
+ * ```
2214
+ */
2215
+ async function handle(server, request, run, options = {}) {
2216
+ const expose = options.expose ?? defaultExpose();
2217
+ const instance = options.instance ?? new URL(request.url).pathname;
2218
+ assertCookieRefresh(options);
2219
+ const ctx = await server.context(request, {
2220
+ ...options.context,
2221
+ ...options.cookies === void 0 ? {} : { cookies: options.cookies },
2222
+ refresh: refreshFor(options.refresh, request) ?? false
2223
+ });
2224
+ const denied = guard(ctx.auth, options.allow, options.aal, options.scopes);
2225
+ try {
2226
+ let response;
2227
+ try {
2228
+ response = denied ? problemResponse(denied, {
2229
+ instance,
2230
+ expose
2231
+ }) : await respond(() => run(ctx), {
2232
+ instance,
2233
+ expose,
2234
+ ...options.status === void 0 ? {} : { status: options.status }
2235
+ });
2236
+ } catch (cause) {
2237
+ options.rethrow?.(cause);
2238
+ response = unexpectedResponse(cause, {
2239
+ instance,
2240
+ expose
2241
+ });
2242
+ }
2243
+ return ctx.apply(response);
2244
+ } finally {
2245
+ flushEvents(server, options.waitUntil);
2246
+ }
2247
+ }
2248
+ /** A request carrying only `token` as a bearer, for resolvers that read headers. */
2249
+ function bearerRequest(token) {
2250
+ return new Request("http://localhost/", { headers: token ? { authorization: `Bearer ${token}` } : {} });
2251
+ }
2252
+ /**
2253
+ * Verifies a bare access token (an MCP transport's, a WebSocket's) without
2254
+ * cookies or a refresh. An empty token resolves to `anon`.
2255
+ */
2256
+ async function resolveToken(server, token) {
2257
+ const { auth } = await server.resolve(bearerRequest(token), { cookies: false });
2258
+ return auth;
2259
+ }
2260
+ export { SERVER_EVENT_SOURCE as C, deleteAccount as D, suspendAccount as E, defineAuthorizationHooks as S, lastSignIns as T, withSupport as _, unexpectedResponse as a, withServerContext as b, extendServer as c, clearSupportCookie as d, supportCookie as f, withTenant as g, TENANT_HEADER as h, resolveToken as i, supportStorage as l, supportCookieValue as m, flushEvents as n, withFlush as o, supportCookieMaxAge as p, handle as r, createServer as s, bearerRequest as t, SUPPORT_COOKIE as u, outageResponse as v, endSessions as w, serverCore as x, withSession as y };