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