better-supabase 0.31.0 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1703) hide show
  1. package/README.md +11 -10
  2. package/codemods/0.32.json +31 -0
  3. package/dist/access-sql-Dao1C0fz.js +383 -0
  4. package/dist/actor-B5b0i1Fs.js +149 -0
  5. package/dist/actor-DseNR02I.d.ts +104 -0
  6. package/dist/adapter-CWzyKepA.js +2260 -0
  7. package/dist/agents-DXiOPB3V.d.ts +115 -0
  8. package/dist/ai-cache-CLiAXCPH.d.ts +80 -0
  9. package/dist/ai-cache-D9D36eh4.js +86 -0
  10. package/dist/ai-chat-DlcBdOhJ.d.ts +532 -0
  11. package/dist/ai-files-DCMVGSds.js +337 -0
  12. package/dist/ai-message-cnroprVB.js +13 -0
  13. package/dist/ai-schedules-Drx2KRTn.d.ts +164 -0
  14. package/dist/ai-sdk/agents/index.d.ts +8 -12
  15. package/dist/ai-sdk/agents/index.js +10 -12
  16. package/dist/ai-sdk/batches/index.d.ts +12 -7
  17. package/dist/ai-sdk/batches/index.js +16 -9
  18. package/dist/ai-sdk/cache/index.d.ts +2 -4
  19. package/dist/ai-sdk/cache/index.js +3 -4
  20. package/dist/ai-sdk/chat/index.d.ts +77 -2
  21. package/dist/ai-sdk/chat/index.js +179 -28
  22. package/dist/ai-sdk/embeddings/index.d.ts +2 -2
  23. package/dist/ai-sdk/embeddings/index.js +1 -1
  24. package/dist/ai-sdk/files/index.d.ts +3 -5
  25. package/dist/ai-sdk/files/index.js +5 -6
  26. package/dist/ai-sdk/index.d.ts +75 -21
  27. package/dist/ai-sdk/index.js +112 -66
  28. package/dist/ai-sdk/mcp/index.d.ts +28 -13
  29. package/dist/ai-sdk/mcp/index.js +56 -17
  30. package/dist/ai-sdk/memory/index.d.ts +3 -5
  31. package/dist/ai-sdk/memory/index.js +3 -4
  32. package/dist/ai-sdk/react/index.d.ts +2 -2
  33. package/dist/ai-sdk/react/index.js +3 -1
  34. package/dist/ai-sdk/react/server.d.ts +7 -4
  35. package/dist/ai-sdk/react/server.js +10 -3
  36. package/dist/ai-sdk/workflow/index.d.ts +12 -13
  37. package/dist/ai-sdk/workflow/index.js +17 -17
  38. package/dist/ai-sdk/workflow/react/index.d.ts +1 -3
  39. package/dist/ai-sdk/workflow/react/index.js +3 -3
  40. package/dist/ai-sdk/workflow/react/server.d.ts +1 -3
  41. package/dist/ai-sdk/workflow/react/server.js +1 -2
  42. package/dist/anchors-sCLvYj-8.d.ts +36 -0
  43. package/dist/api-keys-DbIbkGxx.d.ts +211 -0
  44. package/dist/api-myq2e9t5.d.ts +482 -0
  45. package/dist/api-wwix_K5c.js +691 -0
  46. package/dist/app-tables-IrglDJCs.d.ts +26 -0
  47. package/dist/approvals-DZoGtNFv.d.ts +127 -0
  48. package/dist/approvals-Da4uAANx.js +166 -0
  49. package/dist/assistant-BEbRPjhn.d.ts +209 -0
  50. package/dist/astro/index.d.ts +7 -10
  51. package/dist/astro/index.js +8 -9
  52. package/dist/attachments-BWtUQgsL.js +375 -0
  53. package/dist/attributes-BZNkR2z2.js +51 -0
  54. package/dist/auth-link-BmJsQG4a.js +117 -0
  55. package/dist/auth-link-DRjtI1Ky.d.ts +102 -0
  56. package/dist/auth-module-CqXdm8qD.js +50 -0
  57. package/dist/auth-reply-BMPJQssh.d.ts +9 -0
  58. package/dist/auth-reply-Cnwn3I_q.js +30 -0
  59. package/dist/auth-wFlGgwTZ.js +19 -0
  60. package/dist/authorization-BlmDNI2b.d.ts +3734 -0
  61. package/dist/authorization-hooks-CxwsRnfV.d.ts +219 -0
  62. package/dist/authorizer-BtIPDO-c.js +194 -0
  63. package/dist/automation-acq3iK9y.js +74 -0
  64. package/dist/automations-BfH8GJqv.js +27 -0
  65. package/dist/automations-Bw5cX7oj.js +29 -0
  66. package/dist/automations-CCc5RUw-.js +31 -0
  67. package/dist/automations-Dou1t3lt.js +313 -0
  68. package/dist/availability-CebEOfMN.d.ts +236 -0
  69. package/dist/base64-CVyKHBBw.js +41 -0
  70. package/dist/batch-limit-DqQ3d6op.js +4 -0
  71. package/dist/before-route-Ra3OhI2x.js +29 -0
  72. package/dist/better-result/index.d.ts +4 -6
  73. package/dist/better-result/index.js +2 -3
  74. package/dist/bind-DP-KLgYI.d.ts +102 -0
  75. package/dist/block-authors-C5z3tGVu.d.ts +10 -0
  76. package/dist/block-authors-DCQ4zl8e.js +13 -0
  77. package/dist/block-env-CJ38ZSTP.d.ts +30 -0
  78. package/dist/block-event-listener-DCi7c89M.js +15 -0
  79. package/dist/block-events-Bp6GPIBN.js +82 -0
  80. package/dist/block-fields-Bjcv6_zc.js +139 -0
  81. package/dist/block-fields-Puv5m5D3.d.ts +56 -0
  82. package/dist/block-helpers-I7UzjNEf.js +435 -0
  83. package/dist/block-helpers-disoUWCp.d.ts +56 -0
  84. package/dist/block-hooks-CadxQ9-_.js +129 -0
  85. package/dist/block-hooks-DrA_d1dJ.d.ts +115 -0
  86. package/dist/block-method-DIbWG4Mj.js +20 -0
  87. package/dist/block-method-QSaPsL2P.d.ts +12 -0
  88. package/dist/block-subjects-Br2MQNFn.d.ts +4 -0
  89. package/dist/block-subjects-cRlVtKDO.js +54 -0
  90. package/dist/block-tables-CQTU71zn.d.ts +34 -0
  91. package/dist/block-tenant-Bun03JuO.js +13 -0
  92. package/dist/block-transport-BEtC_Kis.d.ts +67 -0
  93. package/dist/blocks/access-requests/index.d.ts +9 -15
  94. package/dist/blocks/access-requests/index.js +11 -14
  95. package/dist/blocks/activities/index.d.ts +13 -21
  96. package/dist/blocks/activities/index.js +16 -21
  97. package/dist/blocks/agents/index.d.ts +4 -8
  98. package/dist/blocks/agents/index.js +11 -14
  99. package/dist/blocks/ai-cache/index.d.ts +3 -5
  100. package/dist/blocks/ai-cache/index.js +5 -6
  101. package/dist/blocks/ai-chat/index.d.ts +10 -19
  102. package/dist/blocks/ai-chat/index.js +20 -28
  103. package/dist/blocks/ai-files/index.d.ts +5 -9
  104. package/dist/blocks/ai-files/index.js +5 -6
  105. package/dist/blocks/ai-keys/index.d.ts +4 -10
  106. package/dist/blocks/ai-keys/index.js +14 -18
  107. package/dist/blocks/ai-schedules/index.d.ts +3 -5
  108. package/dist/blocks/ai-schedules/index.js +14 -16
  109. package/dist/blocks/announcements/index.d.ts +12 -20
  110. package/dist/blocks/announcements/index.js +12 -16
  111. package/dist/blocks/api-keys/index.d.ts +4 -116
  112. package/dist/blocks/api-keys/index.js +17 -22
  113. package/dist/blocks/approvals/index.d.ts +4 -8
  114. package/dist/blocks/approvals/index.js +7 -173
  115. package/dist/blocks/assets/index.d.ts +9 -17
  116. package/dist/blocks/assets/index.js +13 -17
  117. package/dist/blocks/assignment/index.d.ts +9 -17
  118. package/dist/blocks/assignment/index.js +10 -14
  119. package/dist/blocks/attachments/index.d.ts +6 -18
  120. package/dist/blocks/attachments/index.js +19 -24
  121. package/dist/blocks/audit/index.d.ts +15 -31
  122. package/dist/blocks/audit/index.js +27 -35
  123. package/dist/blocks/automations/index.d.ts +14 -26
  124. package/dist/blocks/automations/index.js +18 -23
  125. package/dist/blocks/billable-time/index.d.ts +9 -19
  126. package/dist/blocks/billable-time/index.js +15 -20
  127. package/dist/blocks/billing/index.d.ts +12 -22
  128. package/dist/blocks/billing/index.js +19 -24
  129. package/dist/blocks/bookings/index.d.ts +8 -18
  130. package/dist/blocks/bookings/index.js +17 -23
  131. package/dist/blocks/bulk/index.d.ts +6 -12
  132. package/dist/blocks/bulk/index.js +10 -13
  133. package/dist/blocks/calendar/index.d.ts +13 -23
  134. package/dist/blocks/calendar/index.js +35 -32
  135. package/dist/blocks/catalog/index.d.ts +12 -20
  136. package/dist/blocks/catalog/index.js +17 -21
  137. package/dist/blocks/channels/index.d.ts +9 -17
  138. package/dist/blocks/channels/index.js +11 -15
  139. package/dist/blocks/collections/index.d.ts +11 -17
  140. package/dist/blocks/collections/index.js +13 -16
  141. package/dist/blocks/comments/index.d.ts +16 -26
  142. package/dist/blocks/comments/index.js +21 -26
  143. package/dist/blocks/compliance/index.d.ts +9 -17
  144. package/dist/blocks/compliance/index.js +13 -17
  145. package/dist/blocks/connectors/index.d.ts +4 -8
  146. package/dist/blocks/connectors/index.js +13 -16
  147. package/dist/blocks/contacts/index.d.ts +10 -18
  148. package/dist/blocks/contacts/index.js +12 -16
  149. package/dist/blocks/content/index.d.ts +8 -16
  150. package/dist/blocks/content/index.js +13 -17
  151. package/dist/blocks/contracts/index.d.ts +11 -21
  152. package/dist/blocks/contracts/index.js +17 -22
  153. package/dist/blocks/courses/index.d.ts +11 -21
  154. package/dist/blocks/courses/index.js +17 -22
  155. package/dist/blocks/created-by/index.d.ts +3 -7
  156. package/dist/blocks/created-by/index.js +4 -5
  157. package/dist/blocks/custom-fields/index.d.ts +10 -16
  158. package/dist/blocks/custom-fields/index.js +13 -16
  159. package/dist/blocks/data-lifecycle/index.d.ts +10 -26
  160. package/dist/blocks/data-lifecycle/index.js +17 -23
  161. package/dist/blocks/deals/index.d.ts +12 -20
  162. package/dist/blocks/deals/index.js +18 -22
  163. package/dist/blocks/dispatch/index.d.ts +11 -23
  164. package/dist/blocks/dispatch/index.js +19 -24
  165. package/dist/blocks/documents/index.d.ts +4 -8
  166. package/dist/blocks/documents/index.js +9 -12
  167. package/dist/blocks/domains/index.d.ts +8 -14
  168. package/dist/blocks/domains/index.js +12 -15
  169. package/dist/blocks/donations/index.d.ts +13 -23
  170. package/dist/blocks/donations/index.js +21 -26
  171. package/dist/blocks/drive/index.d.ts +116 -20
  172. package/dist/blocks/drive/index.js +138 -26
  173. package/dist/blocks/employees/index.d.ts +13 -23
  174. package/dist/blocks/employees/index.js +18 -23
  175. package/dist/blocks/enrichment/index.d.ts +8 -16
  176. package/dist/blocks/enrichment/index.js +11 -15
  177. package/dist/blocks/enrollments/index.d.ts +9 -17
  178. package/dist/blocks/enrollments/index.js +13 -17
  179. package/dist/blocks/entitlements/index.d.ts +8 -14
  180. package/dist/blocks/entitlements/index.js +8 -32
  181. package/dist/blocks/expenses/index.d.ts +22 -19
  182. package/dist/blocks/expenses/index.js +25 -23
  183. package/dist/blocks/field-history/index.d.ts +6 -10
  184. package/dist/blocks/field-history/index.js +5 -7
  185. package/dist/blocks/flags/index.d.ts +49 -20
  186. package/dist/blocks/flags/index.js +65 -19
  187. package/dist/blocks/forecasts/index.d.ts +10 -16
  188. package/dist/blocks/forecasts/index.js +11 -14
  189. package/dist/blocks/forms/index.d.ts +11 -25
  190. package/dist/blocks/forms/index.js +17 -24
  191. package/dist/blocks/goals/index.d.ts +8 -12
  192. package/dist/blocks/goals/index.js +9 -11
  193. package/dist/blocks/guests/index.d.ts +9 -19
  194. package/dist/blocks/guests/index.js +14 -19
  195. package/dist/blocks/hiring/index.d.ts +10 -18
  196. package/dist/blocks/hiring/index.js +12 -15
  197. package/dist/blocks/identities/index.d.ts +7 -11
  198. package/dist/blocks/identities/index.js +7 -9
  199. package/dist/blocks/imports/index.d.ts +8 -18
  200. package/dist/blocks/imports/index.js +11 -16
  201. package/dist/blocks/inbox/index.d.ts +11 -21
  202. package/dist/blocks/inbox/index.js +26 -23
  203. package/dist/blocks/incidents/index.d.ts +9 -17
  204. package/dist/blocks/incidents/index.js +14 -18
  205. package/dist/blocks/index.d.ts +14 -20
  206. package/dist/blocks/index.js +17 -20
  207. package/dist/blocks/inventory/index.d.ts +11 -17
  208. package/dist/blocks/inventory/index.js +12 -15
  209. package/dist/blocks/invoices/index.d.ts +34 -21
  210. package/dist/blocks/invoices/index.js +31 -18
  211. package/dist/blocks/knowledge/index.d.ts +3 -5
  212. package/dist/blocks/knowledge/index.js +5 -6
  213. package/dist/blocks/lead-scoring/index.d.ts +10 -14
  214. package/dist/blocks/lead-scoring/index.js +11 -13
  215. package/dist/blocks/leases/index.d.ts +11 -21
  216. package/dist/blocks/leases/index.js +20 -25
  217. package/dist/blocks/leave/index.d.ts +50 -17
  218. package/dist/blocks/leave/index.js +35 -14
  219. package/dist/blocks/ledger/index.d.ts +9 -17
  220. package/dist/blocks/ledger/index.js +13 -17
  221. package/dist/blocks/mail-sync/index.d.ts +6 -12
  222. package/dist/blocks/mail-sync/index.js +26 -25
  223. package/dist/blocks/memberships/index.d.ts +5 -9
  224. package/dist/blocks/memberships/index.js +4 -5
  225. package/dist/blocks/memory/index.d.ts +4 -8
  226. package/dist/blocks/memory/index.js +12 -15
  227. package/dist/blocks/messaging/index.d.ts +14 -24
  228. package/dist/blocks/messaging/index.js +19 -24
  229. package/dist/blocks/metrics/index.d.ts +9 -17
  230. package/dist/blocks/metrics/index.js +14 -18
  231. package/dist/blocks/mfa/index.d.ts +5 -9
  232. package/dist/blocks/mfa/index.js +7 -9
  233. package/dist/blocks/moderation/index.d.ts +9 -17
  234. package/dist/blocks/moderation/index.js +13 -17
  235. package/dist/blocks/notifications/index.d.ts +18 -34
  236. package/dist/blocks/notifications/index.js +32 -42
  237. package/dist/blocks/numbering/index.d.ts +6 -12
  238. package/dist/blocks/numbering/index.js +8 -11
  239. package/dist/blocks/oauth-server/index.d.ts +7 -13
  240. package/dist/blocks/oauth-server/index.js +12 -15
  241. package/dist/blocks/onboarding/index.d.ts +7 -13
  242. package/dist/blocks/onboarding/index.js +8 -11
  243. package/dist/blocks/orders/index.d.ts +17 -29
  244. package/dist/blocks/orders/index.js +22 -28
  245. package/dist/blocks/organizations/index.d.ts +11 -21
  246. package/dist/blocks/organizations/index.js +16 -19
  247. package/dist/blocks/outbox/index.d.ts +4 -6
  248. package/dist/blocks/outbox/index.js +11 -13
  249. package/dist/blocks/passes/index.d.ts +12 -22
  250. package/dist/blocks/passes/index.js +20 -25
  251. package/dist/blocks/permissions/index.d.ts +50 -15
  252. package/dist/blocks/permissions/index.js +99 -19
  253. package/dist/blocks/pipelines/index.d.ts +12 -18
  254. package/dist/blocks/pipelines/index.js +12 -15
  255. package/dist/blocks/posts/index.d.ts +10 -18
  256. package/dist/blocks/posts/index.js +15 -19
  257. package/dist/blocks/profiles/index.d.ts +8 -12
  258. package/dist/blocks/profiles/index.js +9 -11
  259. package/dist/blocks/promotions/index.d.ts +11 -17
  260. package/dist/blocks/promotions/index.js +13 -16
  261. package/dist/blocks/push/index.d.ts +12 -18
  262. package/dist/blocks/push/index.js +13 -16
  263. package/dist/blocks/queue/index.d.ts +187 -39
  264. package/dist/blocks/queue/index.js +226 -60
  265. package/dist/blocks/quotes/index.d.ts +13 -21
  266. package/dist/blocks/quotes/index.js +14 -17
  267. package/dist/blocks/rank/index.d.ts +7 -13
  268. package/dist/blocks/rank/index.js +8 -10
  269. package/dist/blocks/reactions/index.d.ts +11 -19
  270. package/dist/blocks/reactions/index.js +13 -17
  271. package/dist/blocks/relations/index.d.ts +11 -21
  272. package/dist/blocks/relations/index.js +18 -23
  273. package/dist/blocks/reminders/index.d.ts +12 -22
  274. package/dist/blocks/reminders/index.js +21 -25
  275. package/dist/blocks/reviews/index.d.ts +9 -15
  276. package/dist/blocks/reviews/index.js +11 -14
  277. package/dist/blocks/saved-views/index.d.ts +11 -21
  278. package/dist/blocks/saved-views/index.js +16 -21
  279. package/dist/blocks/scores/index.d.ts +6 -12
  280. package/dist/blocks/scores/index.js +10 -13
  281. package/dist/blocks/search/index.d.ts +9 -19
  282. package/dist/blocks/search/index.js +15 -19
  283. package/dist/blocks/security-events/index.d.ts +10 -24
  284. package/dist/blocks/security-events/index.js +17 -23
  285. package/dist/blocks/segments/index.d.ts +10 -18
  286. package/dist/blocks/segments/index.js +11 -15
  287. package/dist/blocks/sequences/index.d.ts +9 -17
  288. package/dist/blocks/sequences/index.js +15 -19
  289. package/dist/blocks/service-accounts/index.d.ts +9 -15
  290. package/dist/blocks/service-accounts/index.js +11 -14
  291. package/dist/blocks/sessions/index.d.ts +4 -8
  292. package/dist/blocks/sessions/index.js +9 -11
  293. package/dist/blocks/settings/index.d.ts +8 -16
  294. package/dist/blocks/settings/index.js +14 -18
  295. package/dist/blocks/share-links/index.d.ts +9 -17
  296. package/dist/blocks/share-links/index.js +16 -20
  297. package/dist/blocks/shipments/index.d.ts +14 -24
  298. package/dist/blocks/shipments/index.js +25 -31
  299. package/dist/blocks/signatures/index.d.ts +10 -16
  300. package/dist/blocks/signatures/index.js +10 -13
  301. package/dist/blocks/signing-keys/index.d.ts +5 -9
  302. package/dist/blocks/signing-keys/index.js +8 -10
  303. package/dist/blocks/sla/index.d.ts +11 -19
  304. package/dist/blocks/sla/index.js +17 -21
  305. package/dist/blocks/sso/index.d.ts +7 -19
  306. package/dist/blocks/sso/index.js +14 -21
  307. package/dist/blocks/state-machine/index.d.ts +7 -13
  308. package/dist/blocks/state-machine/index.js +9 -12
  309. package/dist/blocks/subjects/index.d.ts +7 -11
  310. package/dist/blocks/subjects/index.js +12 -14
  311. package/dist/blocks/tags/index.d.ts +11 -21
  312. package/dist/blocks/tags/index.js +20 -25
  313. package/dist/blocks/tasks/index.d.ts +13 -27
  314. package/dist/blocks/tasks/index.js +22 -29
  315. package/dist/blocks/teams/index.d.ts +8 -14
  316. package/dist/blocks/teams/index.js +10 -13
  317. package/dist/blocks/templates/index.d.ts +12 -22
  318. package/dist/blocks/templates/index.js +16 -21
  319. package/dist/blocks/time-tracking/index.d.ts +31 -25
  320. package/dist/blocks/time-tracking/index.js +29 -29
  321. package/dist/blocks/timeline/index.d.ts +10 -14
  322. package/dist/blocks/timeline/index.js +11 -13
  323. package/dist/blocks/trash/index.d.ts +10 -18
  324. package/dist/blocks/trash/index.js +11 -14
  325. package/dist/blocks/undo/index.d.ts +4 -8
  326. package/dist/blocks/undo/index.js +6 -8
  327. package/dist/blocks/updated-at/index.d.ts +3 -7
  328. package/dist/blocks/updated-at/index.js +4 -5
  329. package/dist/blocks/usage/index.d.ts +6 -10
  330. package/dist/blocks/usage/index.js +10 -13
  331. package/dist/blocks/vercel-marketplace/index.d.ts +9 -17
  332. package/dist/blocks/vercel-marketplace/index.js +17 -21
  333. package/dist/blocks/versions/index.d.ts +10 -20
  334. package/dist/blocks/versions/index.js +17 -22
  335. package/dist/blocks/waitlist/index.d.ts +10 -16
  336. package/dist/blocks/waitlist/index.js +11 -14
  337. package/dist/blocks/webhooks/index.d.ts +16 -34
  338. package/dist/blocks/webhooks/index.js +33 -44
  339. package/dist/blocks/workflow-editor/index.d.ts +13 -21
  340. package/dist/blocks/workflow-editor/index.js +22 -27
  341. package/dist/blocks/workflows/index.d.ts +8 -14
  342. package/dist/blocks/workflows/index.js +14 -18
  343. package/dist/bookings-Br0VXzaf.d.ts +285 -0
  344. package/dist/bucket-DvG66r5G.d.ts +693 -0
  345. package/dist/build-Ckxct2EX.js +2065 -0
  346. package/dist/build-D1-V9dd8.js +732 -0
  347. package/dist/carrier-D2b_028L.d.ts +165 -0
  348. package/dist/casing-DQzG9ANZ.js +15 -0
  349. package/dist/channel-B_kufDZy.d.ts +101 -0
  350. package/dist/channels-BxeTTtCY.js +113 -0
  351. package/dist/chat-sdk/index.d.ts +174 -41
  352. package/dist/chat-sdk/index.js +425 -83
  353. package/dist/claim-names-BKig1LOk.js +24 -0
  354. package/dist/claims/index.d.ts +8 -0
  355. package/dist/claims/index.js +8 -0
  356. package/dist/claims-CqTr_N1n.js +98 -0
  357. package/dist/claims-DouHL7ZL.js +62 -0
  358. package/dist/cli/_format-Ba0DoWjl.js +99 -0
  359. package/dist/cli/add-BDLLVLI8.js +99 -0
  360. package/dist/cli/add-BaOCKKt6.js +1 -0
  361. package/dist/cli/add-D2pKTbPw.js +1222 -0
  362. package/dist/cli/agent-59XWXsRi.js +184 -0
  363. package/dist/cli/app-table-files-CimWi_eh.js +343 -0
  364. package/dist/cli/arazzo-1.0-D3OaSeZw.js +531 -0
  365. package/dist/cli/arazzo-1.1-DaT2KAkP.js +704 -0
  366. package/dist/cli/args-_ZVgRBkx.js +26 -0
  367. package/dist/cli/asyncapi-3.0.0-Ca-UwtUW.js +5592 -0
  368. package/dist/cli/asyncapi-3.1.0-DUxf5zNu.js +5832 -0
  369. package/dist/cli/authorization-DJkkOjjG.js +230 -0
  370. package/dist/cli/backfill-B1xAsdL4.js +292 -0
  371. package/dist/cli/bin.js +5 -5
  372. package/dist/cli/blocks-DtZtn-R4.js +1 -0
  373. package/dist/cli/blocks-rBeis04I.js +155 -0
  374. package/dist/cli/cache-CvBRwv02.js +643 -0
  375. package/dist/cli/codemod-DYbVbJ-e.js +2884 -0
  376. package/dist/cli/codemod-block-renames-Dt3X1Wvg.js +238 -0
  377. package/dist/cli/command-BpZ4AuhR.js +1021 -0
  378. package/dist/cli/compare-yl4sSwVn.js +8 -0
  379. package/dist/cli/completion-B08Q0xB3.js +29 -0
  380. package/dist/cli/completion-CwL7e93t.js +210 -0
  381. package/dist/cli/completion-DHTT6rjI.js +1 -0
  382. package/dist/cli/config-CrwCec-B.js +1 -0
  383. package/dist/cli/config-D-Upz3jV.js +46 -0
  384. package/dist/cli/config-DrrkMihk.js +2030 -0
  385. package/dist/cli/config-edit-C6sQ1MqT.js +619 -0
  386. package/dist/cli/config-group-D4JWh4kG.js +388 -0
  387. package/dist/cli/content-mapper-DrhtDsAm.js +181 -0
  388. package/dist/cli/db-B8zfxjl2.js +77 -0
  389. package/dist/cli/db-Diy1OebO.js +246 -0
  390. package/dist/cli/detect-BcUDaO8I.js +83 -0
  391. package/dist/cli/dist-CYnD1kyT.js +128 -0
  392. package/dist/cli/dist-MKwjiW2w.js +1114 -0
  393. package/dist/cli/doctor-Dn4TzGmw.js +4687 -0
  394. package/dist/cli/env-BAJn6wCA.js +142 -0
  395. package/dist/cli/env-BCuUsWOh.js +1109 -0
  396. package/dist/cli/env-D70ihdbB.js +1 -0
  397. package/dist/cli/env-UN6PJFX6.js +1 -0
  398. package/dist/cli/errors-DcJ_PayO.js +97 -0
  399. package/dist/cli/exec-CXBufciC.js +461 -0
  400. package/dist/cli/fastest-levenshtein-B_QF6At5.js +119 -0
  401. package/dist/cli/files-DQayErI8.js +999 -0
  402. package/dist/cli/fresh-import-CdO2oQaQ.js +39 -0
  403. package/dist/cli/gen-BbeS0KgF.js +390 -0
  404. package/dist/cli/guards-DxwRG0Uv.js +7 -0
  405. package/dist/cli/in-stack-diff-huI7fGMX.js +185 -0
  406. package/dist/cli/index.d.ts +1 -53
  407. package/dist/cli/index.js +10 -11
  408. package/dist/cli/init-C30xdMSs.js +556 -0
  409. package/dist/cli/io-CQzy8PEZ.js +36 -0
  410. package/dist/cli/json5-DhsZB2va.js +784 -0
  411. package/dist/cli/jsonc-DU9Clnrz.js +1 -0
  412. package/dist/cli/jsonc-u_UiXFxs.js +43 -0
  413. package/dist/cli/keys-CxajkV_7.js +105 -0
  414. package/dist/cli/legacy-prefix-D8Jfku6I.js +153 -0
  415. package/dist/cli/live-Ctc8Qh9Y.js +339 -0
  416. package/dist/cli/mcp-5J0kUOtD.js +240 -0
  417. package/dist/cli/metadata-DxhUNctA.js +149 -0
  418. package/dist/cli/migrate-ockrh3UX.js +45 -0
  419. package/dist/cli/migration-safety-CLrqC0D-.js +925 -0
  420. package/dist/cli/migrations-CZTg2UJM.js +116 -0
  421. package/dist/cli/module-migration-BptQzmj2.js +118 -0
  422. package/dist/cli/moved-BAFPdJz_.js +253 -0
  423. package/dist/cli/ohash-imLR_J5Y.js +276 -0
  424. package/dist/cli/openapi-3.0-BJiTNq_x.js +927 -0
  425. package/dist/cli/openapi-3.1-BcWCoii2.js +869 -0
  426. package/dist/cli/openapi-3.2-MXPkeoTk.js +1030 -0
  427. package/dist/cli/orphans-CPcR85QN.js +27 -0
  428. package/dist/cli/parse-BueItuNJ.js +181 -0
  429. package/dist/cli/powersync-CmsXOuui.js +1 -0
  430. package/dist/cli/powersync-DIvsipKr.js +375 -0
  431. package/dist/cli/preset-BQnjDCSR.js +100 -0
  432. package/dist/cli/print-DdHt8xCc.js +66 -0
  433. package/dist/cli/prompts-D9b6uf21.js +1133 -0
  434. package/dist/cli/providers-k-1cEna6.js +99 -0
  435. package/dist/cli/prune-workflows-Ddv-GfkO.js +153 -0
  436. package/dist/cli/redact--zOGdWzo.js +37 -0
  437. package/dist/cli/remove-DEEQDoc7.js +237 -0
  438. package/dist/cli/render-SjSVz8yK.js +2216 -0
  439. package/dist/cli/rolldown-runtime-DegdyBIC.js +25 -0
  440. package/dist/cli/run-DdhIK7-K.js +1451 -0
  441. package/dist/cli/run-Ixt9mEb6.js +703 -0
  442. package/dist/cli/run-dY9uOC3W.js +62 -0
  443. package/dist/cli/seed-BpaqqyO8.js +187 -0
  444. package/dist/cli/seed-ByLneY1H.js +1 -0
  445. package/dist/cli/shared-p6sxli_5.js +150 -0
  446. package/dist/cli/shell-C1U618XA.js +9 -0
  447. package/dist/cli/skills-jZThjL3B.js +120 -0
  448. package/dist/cli/snapshot-Dd_8B9g-.js +728 -0
  449. package/dist/cli/source-BYvVe_Es.js +317 -0
  450. package/dist/cli/source-args-Bz5QQne2.js +58 -0
  451. package/dist/cli/spec-BxQgllJY.js +7449 -0
  452. package/dist/cli/spec-liRzcZTa.js +1 -0
  453. package/dist/cli/sql-layout-DHwiUOaD.js +260 -0
  454. package/dist/cli/stack-147NqctC.js +134 -0
  455. package/dist/cli/stack-env-BQhbUFa7.js +92 -0
  456. package/dist/cli/stack-status-Mxgqb3I4.js +45 -0
  457. package/dist/cli/stacks-C5YL6Un9.js +230 -0
  458. package/dist/cli/style-B5-nByxb.js +34 -0
  459. package/dist/cli/supabase-toml-B6-eEV5p.js +1155 -0
  460. package/dist/cli/sync-CreQWj53.js +318 -0
  461. package/dist/cli/table-D9FbJS8h.js +88 -0
  462. package/dist/cli/toml-VX0BsvYq.js +422 -0
  463. package/dist/cli/topics-Cdg0V7Tt.js +29 -0
  464. package/dist/cli/trace-D3TNqWBg.js +6 -0
  465. package/dist/cli/upgrade-3NQOUO1_.js +270 -0
  466. package/dist/cli/upgrade-U7IKj45h.js +40 -0
  467. package/dist/cli/validate-C_WTnX1U.js +7426 -0
  468. package/dist/cli/version-mBwP-aMG.js +3 -0
  469. package/dist/cli/yaml-JsusTbcC.js +2250 -0
  470. package/dist/client/index.d.ts +7 -7
  471. package/dist/client/index.js +9 -12
  472. package/dist/client/native/index.d.ts +7 -23
  473. package/dist/client/native/index.js +15 -22
  474. package/dist/client-Bky2z09B.js +290 -0
  475. package/dist/clone-H_gCsL29.js +32 -0
  476. package/dist/cloud-event-CLvsaPqH.js +62 -0
  477. package/dist/cloud-event-DXWmXrus.d.ts +62 -0
  478. package/dist/codecs-B1VO2BGL.d.ts +220 -0
  479. package/dist/codecs-B9v5Y5HH.js +357 -0
  480. package/dist/commerce/index.d.ts +5 -13
  481. package/dist/commerce/index.js +13 -16
  482. package/dist/compiler-qlXlokKn.d.ts +12 -0
  483. package/dist/compose-BRBlPSEY.js +52 -0
  484. package/dist/composite-CIxjVcL1.d.ts +79 -0
  485. package/dist/composite-D2JnIiHt.js +125 -0
  486. package/dist/config/index.d.ts +6 -6
  487. package/dist/config/index.js +7 -7
  488. package/dist/config-Bu6pwqcO.js +1102 -0
  489. package/dist/config-MDRA2sre.js +1672 -0
  490. package/dist/connectors-Cf2LeAuZ.d.ts +145 -0
  491. package/dist/context-D7jICqdN.d.ts +4279 -0
  492. package/dist/context-DSevnLrT.js +40 -0
  493. package/dist/contract/index.d.ts +16 -0
  494. package/dist/contract/index.js +0 -0
  495. package/dist/controller-BJmh7gFm.js +78 -0
  496. package/dist/controller-DxtxeYdf.d.ts +50 -0
  497. package/dist/controller-y1kSMuCU.js +72 -0
  498. package/dist/conversion-Bj9j3KnG.js +76 -0
  499. package/dist/conversion-C9rndpEI.d.ts +84 -0
  500. package/dist/cookie-DDkqvqe4.d.ts +3 -0
  501. package/dist/cookie-DJI6xXJ9.js +4 -0
  502. package/dist/cors-9SDsndtb.d.ts +13 -0
  503. package/dist/cors-DrDFLMNn.js +23 -0
  504. package/dist/create/index.d.ts +4 -28
  505. package/dist/create/index.js +9 -15
  506. package/dist/create/lite/index.d.ts +5 -25
  507. package/dist/create/lite/index.js +14 -24
  508. package/dist/create/oauth/index.d.ts +1 -1
  509. package/dist/create/oauth/index.js +1 -2
  510. package/dist/create/supabase/index.d.ts +2 -4
  511. package/dist/create/supabase/index.js +3 -6
  512. package/dist/create-blocks-D7q1boXV.js +367 -0
  513. package/dist/credentials/index.d.ts +6 -10
  514. package/dist/credentials/index.js +11 -12
  515. package/dist/cron-BD8VrQQl.js +147 -0
  516. package/dist/cron-route-DSITg1yC.js +23 -0
  517. package/dist/csv-Bwn9insJ.js +88 -0
  518. package/dist/csv-Dd1iKsk-.d.ts +26 -0
  519. package/dist/data-engine-BbqQwso_.js +174 -0
  520. package/dist/data-engine-CMENsp3d.d.ts +269 -0
  521. package/dist/data-hooks-BToeAcQ_.js +277 -0
  522. package/dist/db-exception-Dv18UZ-I.js +30 -0
  523. package/dist/deal-forecast-CN_BEy9s.d.ts +21 -0
  524. package/dist/deal-forecast-DsVFoMkJ.js +38 -0
  525. package/dist/define-B6D55cO0.js +2073 -0
  526. package/dist/define-ITQA71fw.d.ts +1242 -0
  527. package/dist/define-block-22Jv4U_-.js +63 -0
  528. package/dist/define-block-COmMkx2x.d.ts +1669 -0
  529. package/dist/delegation-C2rLpkHO.js +147 -0
  530. package/dist/delivery-CWcbh87x.d.ts +69 -0
  531. package/dist/delivery-SmPHu2_H.js +28 -0
  532. package/dist/delivery-events-0mAEuscm.js +52 -0
  533. package/dist/documents-DeZw83ue.d.ts +150 -0
  534. package/dist/edge/index.d.ts +20 -26
  535. package/dist/edge/index.js +20 -24
  536. package/dist/elysia/index.d.ts +2 -6
  537. package/dist/elysia/index.js +4 -6
  538. package/dist/email-BRm6wMWQ.d.ts +40 -0
  539. package/dist/embeddings--v4BJdUL.js +127 -0
  540. package/dist/embeddings-rVR2AKVz.d.ts +76 -0
  541. package/dist/ended-NC_ZesY4.d.ts +22 -0
  542. package/dist/entitlements-Dydkg-TV.js +47 -0
  543. package/dist/entitlements-sLoj3M6Y.js +44 -0
  544. package/dist/entitlements-w04ivvAy.d.ts +70 -0
  545. package/dist/entity-naming-BES3pkQI.js +130 -0
  546. package/dist/entity-schema-DEIz0I8i.js +38 -0
  547. package/dist/env/index.d.ts +1 -1
  548. package/dist/env/index.js +1 -2
  549. package/dist/envelope-CapD-JtH.js +90 -0
  550. package/dist/errors-B7tCfCvX.js +327 -0
  551. package/dist/errors-BdjHv5SV.js +43 -0
  552. package/dist/errors-D3-4c-XF.js +102 -0
  553. package/dist/escape-like-CK6L7gkj.d.ts +26 -0
  554. package/dist/escape-like-gxNXs145.js +6 -0
  555. package/dist/eve/index.d.ts +247 -16
  556. package/dist/eve/index.js +334 -26
  557. package/dist/eve-DIKjuPp5.d.ts +213 -0
  558. package/dist/event-calendar-DUtFyRrv.d.ts +63 -0
  559. package/dist/event-map-DxfsFgQT.js +18 -0
  560. package/dist/events/index.d.ts +3 -3
  561. package/dist/events/index.js +7 -8
  562. package/dist/events-BRKIxVQD.js +25 -0
  563. package/dist/events-DVt3Z9hw.d.ts +850 -0
  564. package/dist/events-Da482tiF.js +81 -0
  565. package/dist/executor-BDMqPbVU.js +482 -0
  566. package/dist/executor-C0_TT717.js +840 -0
  567. package/dist/executor-CFmee_nV.d.ts +35 -0
  568. package/dist/executor-CHnoKOxk.d.ts +168 -0
  569. package/dist/executor-Dc4Pl44u.js +207 -0
  570. package/dist/executor-DqNRrFxx.d.ts +99 -0
  571. package/dist/expo/index.d.ts +5 -9
  572. package/dist/expo/index.js +10 -12
  573. package/dist/extension-DQ9-oOVC.js +58 -0
  574. package/dist/extension-WdHd5uqI.js +102 -0
  575. package/dist/extension-Z8Pe7fXA.js +120 -0
  576. package/dist/extension-rdpYvpyN.js +52 -0
  577. package/dist/extension-shared-DJb_PfD4.js +59 -0
  578. package/dist/extra-Dz9n5y1s.js +9 -0
  579. package/dist/field-errors-DKCaSlZw.d.ts +208 -0
  580. package/dist/field-formats-Cap-V7UP.js +101 -0
  581. package/dist/field-formats-DVukMbRa.d.ts +36 -0
  582. package/dist/fields-BBcdKD-S.js +107 -0
  583. package/dist/fields-CAVk9dxX.d.ts +76 -0
  584. package/dist/filter-evaluate-Bz3Fzhz2.d.ts +35 -0
  585. package/dist/filter-evaluate-D_LLfdtE.js +216 -0
  586. package/dist/filter-query-DV-x8fio.d.ts +131 -0
  587. package/dist/filter-query-Ds7Z6lgZ.js +565 -0
  588. package/dist/flags-0EXDD3Iz.js +361 -0
  589. package/dist/flags-6emyAXly.d.ts +315 -0
  590. package/dist/flags-sdk/index.d.ts +217 -28
  591. package/dist/flags-sdk/index.js +255 -35
  592. package/dist/form-definition-8cCCt5zj.js +362 -0
  593. package/dist/form-definition-BN8shngm.d.ts +117 -0
  594. package/dist/format-BT0Z3V54.d.ts +77 -0
  595. package/dist/framework-BFlaPuvv.d.ts +46 -0
  596. package/dist/framework-ChzJYkJW.js +58 -0
  597. package/dist/function-contract-Bf6llTkE.js +7 -0
  598. package/dist/function-contract-DgDBYbXu.d.ts +25 -0
  599. package/dist/gateway-DaekJ_Me.d.ts +120 -0
  600. package/dist/gateway-options-DQGQzdkD.js +26 -0
  601. package/dist/gateway-options-Mut8jih_.d.ts +27 -0
  602. package/dist/guards-CsRa6v57.js +11 -0
  603. package/dist/guest-actions-CEwttioE.js +8 -0
  604. package/dist/guest-actions-DfHHp98H.d.ts +3 -0
  605. package/dist/h3/index.d.ts +2 -6
  606. package/dist/h3/index.js +4 -6
  607. package/dist/h3/v1/index.d.ts +3 -5
  608. package/dist/h3/v1/index.js +4 -5
  609. package/dist/history-6KiVNWdH.js +269 -0
  610. package/dist/hmac-DNcfpmI9.js +22 -0
  611. package/dist/hono/index.d.ts +18 -22
  612. package/dist/hono/index.js +16 -17
  613. package/dist/http-BDC1IvBX.js +27 -0
  614. package/dist/http-BRUI3qim.js +140 -0
  615. package/dist/http-D4lH1xqY.js +39 -0
  616. package/dist/image-url-bsGeybeg.js +83 -0
  617. package/dist/impersonation-BOCJcsmS.d.ts +26 -0
  618. package/dist/impersonation-D-quM36V.js +61 -0
  619. package/dist/inbox-DavCzW7b.d.ts +326 -0
  620. package/dist/index-8w4OB5En.d.ts +102 -0
  621. package/dist/index-BIAtapnD.d.ts +570 -0
  622. package/dist/index-BWR29Vvw.d.ts +76 -0
  623. package/dist/index-BZCmy767.d.ts +234 -0
  624. package/dist/index-BdC2IqkU.d.ts +152 -0
  625. package/dist/index-BgkHbf9C.d.ts +637 -0
  626. package/dist/index-BvcMQYL-.d.ts +326 -0
  627. package/dist/index-CbUXFzQV.d.ts +107 -0
  628. package/dist/index-CiE37wKX.d.ts +289 -0
  629. package/dist/index-D18su_r5.d.ts +402 -0
  630. package/dist/index-DU0UwWvL.d.ts +667 -0
  631. package/dist/index-Dj4VKpYZ.d.ts +49 -0
  632. package/dist/index-Dvpu22CJ.d.ts +291 -0
  633. package/dist/index-IKfbX_39.d.ts +23 -0
  634. package/dist/index-M1izbwbN.d.ts +145 -0
  635. package/dist/index.d.ts +13 -41
  636. package/dist/index.js +29 -34
  637. package/dist/instance-property-BlH7QSDl.js +6 -0
  638. package/dist/instances-D31jrmKh.js +16636 -0
  639. package/dist/invalidate-DAB9CaPm.d.ts +19 -0
  640. package/dist/iso4217-oKsif_hW.js +175 -0
  641. package/dist/json-O5vFw243.js +21 -0
  642. package/dist/json-schema-D9eVL_xi.js +884 -0
  643. package/dist/jwks-cache-IZaiICAV.js +48 -0
  644. package/dist/jws-B8p0ppgh.js +204 -0
  645. package/dist/jws-CxgTsbgG.d.ts +64 -0
  646. package/dist/kit-9pZP5iLU.js +163 -0
  647. package/dist/kit-OgFOW9rX.d.ts +92 -0
  648. package/dist/knowledge-BBC2sfAY.d.ts +215 -0
  649. package/dist/knowledge-DdZzUTQ-.js +299 -0
  650. package/dist/lint/index.d.ts +1 -5
  651. package/dist/lint/index.js +8 -10
  652. package/dist/list/index.d.ts +3 -3
  653. package/dist/list/index.js +3 -3
  654. package/dist/list-query-C7V8kUaD.d.ts +220 -0
  655. package/dist/list-query-D-tgs1eY.js +558 -0
  656. package/dist/live-BVi3q4bX.js +277 -0
  657. package/dist/logger-0LfhvwE4.d.ts +16 -0
  658. package/dist/logger-BkF8ukXV.js +20 -0
  659. package/dist/lookup-upE-e1zw.js +17 -0
  660. package/dist/management-DtX4ic1F.d.ts +55 -0
  661. package/dist/mapper/bin.js +13 -17
  662. package/dist/mcp/index.d.ts +4 -299
  663. package/dist/mcp/index.js +71 -42
  664. package/dist/mcp/sdk/index.d.ts +7 -11
  665. package/dist/mcp/sdk/index.js +12 -14
  666. package/dist/message-Cc4bkdNw.d.ts +97 -0
  667. package/dist/messages-CRk1g6oe.js +512 -0
  668. package/dist/messaging-D5z2TR37.d.ts +295 -0
  669. package/dist/methods-BjfDv4Gy.js +9 -0
  670. package/dist/metric-definition-2KQYeUZ1.d.ts +67 -0
  671. package/dist/metric-definition-D4H6IQT7.js +116 -0
  672. package/dist/mfa-CM5r904M.d.ts +34 -0
  673. package/dist/model-Lxa_mOzB.d.ts +338 -0
  674. package/dist/model-messages-BcrkjsPE.js +205 -0
  675. package/dist/model-messages-CGSUU450.d.ts +32 -0
  676. package/dist/money-BgpAd7d3.d.ts +89 -0
  677. package/dist/money-DH--bbYr.js +196 -0
  678. package/dist/money-codec-SKPm8FPw.js +40 -0
  679. package/dist/my-work-kinds-DNPq3ccL.js +10 -0
  680. package/dist/nestjs/index.d.ts +3 -5
  681. package/dist/nestjs/index.js +5 -6
  682. package/dist/next/client/index.d.ts +1 -5
  683. package/dist/next/client/index.js +2 -4
  684. package/dist/next/image/index.d.ts +1 -3
  685. package/dist/next/image/index.js +2 -3
  686. package/dist/next/index.d.ts +98 -106
  687. package/dist/next/index.js +88 -87
  688. package/dist/node/index.d.ts +3 -3
  689. package/dist/node/index.js +6 -7
  690. package/dist/node-headers-C3FExlg9.js +54 -0
  691. package/dist/node-headers-TnS4T7V_.d.ts +25 -0
  692. package/dist/nuxt/index.d.ts +0 -2
  693. package/dist/nuxt/index.js +1 -2
  694. package/dist/operations-BNFbWv1t.js +28 -0
  695. package/dist/operations-CsCwruKT.d.ts +4 -0
  696. package/dist/optional-peer-5SOYr3lL.js +31 -0
  697. package/dist/options--rohtkkC.js +4 -0
  698. package/dist/options-1iHDmlZ5.js +8 -0
  699. package/dist/options-2QJXZPPS.js +4 -0
  700. package/dist/options-B-JqrC61.d.ts +8 -0
  701. package/dist/options-B3xH2JvJ.js +8 -0
  702. package/dist/options-B4sTqDrt.js +4 -0
  703. package/dist/options-B56njigZ.js +19 -0
  704. package/dist/options-B5A3UmKY.d.ts +17 -0
  705. package/dist/options-B6m9gYRH.d.ts +11 -0
  706. package/dist/options-B7Pl708M.js +8 -0
  707. package/dist/options-B7YrdiUc.js +11 -0
  708. package/dist/options-B8c2_hIB.js +9 -0
  709. package/dist/options-B9w_Y08G.d.ts +6 -0
  710. package/dist/options-BDF60ouf.js +4 -0
  711. package/dist/options-BDMPjyrI.js +4 -0
  712. package/dist/options-BHdHuY5r.js +14 -0
  713. package/dist/options-BLMeCbtT.js +31 -0
  714. package/dist/options-BLQePOPy.d.ts +8 -0
  715. package/dist/options-BLn1PFyu.js +4 -0
  716. package/dist/options-BMO-FnOT.js +7 -0
  717. package/dist/options-BNRvoEkj.js +4 -0
  718. package/dist/options-BPQOiVx2.js +7 -0
  719. package/dist/options-BSTJmfX4.js +10 -0
  720. package/dist/options-BTRH26MJ.js +9 -0
  721. package/dist/options-BTaQszYn.js +9 -0
  722. package/dist/options-BYo7hMHK.js +10 -0
  723. package/dist/options-B_bxCZYM.js +7 -0
  724. package/dist/options-BaBaVWS-.js +10 -0
  725. package/dist/options-BamaRO-q.d.ts +12 -0
  726. package/dist/options-BcBdiPSZ.js +7 -0
  727. package/dist/options-BfY4pyQE.js +23 -0
  728. package/dist/options-BgCS5ODi.js +9 -0
  729. package/dist/options-Bi96Lzuf.js +9 -0
  730. package/dist/options-BjEsSoFp.js +17 -0
  731. package/dist/options-Bkx8vwip.js +4 -0
  732. package/dist/options-BmFSI07A.js +4 -0
  733. package/dist/options-BmwDdKwE.js +7 -0
  734. package/dist/options-Bn3NjXfn.js +7 -0
  735. package/dist/options-BqK4xV67.js +13 -0
  736. package/dist/options-Bs2dC-at.js +11 -0
  737. package/dist/options-BvttpM1M.js +4 -0
  738. package/dist/options-Bwrwb8do.d.ts +10 -0
  739. package/dist/options-BxdqA2Ex.js +19 -0
  740. package/dist/options-BzxR82Tu.js +9 -0
  741. package/dist/options-C-NFS6e3.js +13 -0
  742. package/dist/options-C13-dVMH.js +7 -0
  743. package/dist/options-C1RIyAe1.js +7 -0
  744. package/dist/options-C1kZ3qLd.js +8 -0
  745. package/dist/options-C2RjdunU.js +27 -0
  746. package/dist/options-C4kpi6HE.js +8 -0
  747. package/dist/options-C5MfwOAO.js +8 -0
  748. package/dist/options-C5fKQ3EJ.d.ts +10 -0
  749. package/dist/options-CJR59q8s.js +17 -0
  750. package/dist/options-CJVYQue3.d.ts +10 -0
  751. package/dist/options-CLy7CcMn.js +8 -0
  752. package/dist/options-COfEYic3.js +8 -0
  753. package/dist/options-CRwTY_q2.d.ts +58 -0
  754. package/dist/options-CcW7h8mv.js +9 -0
  755. package/dist/options-Ceu2j1vv.js +7 -0
  756. package/dist/options-CgBKgmI8.js +7 -0
  757. package/dist/options-CgMiQGOF.js +9 -0
  758. package/dist/options-CptvcSmF.js +11 -0
  759. package/dist/options-CsLUAt04.js +8 -0
  760. package/dist/options-CtyjhSGk.js +15 -0
  761. package/dist/options-CuPWezcV.js +7 -0
  762. package/dist/options-CyDOOWlk.js +7 -0
  763. package/dist/options-CyYZvdSy.js +10 -0
  764. package/dist/options-CzIPn0fF.js +4 -0
  765. package/dist/options-CzWjw2HY.js +10 -0
  766. package/dist/options-CztbWdz9.js +4 -0
  767. package/dist/options-D4LuPM8a.js +4 -0
  768. package/dist/options-D4dxMGHF.js +7 -0
  769. package/dist/options-D5a9CHgP.js +7 -0
  770. package/dist/options-D6tpMRvp.d.ts +13 -0
  771. package/dist/options-D848Os4l.js +10 -0
  772. package/dist/options-DCZPW5gR.d.ts +15 -0
  773. package/dist/options-DFSHZFLN.js +4 -0
  774. package/dist/options-DFemc2im.js +9 -0
  775. package/dist/options-DFgHHwzD.js +12 -0
  776. package/dist/options-DNZ9r_Vo.d.ts +8 -0
  777. package/dist/options-DP7NwQPZ.js +4 -0
  778. package/dist/options-DPQaafyc.js +7 -0
  779. package/dist/options-DQkhhBLy.js +4 -0
  780. package/dist/options-DTTz33na.js +9 -0
  781. package/dist/options-DToWdVqW.js +4 -0
  782. package/dist/options-DUNUGuhM.js +4 -0
  783. package/dist/options-DWgpi5ns.js +7 -0
  784. package/dist/options-DeamnVOY.d.ts +12 -0
  785. package/dist/options-Dg7eK-_J.d.ts +8 -0
  786. package/dist/options-DiIlMZpc.js +8 -0
  787. package/dist/options-DjFbIRgV.js +16 -0
  788. package/dist/options-DjtCYRWb.js +4 -0
  789. package/dist/options-Dk6D88Zx.d.ts +6 -0
  790. package/dist/options-DpwRG4tO.js +8 -0
  791. package/dist/options-DvgKdZ2K.js +9 -0
  792. package/dist/options-DwIoRvic.js +4 -0
  793. package/dist/options-GwwLsKf5.js +8 -0
  794. package/dist/options-I1ZHfDP0.d.ts +58 -0
  795. package/dist/options-Itq7QYoW.js +20 -0
  796. package/dist/options-JnPEVbBJ.js +17 -0
  797. package/dist/options-Jwux4JDX.js +7 -0
  798. package/dist/options-Lg76d-cV.js +7 -0
  799. package/dist/options-Lh6uxepF.d.ts +24 -0
  800. package/dist/options-Oki2W_c3.js +4 -0
  801. package/dist/options-PM7IaIFP.js +10 -0
  802. package/dist/options-PTLBl6QT.js +7 -0
  803. package/dist/options-PheFo4JY.js +10 -0
  804. package/dist/options-SlC_jZ7y.js +4 -0
  805. package/dist/options-Sq4bYbf5.js +13 -0
  806. package/dist/options-XiD_Y3oK.js +14 -0
  807. package/dist/options-Z-bd_H1E.js +88 -0
  808. package/dist/options-ax_ssX_m.js +4 -0
  809. package/dist/options-bNB8_nlW.js +23 -0
  810. package/dist/options-eIEk0vqV.js +4 -0
  811. package/dist/options-eLIedotm.js +7 -0
  812. package/dist/options-jg0FMHA5.js +4 -0
  813. package/dist/options-mypVYaqR.js +9 -0
  814. package/dist/options-ompJjxkV.js +4 -0
  815. package/dist/options-pbc4H8_A.js +7 -0
  816. package/dist/options-uUGi0Phf.d.ts +14 -0
  817. package/dist/options-yRwYr4up.js +4 -0
  818. package/dist/options-z2Zhi97E.js +9 -0
  819. package/dist/options-zYV6M0vr.js +8 -0
  820. package/dist/orpc/index.d.ts +13 -19
  821. package/dist/orpc/index.js +20 -23
  822. package/dist/otel/index.d.ts +4 -6
  823. package/dist/otel/index.js +8 -10
  824. package/dist/outbox-7zgh-7nw.d.ts +197 -0
  825. package/dist/payments-B4JchZuJ.js +15 -0
  826. package/dist/payments-BBGSGRQ7.d.ts +112 -0
  827. package/dist/permissions-BDt27oYF.js +48 -0
  828. package/dist/permissions-BP593xxk.d.ts +44 -0
  829. package/dist/permissions-controller-B4uI5IPH.js +33 -0
  830. package/dist/pg-error-D92B6jlF.js +25 -0
  831. package/dist/plugin-Ca2qBiFZ.js +47 -0
  832. package/dist/pool-D-4HyhuW.d.ts +121 -0
  833. package/dist/pool-errors-JrZie6u3.js +26 -0
  834. package/dist/ports-BVLhLUvR.d.ts +87 -0
  835. package/dist/ports-CmEXVqhg.js +150 -0
  836. package/dist/postgres/index.d.ts +5 -11
  837. package/dist/postgres/index.js +7 -9
  838. package/dist/postgrest-DZtM2nIS.d.ts +51 -0
  839. package/dist/postgrest-executor-lf8Mt4J0.js +1064 -0
  840. package/dist/powersync/index.d.ts +7 -25
  841. package/dist/powersync/index.js +14 -24
  842. package/dist/preset/index.d.ts +3 -3
  843. package/dist/preset/index.js +3 -3
  844. package/dist/preset-om2rbdYw.js +1038 -0
  845. package/dist/problem-C0SVHhd3.js +161 -0
  846. package/dist/problem-NGBjN-TO.d.ts +77 -0
  847. package/dist/project-D4ArwcS5.js +1749 -0
  848. package/dist/provider-B6qpleR9.js +56 -0
  849. package/dist/provider-BI0KC4u5.d.ts +142 -0
  850. package/dist/providers-C9sBIBYE.js +62 -0
  851. package/dist/push-token-B0j171on.d.ts +22 -0
  852. package/dist/push-token-CO28k46S.js +15 -0
  853. package/dist/queries-BLrxg_GL.js +238 -0
  854. package/dist/query/index.d.ts +3 -3
  855. package/dist/query/index.js +11 -15
  856. package/dist/range-BN3kpJAE.d.ts +6 -0
  857. package/dist/range-Nrh_qtb_.js +6 -0
  858. package/dist/rank-keys-CEBzd9Xa.js +59 -0
  859. package/dist/rank-result-B_xLQCBV.d.ts +12 -0
  860. package/dist/rank-result-DzaTKKhH.js +17 -0
  861. package/dist/rate-limit-C89Yzwd9.d.ts +48 -0
  862. package/dist/rate-limit-CRhlLFhP.js +380 -0
  863. package/dist/rate-limit-DXJbLVg0.js +48 -0
  864. package/dist/ratelimit-headers-CpB-cDD6.js +61 -0
  865. package/dist/react/index.d.ts +11 -11
  866. package/dist/react/index.js +6 -6
  867. package/dist/react/native/index.d.ts +3 -5
  868. package/dist/react/native/index.js +5 -5
  869. package/dist/react/server.d.ts +13 -15
  870. package/dist/react/server.js +9 -10
  871. package/dist/react/session.d.ts +4 -6
  872. package/dist/react/session.js +2 -3
  873. package/dist/react-COIov1yC.js +1006 -0
  874. package/dist/react-CqOVutZj.js +80 -0
  875. package/dist/react-router/index.d.ts +7 -12
  876. package/dist/react-router/index.js +10 -12
  877. package/dist/read-set-DEDoIHMM.js +198 -0
  878. package/dist/realtime/index.d.ts +7 -7
  879. package/dist/realtime/index.js +6 -7
  880. package/dist/realtime-status-CocmAOPv.js +10 -0
  881. package/dist/realtime-status-D3oUx3o4.d.ts +6 -0
  882. package/dist/record-bindings-jTZw-GVe.js +25 -0
  883. package/dist/record-form-DU2EoVsv.d.ts +80 -0
  884. package/dist/record-type-oQxekQTX.js +219 -0
  885. package/dist/recordings-D69Va7gP.d.ts +117 -0
  886. package/dist/records/index.d.ts +10 -14
  887. package/dist/records/index.js +13 -16
  888. package/dist/refresh-B8t_KE3s.js +142 -0
  889. package/dist/refresh-BtbC2rZe.d.ts +52 -0
  890. package/dist/refusal-5c6UMpUP.js +63 -0
  891. package/dist/refusal-CGi-0Q18.d.ts +30 -0
  892. package/dist/relay-CllqA-lV.js +248 -0
  893. package/dist/resolve--LfVoOMg.d.ts +287 -0
  894. package/dist/resolve-FW8oeXvh.js +927 -0
  895. package/dist/resolved-names-DYYyh35i.js +130 -0
  896. package/dist/resource-BbWk4hoP.js +561 -0
  897. package/dist/resource-DQ4kIBpa.js +104 -0
  898. package/dist/resource-DWllVW8k.d.ts +124 -0
  899. package/dist/resource-execute-DUBYKTYU.d.ts +13 -0
  900. package/dist/resource-schemas-Bq0g2RCQ.js +81 -0
  901. package/dist/resource-types-RgaljPs0.d.ts +155 -0
  902. package/dist/resources-Bki1J4jy.d.ts +5 -0
  903. package/dist/resources-DYSx9NYM.js +63 -0
  904. package/dist/respond-BYOV7KZp.d.ts +108 -0
  905. package/dist/respond-DLH4tD2d.js +106 -0
  906. package/dist/result-8xza7w5W.js +145 -0
  907. package/dist/result-DTOQRyGY.d.ts +347 -0
  908. package/dist/rows-Ce8dsmfM.js +79 -0
  909. package/dist/rows-D-RqIsRz.js +38 -0
  910. package/dist/rrule-BLpe2449.js +289 -0
  911. package/dist/run-keys-BnzqxtYc.d.ts +59 -0
  912. package/dist/run-state-D0Tbl-nM.d.ts +11 -0
  913. package/dist/run-state-DGiyDQxH.js +12 -0
  914. package/dist/run-watch-DJk4Q603.js +52 -0
  915. package/dist/runtime-qslVrC9l.js +43 -0
  916. package/dist/sales-lines-DuNVoKHA.d.ts +36 -0
  917. package/dist/sales-lines-axwWhnLk.js +44 -0
  918. package/dist/sales-shared-CY3s_wBx.js +21 -0
  919. package/dist/sandboxes-B2hBoBvJ.d.ts +85 -0
  920. package/dist/schemas-CpoEiAeT.js +213 -0
  921. package/dist/scope-dD_OAgRU.js +89 -0
  922. package/dist/scores-Bvk_JgXL.js +176 -0
  923. package/dist/scores-FAORS4qU.d.ts +172 -0
  924. package/dist/search-DtbkD0h0.js +8 -0
  925. package/dist/server/index.d.ts +39 -70
  926. package/dist/server/index.js +55 -59
  927. package/dist/server-types-C2hlvhP4.d.ts +521 -0
  928. package/dist/session-B4VasaAA.d.ts +96 -0
  929. package/dist/session-status-D8CBxCqv.d.ts +80 -0
  930. package/dist/shared-Bmcnxwie.js +16 -0
  931. package/dist/shared-Ci1g9nl4.js +90 -0
  932. package/dist/shared-DsBcvj6q.d.ts +9 -0
  933. package/dist/sign-in-BMm1xhKq.js +730 -0
  934. package/dist/sign-in-C9pZE1kM.d.ts +53 -0
  935. package/dist/sign-in-CX1a5i2P.d.ts +52 -0
  936. package/dist/sign-in-CxdoTEp5.js +399 -0
  937. package/dist/signatures-CBn7w4VR.js +144 -0
  938. package/dist/signatures-jPr9JXyw.d.ts +41 -0
  939. package/dist/signers-6ih6i9aq.d.ts +380 -0
  940. package/dist/signing-keys-BC5_hJN5.js +163 -0
  941. package/dist/signing-keys-De09WNJ3.d.ts +117 -0
  942. package/dist/simplify-BzThKn5b.js +82 -0
  943. package/dist/snapshot-BGsJw9xn.d.ts +83 -0
  944. package/dist/snapshot-CVMSyTHH.js +138 -0
  945. package/dist/solid/index.d.ts +12 -22
  946. package/dist/solid/index.js +10 -16
  947. package/dist/solid-start/index.d.ts +6 -9
  948. package/dist/solid-start/index.js +8 -9
  949. package/dist/spec/index.d.ts +6 -48
  950. package/dist/spec/index.js +23 -39
  951. package/dist/spec-6Vr7sc0Z.js +123 -0
  952. package/dist/spec-pins-CuQ2anBw.d.ts +125 -0
  953. package/dist/spec-pins-FKUzgF6K.js +61 -0
  954. package/dist/sql/index.d.ts +6 -5
  955. package/dist/sql/index.js +5 -5
  956. package/dist/sql-C1K5JALb.js +420 -0
  957. package/dist/sql-DiUP7fKX.js +140711 -0
  958. package/dist/sql-type-XWMeZRAl.js +33 -0
  959. package/dist/sqlite/index.d.ts +3 -9
  960. package/dist/sqlite/index.js +5 -8
  961. package/dist/sso-CRnaFJh0.js +216 -0
  962. package/dist/sso-CuzAjsc8.d.ts +159 -0
  963. package/dist/ssr/index.d.ts +5 -5
  964. package/dist/ssr/index.js +3 -3
  965. package/dist/standard-BD2aOUsf.js +24 -0
  966. package/dist/standard-DRX6Ch1j.d.ts +5 -0
  967. package/dist/stats-BTJgRMEp.js +82 -0
  968. package/dist/statuses-BTrQ5H4S.js +27 -0
  969. package/dist/statuses-Bv-0XoYC.js +27 -0
  970. package/dist/storage/index.d.ts +3 -3
  971. package/dist/storage/index.js +27 -40
  972. package/dist/storage-api-COQr77e8.js +9 -0
  973. package/dist/store-CKKzmsWB.js +68 -0
  974. package/dist/store-c7QxUHX-.d.ts +81 -0
  975. package/dist/streams/index.d.ts +3 -7
  976. package/dist/streams/index.js +5 -6
  977. package/dist/streams/redis/index.d.ts +1 -3
  978. package/dist/streams/redis/index.js +6 -7
  979. package/dist/stripe/index.d.ts +1 -3
  980. package/dist/stripe/index.js +3 -4
  981. package/dist/stripe-Bl-sjnl6.d.ts +154 -0
  982. package/dist/stripe-DKRwRWew.js +31 -0
  983. package/dist/subject-readers-BARV5rNp.js +48 -0
  984. package/dist/subject-readers-BlD8tALG.d.ts +19 -0
  985. package/dist/subject-type-BarjdHZV.js +7 -0
  986. package/dist/subjects-BGwLJ3IB.d.ts +148 -0
  987. package/dist/subjects-Bv2dPflD.d.ts +86 -0
  988. package/dist/subscribers-C57054Pc.js +32 -0
  989. package/dist/summaries-CUemsYwV.d.ts +67 -0
  990. package/dist/supabase-mcp-DY32eoax.d.ts +44 -0
  991. package/dist/supabase-mcp-QvebHckf.js +27 -0
  992. package/dist/support-DxYI6sDM.d.ts +351 -0
  993. package/dist/support-view-CvDEgyGY.js +17 -0
  994. package/dist/support-view-DSmCett7.d.ts +15 -0
  995. package/dist/svelte/index.d.ts +11 -21
  996. package/dist/svelte/index.js +9 -15
  997. package/dist/sveltekit/index.d.ts +9 -14
  998. package/dist/sveltekit/index.js +12 -14
  999. package/dist/table-schema-CwXg7oBz.d.ts +77 -0
  1000. package/dist/table-schema-D-ss9ozY.js +291 -0
  1001. package/dist/tables-BSiVuKKx.js +72 -0
  1002. package/dist/tags--k2fbPfO.d.ts +28 -0
  1003. package/dist/tags-CW-KvjdL.js +38 -0
  1004. package/dist/tanstack-db/index.d.ts +4 -8
  1005. package/dist/tanstack-db/index.js +4 -6
  1006. package/dist/tanstack-start/index.d.ts +7 -12
  1007. package/dist/tanstack-start/index.js +8 -10
  1008. package/dist/tax-BD9dN1rx.d.ts +168 -0
  1009. package/dist/tax-BwckP5dv.js +139 -0
  1010. package/dist/tee-CVOMhEX-.js +100 -0
  1011. package/dist/template-CNq9xcfx.js +125 -0
  1012. package/dist/temporal-DKTdGK9i.js +94 -0
  1013. package/dist/temporal-required-w_2u4EDp.js +19 -0
  1014. package/dist/tenant-B3IIq8Eq.d.ts +14 -0
  1015. package/dist/tenant-Beqd7TTq.js +48 -0
  1016. package/dist/tenant-source-46lMuMEn.js +7 -0
  1017. package/dist/testing/index.d.ts +120 -127
  1018. package/dist/testing/index.js +277 -129
  1019. package/dist/timeline-Bq658xsi.d.ts +147 -0
  1020. package/dist/timeline-Bs-FGMIJ.js +49 -0
  1021. package/dist/timing-B6yHayKA.js +94 -0
  1022. package/dist/topic-D2MyBeaI.d.ts +411 -0
  1023. package/dist/topic-k17VvXRj.js +640 -0
  1024. package/dist/transport-CS4cVH4S.js +30 -0
  1025. package/dist/ttl-cache-C5S0L2wx.js +31 -0
  1026. package/dist/types-BBqP9H6w.d.ts +175 -0
  1027. package/dist/types-BFEKRmEK.d.ts +449 -0
  1028. package/dist/types-BkYEUWdz.d.ts +1095 -0
  1029. package/dist/types-C8UyJOPJ.d.ts +247 -0
  1030. package/dist/types-DCoqai8o.d.ts +215 -0
  1031. package/dist/types-Dh2OGEW5.d.ts +648 -0
  1032. package/dist/types-DnrJ_crV.js +28 -0
  1033. package/dist/types-TH3zlMiM.d.ts +192 -0
  1034. package/dist/types-d0JBRTAg.d.ts +660 -0
  1035. package/dist/undo-22ofP6Zp.d.ts +44 -0
  1036. package/dist/undo-Dki6Ujak.js +43 -0
  1037. package/dist/upload-claim-Bo2mpBz4.js +32 -0
  1038. package/dist/usage-CNCT6_3D.d.ts +230 -0
  1039. package/dist/user-change-Ngy8z1fZ.js +133 -0
  1040. package/dist/variants-BaMleC56.js +51 -0
  1041. package/dist/vault-yGQD5Rdl.d.ts +60 -0
  1042. package/dist/vercel-connect/index.d.ts +194 -20
  1043. package/dist/vercel-connect/index.js +265 -33
  1044. package/dist/vercel-sandbox/index.d.ts +166 -0
  1045. package/dist/vercel-sandbox/index.js +171 -0
  1046. package/dist/verify-BQu3eBNW.d.ts +144 -0
  1047. package/dist/verify-DY_j4GPZ.js +129 -0
  1048. package/dist/view-BfEqjZJ_.js +117 -0
  1049. package/dist/view-Cy2XxYp1.d.ts +107 -0
  1050. package/dist/vue/index.d.ts +12 -22
  1051. package/dist/vue/index.js +10 -16
  1052. package/dist/watch-topic-C2KxpeaB.js +56 -0
  1053. package/dist/watch-topic-q6krNw0T.d.ts +29 -0
  1054. package/dist/wire-DIoLA8VL.js +90 -0
  1055. package/dist/wiring-DJBSLdyF.js +12 -0
  1056. package/dist/workflow-sdk/builder/index.d.ts +12 -14
  1057. package/dist/workflow-sdk/builder/index.js +12 -11
  1058. package/dist/workflow-sdk/index.d.ts +62 -6
  1059. package/dist/workflow-sdk/index.js +75 -10
  1060. package/dist/workflow-sdk/world/index.d.ts +13 -20
  1061. package/dist/workflow-sdk/world/index.js +115 -26
  1062. package/dist/workflow-sdk-BL3wzkdp.js +2749 -0
  1063. package/dist/workflow-sdk-q2jnEaAJ.js +302 -0
  1064. package/dist/workflow-sdk-yIkECybp.d.ts +171 -0
  1065. package/dist/workflows-BljkWRxE.d.ts +256 -0
  1066. package/dist/yjs/index.d.ts +3 -5
  1067. package/dist/yjs/index.js +6 -7
  1068. package/package.json +56 -31
  1069. package/schemas/config-v1.json +60 -3
  1070. package/schemas/doctor-report-v1.json +1 -0
  1071. package/schemas/snapshot-v2.json +7 -0
  1072. package/skills/better-supabase/SKILL.md +4 -4
  1073. package/skills/better-supabase/references/block-extensions.md +2 -2
  1074. package/skills/better-supabase/references/troubleshooting.md +1 -1
  1075. package/skills/better-supabase/references/ui-recipes.md +73 -36
  1076. package/skills/better-supabase-api/SKILL.md +1 -1
  1077. package/skills/better-supabase-api/references/adapters.md +3 -3
  1078. package/skills/better-supabase-api/references/ai.md +8 -0
  1079. package/skills/better-supabase-auth/SKILL.md +19 -19
  1080. package/skills/better-supabase-auth/references/authorization-providers.md +1 -1
  1081. package/dist/access-sql-CTDNuxRv.js +0 -385
  1082. package/dist/actor-CoveJgya.d.ts +0 -106
  1083. package/dist/actor-go7p9-CJ.js +0 -150
  1084. package/dist/adapter-BTbj5N9C.js +0 -2251
  1085. package/dist/agents-CM_cCtcr.d.ts +0 -117
  1086. package/dist/ai-cache-BFRKxgZ4.js +0 -87
  1087. package/dist/ai-cache-BTGqckta.d.ts +0 -82
  1088. package/dist/ai-chat-B7_vQvxU.d.ts +0 -619
  1089. package/dist/ai-files-m_2z3rH1.js +0 -339
  1090. package/dist/ai-message-DfaP8sis.js +0 -14
  1091. package/dist/ai-schedules-CZEfo-_M.d.ts +0 -166
  1092. package/dist/anchors-7F34QyHa.d.ts +0 -40
  1093. package/dist/api-3C0AWFeP.js +0 -696
  1094. package/dist/api-59rv5hL6.d.ts +0 -495
  1095. package/dist/api-keys-JE-aykZE.d.ts +0 -213
  1096. package/dist/app-tables-B2mKMNRQ.d.ts +0 -28
  1097. package/dist/approvals-BfEafAzt.d.ts +0 -129
  1098. package/dist/assistant-B49qATbj.d.ts +0 -157
  1099. package/dist/attachments-BXbLnNxm.js +0 -376
  1100. package/dist/attributes-Bzf51_nc.js +0 -47
  1101. package/dist/auth-DyF_LRxd.js +0 -20
  1102. package/dist/auth-link-B4NL84XU.d.ts +0 -104
  1103. package/dist/auth-link-D3-bU6yz.js +0 -118
  1104. package/dist/auth-module-BbmX-N4L.js +0 -52
  1105. package/dist/auth-reply-Dj124sbX.d.ts +0 -11
  1106. package/dist/auth-reply-tlXB2FQ9.js +0 -31
  1107. package/dist/authorization-DfEkyFt_.d.ts +0 -3867
  1108. package/dist/authorization-hooks-BWhkMZfH.d.ts +0 -221
  1109. package/dist/authorizer-B6X09otb.d.ts +0 -118
  1110. package/dist/authorizer-BGhXaDmo.js +0 -172
  1111. package/dist/automation-D41DXyvT.js +0 -75
  1112. package/dist/automations-8L3NEuoq.js +0 -29
  1113. package/dist/automations-BKjJpktQ.js +0 -33
  1114. package/dist/automations-BMuqwZZn.js +0 -314
  1115. package/dist/automations-EzXteupo.js +0 -31
  1116. package/dist/availability-BdeKCHpl.d.ts +0 -236
  1117. package/dist/base64-B9Wlsdj7.js +0 -42
  1118. package/dist/batch-limit-DKVQDz4o.js +0 -5
  1119. package/dist/before-route-B23K2zYU.js +0 -30
  1120. package/dist/bind-DAx0bMSi.d.ts +0 -104
  1121. package/dist/block-authors-Bw3zdzgl.js +0 -14
  1122. package/dist/block-authors-DzXLUiIq.d.ts +0 -12
  1123. package/dist/block-env-Dz7Caxk0.d.ts +0 -32
  1124. package/dist/block-event-listener-Bu6G0TFH.js +0 -16
  1125. package/dist/block-events-IWAyafO3.js +0 -83
  1126. package/dist/block-fields-BE7pInWZ.d.ts +0 -58
  1127. package/dist/block-fields-BjXgX_5c.js +0 -140
  1128. package/dist/block-helpers-B0f0ZVb5.js +0 -437
  1129. package/dist/block-helpers-D5emQ2O6.d.ts +0 -62
  1130. package/dist/block-hooks-B8itxzEE.d.ts +0 -117
  1131. package/dist/block-hooks-DKtz0HRh.js +0 -130
  1132. package/dist/block-method-C9hWdHom.js +0 -21
  1133. package/dist/block-method-CiVa2G-J.d.ts +0 -14
  1134. package/dist/block-subjects-C1_9DkSA.d.ts +0 -6
  1135. package/dist/block-subjects-DFSuFY1a.js +0 -55
  1136. package/dist/block-tenant-DHp7subc.js +0 -14
  1137. package/dist/block-transport-9EUA3q_I.d.ts +0 -69
  1138. package/dist/bookings-xsmM2TA_.d.ts +0 -289
  1139. package/dist/bucket-SvRQwYS4.d.ts +0 -705
  1140. package/dist/build-CH2N3Yf0.js +0 -2073
  1141. package/dist/build-DbIRFcHQ.js +0 -735
  1142. package/dist/carrier-KzeYXVrW.d.ts +0 -169
  1143. package/dist/casing-DdFWEtqr.js +0 -16
  1144. package/dist/channel-JcMd5lNP.d.ts +0 -105
  1145. package/dist/channels-CfcFPuo_.js +0 -114
  1146. package/dist/claims-Bp9My7XP.js +0 -88
  1147. package/dist/claims-DTy6R6my.js +0 -63
  1148. package/dist/cli/_format-Cax5EsM9.js +0 -101
  1149. package/dist/cli/add-B9wP0YGU.js +0 -99
  1150. package/dist/cli/add-DjZXKd7X.js +0 -1231
  1151. package/dist/cli/add-ZcEOEK23.js +0 -1
  1152. package/dist/cli/agent-CbuPvI2x.js +0 -185
  1153. package/dist/cli/app-table-files-mtvjHa48.js +0 -346
  1154. package/dist/cli/arazzo-1.0-BalU61-_.js +0 -532
  1155. package/dist/cli/arazzo-1.1-Bnfasbun.js +0 -705
  1156. package/dist/cli/args-UEwg0l-N.js +0 -27
  1157. package/dist/cli/asyncapi-3.0.0-C78dBjR6.js +0 -5593
  1158. package/dist/cli/asyncapi-3.1.0-g-7aIfV1.js +0 -5833
  1159. package/dist/cli/backfill-Coshdvh_.js +0 -293
  1160. package/dist/cli/blocks-BWCuA0nq.js +0 -156
  1161. package/dist/cli/blocks-hiSazThw.js +0 -1
  1162. package/dist/cli/cache-x2wWAy0h.js +0 -607
  1163. package/dist/cli/codemod-BnjV7BpC.js +0 -2634
  1164. package/dist/cli/codemod-block-renames-BuSaTE_G.js +0 -239
  1165. package/dist/cli/command-CCAwhiOh.js +0 -1003
  1166. package/dist/cli/compare-BmIWVEui.js +0 -9
  1167. package/dist/cli/completion-BJaB84Pe.js +0 -211
  1168. package/dist/cli/completion-BkUhs1ms.js +0 -1
  1169. package/dist/cli/completion-DmUVsUVQ.js +0 -30
  1170. package/dist/cli/config-Cskysxp-.js +0 -2000
  1171. package/dist/cli/config-Df5cXWNN.js +0 -1
  1172. package/dist/cli/config-edit-CrWfk8s3.js +0 -621
  1173. package/dist/cli/config-group-CP-B9uRt.js +0 -390
  1174. package/dist/cli/config-zId1jkLx.js +0 -47
  1175. package/dist/cli/content-mapper-DvOSOdTE.js +0 -182
  1176. package/dist/cli/db-CQCLx7cx.js +0 -78
  1177. package/dist/cli/db-DXKyVEDF.js +0 -247
  1178. package/dist/cli/detect-D9JaAX20.js +0 -84
  1179. package/dist/cli/dist-D_VbPAMR.js +0 -129
  1180. package/dist/cli/dist-DuiMMRbJ.js +0 -1112
  1181. package/dist/cli/doctor-Ywy8oJEU.js +0 -4684
  1182. package/dist/cli/env-BK0xKMeU.js +0 -1113
  1183. package/dist/cli/env-Bat6ogep.js +0 -1
  1184. package/dist/cli/env-CNjT_uOV.js +0 -1
  1185. package/dist/cli/env-XMiKvhtV.js +0 -143
  1186. package/dist/cli/errors-BTe6A15O.js +0 -98
  1187. package/dist/cli/exec-Ca5s-ygi.js +0 -463
  1188. package/dist/cli/fastest-levenshtein-dhRRvrM2.js +0 -120
  1189. package/dist/cli/files-CX71yBm8.js +0 -1010
  1190. package/dist/cli/fresh-import-DzgsGHkX.js +0 -40
  1191. package/dist/cli/gen-B-FbQmG1.js +0 -394
  1192. package/dist/cli/guards-CUlDNYZs.js +0 -8
  1193. package/dist/cli/in-stack-diff-Cp-tVPj2.js +0 -186
  1194. package/dist/cli/init-fb9e1BKX.js +0 -559
  1195. package/dist/cli/io-DH1kcmmP.js +0 -37
  1196. package/dist/cli/json5-ChRycquj.js +0 -787
  1197. package/dist/cli/jsonc-C8M0EhHB.js +0 -1
  1198. package/dist/cli/jsonc-D5Fu67jw.js +0 -45
  1199. package/dist/cli/keys-ORiPz1sM.js +0 -106
  1200. package/dist/cli/legacy-prefix-R7UChFFl.js +0 -154
  1201. package/dist/cli/live-DIt7TP-N.js +0 -341
  1202. package/dist/cli/mcp-CVWwraga.js +0 -241
  1203. package/dist/cli/metadata-CannIjel.js +0 -150
  1204. package/dist/cli/migrate-Ht2TzIQF.js +0 -46
  1205. package/dist/cli/migration-safety-nNyB05I-.js +0 -928
  1206. package/dist/cli/migrations-bAd7dpk1.js +0 -117
  1207. package/dist/cli/module-migration-CkNux8dr.js +0 -119
  1208. package/dist/cli/moved-C3WyRHkA.js +0 -254
  1209. package/dist/cli/ohash-BjQY1cBb.js +0 -277
  1210. package/dist/cli/openapi-3.0-t7xwkuRH.js +0 -928
  1211. package/dist/cli/openapi-3.1-CVze7tBS.js +0 -870
  1212. package/dist/cli/openapi-3.2-CFoMYM01.js +0 -1031
  1213. package/dist/cli/orphans-BAboqyVM.js +0 -28
  1214. package/dist/cli/parse-DjHbTaFI.js +0 -182
  1215. package/dist/cli/powersync-B2v0tDwp.js +0 -377
  1216. package/dist/cli/powersync-D3mAQ6QE.js +0 -1
  1217. package/dist/cli/preset-BwmIfFnh.js +0 -101
  1218. package/dist/cli/print-CxQ0rBKT.js +0 -68
  1219. package/dist/cli/prompts-jqnr94b9.js +0 -1140
  1220. package/dist/cli/providers-DtI90lSw.js +0 -301
  1221. package/dist/cli/redact-KGAk2Ul9.js +0 -38
  1222. package/dist/cli/remove-DYtE4IZ4.js +0 -239
  1223. package/dist/cli/render-QGWfEoiB.js +0 -2225
  1224. package/dist/cli/rolldown-runtime-kJ_i4yPo.js +0 -26
  1225. package/dist/cli/run-B5aMwErM.js +0 -63
  1226. package/dist/cli/run-BNoJKf5I.js +0 -706
  1227. package/dist/cli/run-DiYX1XEa.js +0 -1459
  1228. package/dist/cli/seed-C-Hu2n_E.js +0 -188
  1229. package/dist/cli/seed-Cm-c0BDd.js +0 -1
  1230. package/dist/cli/shared-D_CFi5di.js +0 -151
  1231. package/dist/cli/shell-Btv_4Yhe.js +0 -10
  1232. package/dist/cli/skills-D98y0bSB.js +0 -121
  1233. package/dist/cli/snapshot-BlQ4DDcJ.js +0 -734
  1234. package/dist/cli/source-CelMBQMj.js +0 -320
  1235. package/dist/cli/source-args-v8ljFDfc.js +0 -59
  1236. package/dist/cli/spec-BxcoGE0h.js +0 -1
  1237. package/dist/cli/spec-iBx1LcYO.js +0 -7530
  1238. package/dist/cli/sql-layout-Dp4Rottt.js +0 -261
  1239. package/dist/cli/stack-B2slzrYH.js +0 -135
  1240. package/dist/cli/stack-env-3ziggrU3.js +0 -93
  1241. package/dist/cli/stack-status-BkkYRlXG.js +0 -46
  1242. package/dist/cli/stacks-CiDBH1dB.js +0 -232
  1243. package/dist/cli/style-Bm2X5JrN.js +0 -35
  1244. package/dist/cli/supabase-toml-CncmQbO0.js +0 -1164
  1245. package/dist/cli/sync-BnORI43S.js +0 -322
  1246. package/dist/cli/table-D6HUECKI.js +0 -89
  1247. package/dist/cli/toml-DB-MNnFs.js +0 -424
  1248. package/dist/cli/topics-BpdnYmWb.js +0 -30
  1249. package/dist/cli/trace-VbdO6bcN.js +0 -7
  1250. package/dist/cli/upgrade-CR6-WmIc.js +0 -272
  1251. package/dist/cli/upgrade-fz92aCnh.js +0 -41
  1252. package/dist/cli/validate-B3lF3-jB.js +0 -7522
  1253. package/dist/cli/version-Dz8ZlOuh.js +0 -4
  1254. package/dist/cli/yaml-CYCbJ6et.js +0 -2252
  1255. package/dist/client-C_mlji5R.js +0 -288
  1256. package/dist/clone-CkG0-hlI.js +0 -33
  1257. package/dist/cloud-event-0pQ9vFNS.d.ts +0 -64
  1258. package/dist/cloud-event-XsM53POL.js +0 -63
  1259. package/dist/codecs-CMWlhHZ0.d.ts +0 -222
  1260. package/dist/codecs-CSUFGrdP.js +0 -358
  1261. package/dist/compiler-BEeVWXPS.d.ts +0 -14
  1262. package/dist/compose-DKW0Tr3e.js +0 -53
  1263. package/dist/composite-B4qB6k31.js +0 -130
  1264. package/dist/composite-BJ9s-IJJ.d.ts +0 -83
  1265. package/dist/config-B7g-HDis.js +0 -1111
  1266. package/dist/config-R0m0fBiD.js +0 -1679
  1267. package/dist/connectors-uC5baoFV.d.ts +0 -147
  1268. package/dist/context-DBicfUNz.js +0 -41
  1269. package/dist/context-DWWoP1wK.d.ts +0 -4344
  1270. package/dist/controller-BEliOBOv.js +0 -79
  1271. package/dist/controller-Br9dGKGe.d.ts +0 -52
  1272. package/dist/controller-W97g2WGG.js +0 -73
  1273. package/dist/conversion-Dq1S7xzE.js +0 -77
  1274. package/dist/conversion-g8HzH9My.d.ts +0 -86
  1275. package/dist/cors-h_v7TPxl.js +0 -24
  1276. package/dist/cors-kLq6VM06.d.ts +0 -15
  1277. package/dist/create-blocks-BfrDUSM6.js +0 -370
  1278. package/dist/cron-DdT4ti8a.js +0 -148
  1279. package/dist/cron-route-FjKgRvTY.js +0 -24
  1280. package/dist/csv-2rXGPNtP.js +0 -89
  1281. package/dist/csv-DhHQS2x_.d.ts +0 -28
  1282. package/dist/data-engine-D1BkmBoR.js +0 -173
  1283. package/dist/data-engine-rvbR2C4F.d.ts +0 -273
  1284. package/dist/data-hooks-CdcZfVS1.js +0 -280
  1285. package/dist/db-exception-Lngc1W49.js +0 -31
  1286. package/dist/deal-forecast-CKBnRodz.js +0 -39
  1287. package/dist/deal-forecast-LwO-Z4_C.d.ts +0 -23
  1288. package/dist/define-D-dLADd5.js +0 -2084
  1289. package/dist/define-D8_9X5fZ.d.ts +0 -1263
  1290. package/dist/define-block-BGqOO8B3.js +0 -64
  1291. package/dist/define-block-DWVZSZv1.d.ts +0 -1687
  1292. package/dist/delegation-C7eWP2r8.d.ts +0 -14
  1293. package/dist/delegation-DGOIiT8k.js +0 -153
  1294. package/dist/delivery-Bm0jxmzI.js +0 -29
  1295. package/dist/delivery-events-DbL8IHIY.js +0 -53
  1296. package/dist/delivery-n6lZGuGx.d.ts +0 -71
  1297. package/dist/documents-BbwYyynk.d.ts +0 -152
  1298. package/dist/email-B3YxEzwC.d.ts +0 -42
  1299. package/dist/embeddings-I3s5sTDt.d.ts +0 -78
  1300. package/dist/embeddings-vVzseUw0.js +0 -128
  1301. package/dist/ended-EZzN9QTM.d.ts +0 -26
  1302. package/dist/entitlements-CBjm2lvD.d.ts +0 -54
  1303. package/dist/entitlements-tGL6-69B.js +0 -45
  1304. package/dist/entity-naming-Dtyq5sKE.js +0 -131
  1305. package/dist/entity-schema-B1YmMtP8.js +0 -39
  1306. package/dist/envelope-DEI2iX-d.js +0 -90
  1307. package/dist/errors-BVFgt8BZ.js +0 -328
  1308. package/dist/errors-CyxMxzlu.js +0 -44
  1309. package/dist/escape-like-DHfx6jRr.js +0 -7
  1310. package/dist/escape-like-PReMbEEU.d.ts +0 -30
  1311. package/dist/eve-BfhVFV33.d.ts +0 -157
  1312. package/dist/event-calendar-DVLs2wUO.d.ts +0 -65
  1313. package/dist/event-map-CtPFhcOp.js +0 -19
  1314. package/dist/events-B2qbZps6.d.ts +0 -854
  1315. package/dist/events-D6IZ5CE8.js +0 -82
  1316. package/dist/events-DuLhzjP6.js +0 -26
  1317. package/dist/executor-BfirBzOr.d.ts +0 -174
  1318. package/dist/executor-BlS0kCrN.d.ts +0 -104
  1319. package/dist/executor-C2Ne-Scm.js +0 -208
  1320. package/dist/executor-DXQIx4sW.d.ts +0 -37
  1321. package/dist/executor-DqIci3Jb.js +0 -486
  1322. package/dist/executor-WolvKszH.js +0 -843
  1323. package/dist/extension-DTaHjwdc.js +0 -59
  1324. package/dist/extension-DeAd_MqI.js +0 -121
  1325. package/dist/extension-DzCc0IOd.js +0 -103
  1326. package/dist/extension-mGylYROs.js +0 -53
  1327. package/dist/extension-shared-Djm8mGHD.js +0 -60
  1328. package/dist/extra-CGQ2_q3S.js +0 -10
  1329. package/dist/field-errors-CEjsMAgd.d.ts +0 -216
  1330. package/dist/field-formats-C6QKA3UR.js +0 -102
  1331. package/dist/field-formats-CAFNkKSN.d.ts +0 -38
  1332. package/dist/fields-BBm49w-E.js +0 -108
  1333. package/dist/fields-snbaZ14h.d.ts +0 -78
  1334. package/dist/filter-evaluate-BRpNiNPG.d.ts +0 -37
  1335. package/dist/filter-evaluate-lCToXzZI.js +0 -217
  1336. package/dist/filter-query-CQ6d5GnQ.js +0 -566
  1337. package/dist/filter-query-DBt7OKuH.d.ts +0 -133
  1338. package/dist/flags-DDKTThrO.d.ts +0 -246
  1339. package/dist/flags-DF_SCqp5.js +0 -279
  1340. package/dist/form-definition-BTpM_tz1.js +0 -363
  1341. package/dist/form-definition-BjEtH8BT.d.ts +0 -119
  1342. package/dist/format-u-65igKI.d.ts +0 -79
  1343. package/dist/framework-CqiZk89W.js +0 -58
  1344. package/dist/framework-DVYTtQXA.d.ts +0 -47
  1345. package/dist/function-contract-DxFNOmsm.d.ts +0 -27
  1346. package/dist/function-contract-pEmsaUIf.js +0 -8
  1347. package/dist/gateway-Ve7cByEr.d.ts +0 -115
  1348. package/dist/gateway-options-BlVCqgb8.d.ts +0 -29
  1349. package/dist/gateway-options-Cl74B7k6.js +0 -27
  1350. package/dist/guards-6F2bCtQR.js +0 -12
  1351. package/dist/guest-actions-1T1DeS5Y.d.ts +0 -5
  1352. package/dist/guest-actions-B7zdhfnh.js +0 -9
  1353. package/dist/history-GH1HJWQV.js +0 -271
  1354. package/dist/hmac-B3CTTlfv.js +0 -23
  1355. package/dist/http-7-UvHjQe.js +0 -28
  1356. package/dist/http-BjjojWg3.js +0 -40
  1357. package/dist/http-DzbloBR-.js +0 -141
  1358. package/dist/image-url-_d7xYsXK.js +0 -84
  1359. package/dist/impersonation-DM3oWNoD.js +0 -62
  1360. package/dist/impersonation-YTa9dZUv.d.ts +0 -28
  1361. package/dist/inbox-c8B86Trp.d.ts +0 -321
  1362. package/dist/index-B4wttiLh.d.ts +0 -407
  1363. package/dist/index-Clyd2Goi.d.ts +0 -338
  1364. package/dist/index-Cxsnd-OL.d.ts +0 -305
  1365. package/dist/index-D98bQs8a.d.ts +0 -665
  1366. package/dist/index-DIdPoQtO.d.ts +0 -240
  1367. package/dist/index-DbyDZZlc.d.ts +0 -53
  1368. package/dist/index-I8YLxKq8.d.ts +0 -729
  1369. package/dist/index-NRMMhhEi.d.ts +0 -104
  1370. package/dist/index-X2fkPUwb.d.ts +0 -51
  1371. package/dist/index-eRBuKtMt.d.ts +0 -158
  1372. package/dist/index-pZn6S_iq.d.ts +0 -149
  1373. package/dist/index-uIU65iEn.d.ts +0 -588
  1374. package/dist/instance-property-hRh88y_s.js +0 -7
  1375. package/dist/instances-DY_ORk5g.js +0 -16605
  1376. package/dist/invalidate-DMp4eqfF.d.ts +0 -21
  1377. package/dist/iso4217-B-durg_y.js +0 -176
  1378. package/dist/json-DaByVJpw.js +0 -22
  1379. package/dist/json-schema-DHJxiizN.js +0 -888
  1380. package/dist/jwks-cache-DEsKI0hJ.js +0 -49
  1381. package/dist/jws-D0toeQlA.d.ts +0 -66
  1382. package/dist/jws-DOgHJKHb.js +0 -205
  1383. package/dist/kit-B8yWCRN7.d.ts +0 -94
  1384. package/dist/kit-Bcd9wYCV.js +0 -133
  1385. package/dist/knowledge-CsLPACGJ.d.ts +0 -217
  1386. package/dist/knowledge-tCrrU99q.js +0 -300
  1387. package/dist/list-query-BcU8NnNL.d.ts +0 -222
  1388. package/dist/list-query-BnpA2BDg.js +0 -559
  1389. package/dist/live-C21DgbsD.js +0 -275
  1390. package/dist/logger-DWVYUmwi.d.ts +0 -18
  1391. package/dist/logger-glM28NVN.js +0 -21
  1392. package/dist/lookup-BaP5bI27.js +0 -18
  1393. package/dist/management-wtecfrNf.d.ts +0 -57
  1394. package/dist/message-Bg4TKA12.d.ts +0 -99
  1395. package/dist/messages-ecPW_nOv.js +0 -492
  1396. package/dist/messaging-DQP09JsY.d.ts +0 -297
  1397. package/dist/methods-Cund9ZBe.js +0 -11
  1398. package/dist/metric-definition-BjxVn4R5.js +0 -117
  1399. package/dist/metric-definition-EAYI1r2n.d.ts +0 -69
  1400. package/dist/mfa-oIOYTpvc.d.ts +0 -36
  1401. package/dist/model-hwpvole9.d.ts +0 -340
  1402. package/dist/model-messages-CkZSDDHP.js +0 -206
  1403. package/dist/model-messages-DrR4lZ_c.d.ts +0 -34
  1404. package/dist/money-BNRdJQzA.d.ts +0 -91
  1405. package/dist/money-BZl985O-.js +0 -197
  1406. package/dist/money-codec-BJuS2zEW.js +0 -41
  1407. package/dist/my-work-kinds-BU3SlA-6.js +0 -11
  1408. package/dist/node-headers-BPtMP4_V.d.ts +0 -27
  1409. package/dist/node-headers-C71zNQHe.js +0 -55
  1410. package/dist/operations-DVHRHvv6.js +0 -29
  1411. package/dist/operations-hm1Isvvs.d.ts +0 -6
  1412. package/dist/optional-peer-C1NbBRJm.js +0 -32
  1413. package/dist/options-3OYOU56e.js +0 -11
  1414. package/dist/options-56zYYXxc.js +0 -10
  1415. package/dist/options-5WvWOkAm.d.ts +0 -26
  1416. package/dist/options-62woPFn3.js +0 -12
  1417. package/dist/options-7ixoOoap.js +0 -10
  1418. package/dist/options-9dSU5RML.js +0 -5
  1419. package/dist/options-B0YZtAkb.d.ts +0 -15
  1420. package/dist/options-B2Kz_tCx.js +0 -10
  1421. package/dist/options-B5E2MGIz.js +0 -15
  1422. package/dist/options-B685YSzQ.js +0 -5
  1423. package/dist/options-B692WoK6.js +0 -9
  1424. package/dist/options-BHU1wc74.js +0 -5
  1425. package/dist/options-BHy0Z5Zd.js +0 -5
  1426. package/dist/options-BJtdsK7b.js +0 -8
  1427. package/dist/options-BKDxrPvE.js +0 -5
  1428. package/dist/options-BLfymS4s.js +0 -5
  1429. package/dist/options-BOCRbzh3.js +0 -5
  1430. package/dist/options-BOqfYsM1.js +0 -13
  1431. package/dist/options-BQWJqwHO.js +0 -9
  1432. package/dist/options-BQunK6_Y.js +0 -8
  1433. package/dist/options-BQyrZjwM.js +0 -28
  1434. package/dist/options-BR9xTHZW.js +0 -5
  1435. package/dist/options-BRUdd5jY.js +0 -8
  1436. package/dist/options-BSsYXjhC.js +0 -9
  1437. package/dist/options-BTmaRzx2.d.ts +0 -60
  1438. package/dist/options-BUCQYAeJ.d.ts +0 -10
  1439. package/dist/options-B_NrjVDt.d.ts +0 -12
  1440. package/dist/options-BawzwlmC.js +0 -11
  1441. package/dist/options-BbLDAp7G.d.ts +0 -10
  1442. package/dist/options-BfPsL7E2.js +0 -9
  1443. package/dist/options-Bfmwwc78.js +0 -8
  1444. package/dist/options-BhsdveDk.js +0 -21
  1445. package/dist/options-BomoTH-8.js +0 -5
  1446. package/dist/options-BtjkzIVh.js +0 -8
  1447. package/dist/options-Bvi9bl4H.js +0 -5
  1448. package/dist/options-BwKNmaJo.js +0 -5
  1449. package/dist/options-BxpLtyk-.js +0 -18
  1450. package/dist/options-BzB2QxL3.js +0 -5
  1451. package/dist/options-C078wBP0.js +0 -5
  1452. package/dist/options-C3AdsFJ6.js +0 -9
  1453. package/dist/options-C7C5OhmL.d.ts +0 -8
  1454. package/dist/options-C87u6eSa.js +0 -10
  1455. package/dist/options-CBAEGxwS.js +0 -8
  1456. package/dist/options-CDSCkYxu.d.ts +0 -14
  1457. package/dist/options-CDUr8zzX.js +0 -8
  1458. package/dist/options-CF6EVF_G.js +0 -17
  1459. package/dist/options-CFjGxfa8.js +0 -5
  1460. package/dist/options-CI6P0xhV.js +0 -10
  1461. package/dist/options-CJFMK9A_.js +0 -8
  1462. package/dist/options-CLpgx7en.js +0 -10
  1463. package/dist/options-CSCXNYJO.d.ts +0 -8
  1464. package/dist/options-CTXHj9zr.js +0 -16
  1465. package/dist/options-CTl8T88w.js +0 -11
  1466. package/dist/options-CUIOOv4z.js +0 -15
  1467. package/dist/options-CZDmtsbV.js +0 -8
  1468. package/dist/options-CZTscdPB.js +0 -5
  1469. package/dist/options-CZdKndeo.js +0 -9
  1470. package/dist/options-C_7g9TTq.d.ts +0 -12
  1471. package/dist/options-Cb2FOFj5.js +0 -5
  1472. package/dist/options-CbOstLa7.js +0 -5
  1473. package/dist/options-CcXgWlvm.js +0 -24
  1474. package/dist/options-CfVPctAw.js +0 -89
  1475. package/dist/options-Cjgaf8ub.js +0 -8
  1476. package/dist/options-CoSPgWKy.js +0 -9
  1477. package/dist/options-CpZ2HlSU.js +0 -32
  1478. package/dist/options-CsSe8Nba.js +0 -8
  1479. package/dist/options-CsvJR-r2.js +0 -9
  1480. package/dist/options-Cucv6sWP.js +0 -12
  1481. package/dist/options-CyjL9lTf.js +0 -5
  1482. package/dist/options-D-OOO9V2.d.ts +0 -10
  1483. package/dist/options-D0Y6ZMe8.js +0 -5
  1484. package/dist/options-D0bzZx9a.d.ts +0 -10
  1485. package/dist/options-D0sj5abR.js +0 -9
  1486. package/dist/options-D1hSuf50.d.ts +0 -12
  1487. package/dist/options-D610Fa6T.js +0 -5
  1488. package/dist/options-D96dScev.js +0 -24
  1489. package/dist/options-DFpyP1bg.js +0 -5
  1490. package/dist/options-DJEcS4DX.js +0 -5
  1491. package/dist/options-DJbN3bi9.js +0 -11
  1492. package/dist/options-DKoQoRCy.js +0 -13
  1493. package/dist/options-DM1qaMMQ.js +0 -9
  1494. package/dist/options-DNgSwhsm.js +0 -11
  1495. package/dist/options-DOIwzRXL.js +0 -16
  1496. package/dist/options-DRIgHh4O.d.ts +0 -16
  1497. package/dist/options-DRrZmJyI.js +0 -8
  1498. package/dist/options-DSCW40_5.js +0 -12
  1499. package/dist/options-DUMUsvml.js +0 -5
  1500. package/dist/options-DWwL5Kaz.js +0 -9
  1501. package/dist/options-DZHZYlpD.js +0 -10
  1502. package/dist/options-DZLkeqWn.js +0 -9
  1503. package/dist/options-DZRpXKQE.js +0 -5
  1504. package/dist/options-DZen3UiC.js +0 -14
  1505. package/dist/options-D_9Vxx7f.js +0 -8
  1506. package/dist/options-DcHl59RC.js +0 -11
  1507. package/dist/options-Dcaql09y.js +0 -11
  1508. package/dist/options-DcnBNYmV.js +0 -8
  1509. package/dist/options-DdpM-fiP.js +0 -9
  1510. package/dist/options-DhoLMknl.js +0 -10
  1511. package/dist/options-DlohRAYd.d.ts +0 -13
  1512. package/dist/options-Dpy-Ruo-.js +0 -14
  1513. package/dist/options-DsVuVRH3.d.ts +0 -17
  1514. package/dist/options-DtAJxfHS.js +0 -8
  1515. package/dist/options-Dz9Yo52Z.js +0 -8
  1516. package/dist/options-HnfETSHr.d.ts +0 -19
  1517. package/dist/options-LqUXTpML.js +0 -8
  1518. package/dist/options-MsloEAIB.js +0 -5
  1519. package/dist/options-P2FxqYpd.js +0 -17
  1520. package/dist/options-_1gAIMq7.d.ts +0 -60
  1521. package/dist/options-aT89JqlB.js +0 -5
  1522. package/dist/options-cVKZu9b0.js +0 -9
  1523. package/dist/options-eTepQ1rZ.js +0 -15
  1524. package/dist/options-fkShrmGQ.js +0 -8
  1525. package/dist/options-gUvfr3no.js +0 -11
  1526. package/dist/options-hynwKWuf.js +0 -20
  1527. package/dist/options-jsOCvLUz.js +0 -10
  1528. package/dist/options-o5wCw8H7.d.ts +0 -14
  1529. package/dist/options-p49DFg3H.js +0 -8
  1530. package/dist/options-pYNpXKcg.js +0 -8
  1531. package/dist/options-qtETCHzW.js +0 -10
  1532. package/dist/options-rnKlqYEr.js +0 -5
  1533. package/dist/options-sU_zGkiV.js +0 -10
  1534. package/dist/options-xq4MXG1M.js +0 -5
  1535. package/dist/options-zzlznRA7.js +0 -10
  1536. package/dist/outbox-BZ712Z3X.d.ts +0 -199
  1537. package/dist/payments-BXvabJOw.js +0 -16
  1538. package/dist/payments-BYcN34Fp.d.ts +0 -114
  1539. package/dist/permissions-controller-BMsqIE5T.js +0 -34
  1540. package/dist/pg-error-B5QLDcbG.js +0 -26
  1541. package/dist/plugin-AKwwe2gF.js +0 -48
  1542. package/dist/pool-DDR1ndk7.d.ts +0 -123
  1543. package/dist/pool-errors-JUBcGrre.js +0 -27
  1544. package/dist/ports-DOrPTJzl.d.ts +0 -89
  1545. package/dist/ports-DvpNseap.js +0 -152
  1546. package/dist/postgrest-AJc8hnJU.d.ts +0 -53
  1547. package/dist/postgrest-executor-B_Uezhrm.js +0 -1068
  1548. package/dist/preset-CXhpPmPV.js +0 -1042
  1549. package/dist/problem-Bf0cJ7tk.js +0 -162
  1550. package/dist/problem-DNwN8iGz.d.ts +0 -79
  1551. package/dist/project-DJ9Uo0sT.js +0 -1760
  1552. package/dist/provider-B6g7rBZX.js +0 -57
  1553. package/dist/provider-CWjzAIX9.d.ts +0 -112
  1554. package/dist/push-token-B4vcIU4s.d.ts +0 -24
  1555. package/dist/push-token-D6REHMMw.js +0 -16
  1556. package/dist/queries-BWYYS9um.js +0 -239
  1557. package/dist/range-DwpWe8e7.js +0 -7
  1558. package/dist/range-p5V4rBhZ.d.ts +0 -8
  1559. package/dist/rank-keys-DcPMt_Jk.js +0 -60
  1560. package/dist/rank-result-BBJIK-k_.js +0 -18
  1561. package/dist/rank-result-Bwe7igy-.d.ts +0 -14
  1562. package/dist/rate-limit-BWKGlhTM.js +0 -49
  1563. package/dist/rate-limit-Bztf32cl.d.ts +0 -50
  1564. package/dist/rate-limit-fZ_d8gSE.js +0 -380
  1565. package/dist/ratelimit-headers-kEcXyO3H.js +0 -62
  1566. package/dist/react-BKCnIuZs.js +0 -79
  1567. package/dist/react-mdVjpewL.js +0 -1016
  1568. package/dist/read-set-B1sDib5O.js +0 -199
  1569. package/dist/realtime-status-BhNkb-Ow.d.ts +0 -8
  1570. package/dist/realtime-status-asHvhiOh.js +0 -11
  1571. package/dist/record-bindings-Z51mGfhB.js +0 -26
  1572. package/dist/record-form-CubgBrtI.d.ts +0 -82
  1573. package/dist/record-type-BEUyEsFx.js +0 -221
  1574. package/dist/recordings-DeZYx-Kv.d.ts +0 -119
  1575. package/dist/refresh-D02Pbf5B.d.ts +0 -54
  1576. package/dist/refresh-DLBgnxjL.js +0 -144
  1577. package/dist/refusal-B0VmlAxF.d.ts +0 -32
  1578. package/dist/refusal-DDlInPff.js +0 -64
  1579. package/dist/relay-CIKcAVjf.js +0 -248
  1580. package/dist/resolve-B0mW2m7f.js +0 -932
  1581. package/dist/resolve-CtX6T0c0.d.ts +0 -288
  1582. package/dist/resolved-names-kMRjmSIy.js +0 -133
  1583. package/dist/resource-BUJcZKiW.js +0 -520
  1584. package/dist/resource-DvgXqZB_.js +0 -105
  1585. package/dist/resource-WxN0IsvB.d.ts +0 -123
  1586. package/dist/resource-execute-BzqR8DdD.d.ts +0 -15
  1587. package/dist/resource-schemas-up6bKOUi.js +0 -82
  1588. package/dist/resource-types-BVbHgTPg.d.ts +0 -157
  1589. package/dist/resources-BSbRa0Ab.d.ts +0 -7
  1590. package/dist/resources-jb3R6rEa.js +0 -64
  1591. package/dist/respond-CZMWbUs3.js +0 -107
  1592. package/dist/respond-Dzu_-EPH.d.ts +0 -112
  1593. package/dist/result-DZeA5KS6.d.ts +0 -351
  1594. package/dist/result-ntFBW2p2.js +0 -146
  1595. package/dist/rows-BdqXmiB-.js +0 -80
  1596. package/dist/rows-jijHLVE_.js +0 -39
  1597. package/dist/rrule-C9Ot6ax8.js +0 -290
  1598. package/dist/run-state-BMCD_1Lt.d.ts +0 -13
  1599. package/dist/run-state-CgBKzYMW.js +0 -13
  1600. package/dist/run-watch-B-LoK5m1.js +0 -53
  1601. package/dist/runtime-LRJM7UqY.js +0 -44
  1602. package/dist/sales-lines-BsmrNHe9.d.ts +0 -38
  1603. package/dist/sales-lines-DO7oRu1o.js +0 -45
  1604. package/dist/sales-shared-BuTA8JK7.js +0 -22
  1605. package/dist/schemas-CLOTvdsC.js +0 -216
  1606. package/dist/scope-DgWjuXUw.js +0 -90
  1607. package/dist/scores-Y8TvyJi1.d.ts +0 -174
  1608. package/dist/scores-bY2Is0kx.js +0 -177
  1609. package/dist/search-Cn_DGluL.js +0 -9
  1610. package/dist/server-types-BkTIxW_H.d.ts +0 -597
  1611. package/dist/session-BOzx2qHC.d.ts +0 -100
  1612. package/dist/session-status-BP8eYVnA.d.ts +0 -82
  1613. package/dist/shared-BeHTi8Fu.js +0 -17
  1614. package/dist/shared-Bf-I13Ht.js +0 -91
  1615. package/dist/shared-CRRfQAKG.d.ts +0 -11
  1616. package/dist/sign-in-BzihC_8k.d.ts +0 -50
  1617. package/dist/sign-in-CmPK1AgM.js +0 -402
  1618. package/dist/sign-in-CuZ1Ag7O.js +0 -718
  1619. package/dist/sign-in-D54FLMQy.d.ts +0 -55
  1620. package/dist/signatures-CX1b4WHa.js +0 -145
  1621. package/dist/signatures-Dkx9OE8j.d.ts +0 -43
  1622. package/dist/signers-ZmxO1I05.d.ts +0 -390
  1623. package/dist/signing-keys-CWtpMask.js +0 -164
  1624. package/dist/signing-keys-udgP7Aod.d.ts +0 -119
  1625. package/dist/simplify-DDO0j0LI.js +0 -83
  1626. package/dist/spec-BMvCCNnd.js +0 -124
  1627. package/dist/spec-pins-BZkKfwY8.d.ts +0 -127
  1628. package/dist/spec-pins-D3zDek-u.js +0 -62
  1629. package/dist/sql-CYt7EhH0.js +0 -421
  1630. package/dist/sql-DHp0L7zK.js +0 -138385
  1631. package/dist/sql-type-iUSZpaUu.js +0 -34
  1632. package/dist/sso-CkU_4mtK.d.ts +0 -161
  1633. package/dist/sso-DdDpJQzw.js +0 -217
  1634. package/dist/standard-BA3mLh6w.js +0 -25
  1635. package/dist/standard-DBV730sF.d.ts +0 -7
  1636. package/dist/stats-BHl1-zj9.js +0 -83
  1637. package/dist/statuses-Alll5Ip6.js +0 -29
  1638. package/dist/statuses-zRcc2TeZ.js +0 -28
  1639. package/dist/storage-api-Dg78Wqsg.js +0 -10
  1640. package/dist/store-CpheI-lN.d.ts +0 -83
  1641. package/dist/store-McN-2esd.js +0 -69
  1642. package/dist/stripe-BJUfp5jM.js +0 -32
  1643. package/dist/stripe-X22LjuH-.d.ts +0 -156
  1644. package/dist/subject-readers-CB5Te02u.d.ts +0 -21
  1645. package/dist/subject-readers-VHcrWhmq.js +0 -49
  1646. package/dist/subject-type-BRnK7Av3.js +0 -8
  1647. package/dist/subjects-BYCL-6hA.d.ts +0 -145
  1648. package/dist/subjects-CiBNKy2y.d.ts +0 -90
  1649. package/dist/subscribers-BvZxcd63.js +0 -33
  1650. package/dist/summaries-8jQTELIX.d.ts +0 -69
  1651. package/dist/supabase-mcp-Dz9DgrKP.js +0 -28
  1652. package/dist/supabase-mcp-Z4vtsuoO.d.ts +0 -46
  1653. package/dist/support-BxyPOFk4.d.ts +0 -357
  1654. package/dist/support-view-g4YLBeqX.js +0 -18
  1655. package/dist/support-view-nqUWKHEs.d.ts +0 -17
  1656. package/dist/table-schema-BlF6k62Q.d.ts +0 -81
  1657. package/dist/table-schema-C80xItaV.js +0 -293
  1658. package/dist/tables-Cb-3_VWc.js +0 -73
  1659. package/dist/tags-CIZTqtlY.js +0 -39
  1660. package/dist/tags-Cm48BsOa.d.ts +0 -30
  1661. package/dist/tax-BkCNWWMc.js +0 -140
  1662. package/dist/tax-DPShHual.d.ts +0 -170
  1663. package/dist/tee-V97_v1ZS.js +0 -101
  1664. package/dist/template-Drgg3v2J.js +0 -126
  1665. package/dist/temporal-Dbo0fLzc.js +0 -95
  1666. package/dist/temporal-required-DcLhnDhQ.js +0 -20
  1667. package/dist/tenant-BgIiMQpo.js +0 -27
  1668. package/dist/tenant-FfgNhd5x.d.ts +0 -17
  1669. package/dist/tenant-source-bqWpSr86.js +0 -8
  1670. package/dist/timeline-DqEoD8bb.d.ts +0 -151
  1671. package/dist/timeline-Dz3hO2I6.js +0 -50
  1672. package/dist/timing-dypS0nxW.js +0 -95
  1673. package/dist/topic-BaUElNw2.d.ts +0 -415
  1674. package/dist/topic-DnsNG4Kj.js +0 -643
  1675. package/dist/ttl-cache-Bhr9swjT.js +0 -32
  1676. package/dist/types-B-D6fYx2.d.ts +0 -194
  1677. package/dist/types-CK2X2wCB.d.ts +0 -618
  1678. package/dist/types-CMN0h_Ix.d.ts +0 -461
  1679. package/dist/types-CPl9uJ0G.d.ts +0 -912
  1680. package/dist/types-CwQgFo8c.d.ts +0 -177
  1681. package/dist/types-DMihLukJ.d.ts +0 -251
  1682. package/dist/types-R6syp1el.js +0 -29
  1683. package/dist/types-iCyZ3lMx.d.ts +0 -217
  1684. package/dist/types-nspa5I-a.d.ts +0 -664
  1685. package/dist/undo-0HkWXASn.d.ts +0 -46
  1686. package/dist/undo-BbftL9-4.js +0 -44
  1687. package/dist/upload-claim-B1ZU8ydB.js +0 -33
  1688. package/dist/usage-BkWAPkg2.d.ts +0 -232
  1689. package/dist/user-change-DgWC6RRC.js +0 -135
  1690. package/dist/variants-Cy--Ub-a.js +0 -53
  1691. package/dist/vault-BkdPmL7f.d.ts +0 -62
  1692. package/dist/verify-41mZmspj.d.ts +0 -146
  1693. package/dist/verify-7EucfCnv.js +0 -130
  1694. package/dist/view-C8Ve14ja.js +0 -247
  1695. package/dist/view-C8_xvD-j.d.ts +0 -97
  1696. package/dist/watch-topic-BabDTZ-L.d.ts +0 -31
  1697. package/dist/watch-topic-CuaWfCuv.js +0 -57
  1698. package/dist/wire-ChYn1g21.js +0 -91
  1699. package/dist/wiring-CDNuQoJJ.js +0 -13
  1700. package/dist/workflow-sdk-Cf0LAOFF.js +0 -242
  1701. package/dist/workflow-sdk-DJJkP0dT.js +0 -2545
  1702. package/dist/workflow-sdk-rg3IbCZC.d.ts +0 -163
  1703. package/dist/workflows-xL6t0TXx.d.ts +0 -258
@@ -0,0 +1,2073 @@
1
+ import { r as isPlainObject, t as cloneValue } from "./clone-H_gCsL29.js";
2
+ import { t as DbException } from "./db-exception-Dv18UZ-I.js";
3
+ import { n as dbError } from "./errors-B7tCfCvX.js";
4
+ import { n as isRecord, t as isList } from "./guards-CsRa6v57.js";
5
+ import { c as optionalTemporal, l as provideTemporal, s as nowInstant, u as providedTemporal } from "./temporal-DKTdGK9i.js";
6
+ import { n as invalidRequest, t as builderFor } from "./build-D1-V9dd8.js";
7
+ import { t as lookupOf } from "./lookup-upE-e1zw.js";
8
+ import { i as or, n as column, r as not, t as and } from "./types-DnrJ_crV.js";
9
+ import { a as encodeArguments, n as decodeScalar, o as encodeValue, r as decodeValue } from "./wire-DIoLA8VL.js";
10
+ import { t as isStorageApi } from "./storage-api-COQr77e8.js";
11
+ import { a as ok, c as withErrorMapper, r as err, s as toDbError, t as AsyncResult } from "./result-8xza7w5W.js";
12
+ import { t as invalidationTargets } from "./tables-BSiVuKKx.js";
13
+ import { t as instanceProperty } from "./instance-property-BlH7QSDl.js";
14
+ import { t as vectorLiteral } from "./search-DtbkD0h0.js";
15
+ import { t as consoleLogger } from "./logger-BkF8ukXV.js";
16
+ import { n as errorEvent, t as EventHub } from "./events-Da482tiF.js";
17
+ import { i as orderPlugins } from "./plugin-Ca2qBiFZ.js";
18
+ import { t as simplify } from "./simplify-BzThKn5b.js";
19
+ import { a as invalidTuning, i as deadline, n as postgrestExecutor, o as tuningOf, r as NO_TUNING } from "./postgrest-executor-lf8Mt4J0.js";
20
+ import { n as isQuerySpec, r as specTables, t as createSpecs } from "./spec-6Vr7sc0Z.js";
21
+ import { n as checkParams, o as isReadSet, r as containsPlaceholder, t as bindParams } from "./read-set-DEDoIHMM.js";
22
+ import { a as toBase64Url, t as base64ToText } from "./base64-CVyKHBBw.js";
23
+ import { n as validate } from "./standard-BD2aOUsf.js";
24
+ import { n as StatsRecorder, r as recordStats } from "./stats-BTJgRMEp.js";
25
+ // src/core/batch.ts
26
+ /**
27
+ * A signal that aborts once every reader's signal has, so one reader giving up
28
+ * never cancels the operations of the others. `undefined` when a reader has no
29
+ * signal.
30
+ */
31
+ function allAborted(signals) {
32
+ const present = signals.filter((signal) => signal !== void 0);
33
+ if (present.length < signals.length) return;
34
+ if (present.length === 1) return present[0];
35
+ const controller = new AbortController();
36
+ const check = () => {
37
+ if (present.every((signal) => signal.aborted)) controller.abort();
38
+ };
39
+ for (const signal of present) signal.addEventListener("abort", check, { once: true });
40
+ check();
41
+ return controller.signal;
42
+ }
43
+ /**
44
+ * Holds operations until each of `readers` has either submitted one or
45
+ * finished, then runs the held ones through `batch` together. A reader that
46
+ * runs a second operation joins the next batch.
47
+ */
48
+ function batchingExecutor(base, readers) {
49
+ let running = readers;
50
+ const queue = [];
51
+ const flush = () => {
52
+ if (queue.length === 0 || queue.length < running) return;
53
+ const items = queue.splice(0);
54
+ const { signal: _first, ...shared } = items[0].context;
55
+ const signal = allAborted(items.map((item) => item.context.signal));
56
+ const context = signal ? {
57
+ ...shared,
58
+ signal
59
+ } : shared;
60
+ for (const item of items) item.context.signal?.addEventListener("abort", () => {
61
+ item.resolve(err(dbError("aborted", "The request was aborted")));
62
+ }, { once: true });
63
+ base.batch(items.map((item) => item.op), context).then((results) => {
64
+ for (const [index, item] of items.entries()) item.resolve(results[index] ?? err(toDbError(/* @__PURE__ */ new Error(`Executor "${base.name}" returned too few results`))));
65
+ return results;
66
+ }, (cause) => {
67
+ for (const item of items) item.resolve(err(toDbError(cause)));
68
+ return cause;
69
+ });
70
+ };
71
+ return {
72
+ executor: {
73
+ name: base.name,
74
+ execute: (op, context) => new Promise((resolve) => {
75
+ queue.push({
76
+ op,
77
+ context,
78
+ resolve
79
+ });
80
+ flush();
81
+ }),
82
+ ...base.rpc ? { rpc: base.rpc.bind(base) } : {}
83
+ },
84
+ done: () => {
85
+ running -= 1;
86
+ flush();
87
+ }
88
+ };
89
+ }
90
+ // src/core/cache.ts
91
+ /** Primary key of a row as a string, or `undefined` when it isn't returned. */
92
+ function rowKey(table, row) {
93
+ if (table.primaryKey.length === 0) return;
94
+ const parts = table.primaryKey.map((column) => row[column]);
95
+ if (parts.some((part) => part === void 0 || part === null)) return;
96
+ return parts.map(String).join(",");
97
+ }
98
+ function cacheTargetOf(meta, notice) {
99
+ const table = meta.tables[notice.table];
100
+ const rows = notice.rows.length > 0 ? notice.rows : notice.keys ?? [];
101
+ const ids = table ? [...new Set(rows.flatMap((row) => rowKey(table, row) ?? []))] : [];
102
+ const tenant = notice.tenant ?? notice.context.tenant;
103
+ return {
104
+ table: notice.table,
105
+ tables: notice.kind === "delete" ? invalidationTargets(meta, notice.table) : [notice.table],
106
+ ids,
107
+ ...tenant === void 0 ? {} : { tenant }
108
+ };
109
+ }
110
+ /** One target per table an RPC changes; RPCs report no row ids. */
111
+ function rpcCacheTargets(meta, notice) {
112
+ const tenant = notice.context.tenant;
113
+ return notice.invalidates.map((table) => ({
114
+ table,
115
+ tables: invalidationTargets(meta, table),
116
+ ids: [],
117
+ ...tenant === void 0 ? {} : { tenant }
118
+ }));
119
+ }
120
+ /** Records invalidations. For tests and for checking what a mutation touches. */
121
+ function memoryCache() {
122
+ const invalidated = [];
123
+ return {
124
+ name: "memory",
125
+ invalidated,
126
+ invalidate: (target) => {
127
+ invalidated.push(target);
128
+ },
129
+ clear: () => {
130
+ invalidated.length = 0;
131
+ }
132
+ };
133
+ }
134
+ // src/core/db-blocks.ts
135
+ /**
136
+ * A prototype for every `Db` of a definition, with one getter per block
137
+ * instance (skipping those whose property a table holds) and `$blocks` with all
138
+ * of them. Each getter builds the instance's client for the `Db` it is read on,
139
+ * once, so `$with` and every request get their own.
140
+ */
141
+ function blocksPrototype(source, parent, tables, events, temporal) {
142
+ const prototype = Object.create(parent);
143
+ const built = /* @__PURE__ */ new WeakMap();
144
+ const clientOf = (db, key) => {
145
+ let clients = built.get(db);
146
+ if (clients === void 0) {
147
+ clients = /* @__PURE__ */ new Map();
148
+ built.set(db, clients);
149
+ }
150
+ if (!clients.has(key)) clients.set(key, source.client(db, key, {
151
+ events,
152
+ ...temporal === void 0 ? {} : { temporal }
153
+ }));
154
+ return clients.get(key);
155
+ };
156
+ const views = /* @__PURE__ */ new WeakMap();
157
+ for (const key of source.instances) {
158
+ const property = instanceProperty(key);
159
+ if (tables.includes(property)) continue;
160
+ Object.defineProperty(prototype, property, {
161
+ get() {
162
+ return clientOf(this, key);
163
+ },
164
+ configurable: true,
165
+ enumerable: false
166
+ });
167
+ }
168
+ Object.defineProperty(prototype, "$blocks", {
169
+ get() {
170
+ let view = views.get(this);
171
+ if (view === void 0) {
172
+ view = Object.defineProperties({}, Object.fromEntries(source.instances.map((key) => [instanceProperty(key), {
173
+ get: () => clientOf(this, key),
174
+ enumerable: true
175
+ }])));
176
+ views.set(this, view);
177
+ }
178
+ return view;
179
+ },
180
+ configurable: true,
181
+ enumerable: false
182
+ });
183
+ Object.defineProperty(prototype, "$api", {
184
+ value(fn, args = {}, options = {}) {
185
+ if (source.api === void 0) return AsyncResult.err(dbError("unsupported", "No block has an API schema (`sql.api`) for $api to call"));
186
+ return this.$rpc(fn, args, {
187
+ ...options,
188
+ schema: source.api
189
+ });
190
+ },
191
+ configurable: true,
192
+ enumerable: false,
193
+ writable: false
194
+ });
195
+ Object.defineProperty(prototype, "$apiResult", {
196
+ value(fn, args = {}) {
197
+ return this.$api(fn, args);
198
+ },
199
+ configurable: true,
200
+ enumerable: false,
201
+ writable: false
202
+ });
203
+ return prototype;
204
+ }
205
+ // src/core/db-search.ts
206
+ /**
207
+ * `db.$search({ score: true })`: the ranked ids and scores from
208
+ * `search_<table>_scores`, then those rows through the table (RLS and `where`
209
+ * apply), best first, each with `$score`.
210
+ */
211
+ async function scoredSearch(runner, table, fnArgs, args, hint) {
212
+ const [key, ...rest] = table.primaryKey;
213
+ if (key === void 0 || rest.length > 0) return err(dbError("invalid_request", "db.$search({ score: true }) needs a table with a one-column primary key", { table: table.key }));
214
+ const { builder } = runner.runtime;
215
+ const scoresTable = {
216
+ key: `${table.key}$scores`,
217
+ name: `search_${table.name}_scores`,
218
+ schema: table.schema,
219
+ kind: "view",
220
+ columns: {
221
+ id: {
222
+ db: "id",
223
+ type: "jsonb",
224
+ nullable: false,
225
+ hasDefault: false
226
+ },
227
+ score: {
228
+ db: "score",
229
+ type: "float8",
230
+ nullable: false,
231
+ hasDefault: false
232
+ }
233
+ },
234
+ primaryKey: [],
235
+ uniqueKeys: {},
236
+ relations: {},
237
+ flags: {}
238
+ };
239
+ const scored = await runner.runInternal({
240
+ kind: "select",
241
+ table: scoresTable,
242
+ selection: builder.selection(scoresTable, ["id", "score"], void 0),
243
+ where: void 0,
244
+ orderBy: [],
245
+ limit: void 0,
246
+ offset: void 0,
247
+ count: void 0,
248
+ head: false,
249
+ single: void 0,
250
+ source: {
251
+ schema: table.schema,
252
+ name: scoresTable.name,
253
+ args: fnArgs
254
+ }
255
+ }, table, args.signal);
256
+ if (!scored.ok) return err(hint(scored.error));
257
+ const ranked = scored.data.rows.flatMap((row) => row["score"] === void 0 || row["score"] === null ? [] : [{
258
+ id: row["id"],
259
+ score: Number(row["score"])
260
+ }]);
261
+ if (ranked.length === 0) return ok([]);
262
+ const byId = new Map(ranked.map((entry) => [String(entry.id), entry]));
263
+ const op = {
264
+ kind: "select",
265
+ table,
266
+ selection: builder.selection(table, args.select, args.include),
267
+ where: builder.where(table, { AND: [...args.where === void 0 ? [] : [args.where], { [key]: { in: ranked.map((entry) => entry.id) } }] }),
268
+ orderBy: [],
269
+ limit: ranked.length,
270
+ offset: void 0,
271
+ count: void 0,
272
+ head: false,
273
+ single: void 0
274
+ };
275
+ const result = await runner.run(op, {}, args.signal);
276
+ if (!result.ok) return result;
277
+ return ok(result.data.rows.flatMap((row) => {
278
+ const entry = byId.get(String(row[key]));
279
+ return entry ? [{
280
+ ...row,
281
+ $score: entry.score
282
+ }] : [];
283
+ }).toSorted((a, b) => b.$score - a.$score));
284
+ }
285
+ /**
286
+ * `db.$search(table, args)`: nearest rows from the table's `search_<table>`
287
+ * function.
288
+ */
289
+ function searchTable(runner, base, meta, name, args) {
290
+ return AsyncResult.from(async () => {
291
+ const table = Object.hasOwn(meta.tables, name) ? meta.tables[name] : void 0;
292
+ if (!table) return err(dbError("invalid_request", `db.$search(): unknown table "${name}"`));
293
+ if (!base.functionSources) return err(dbError("invalid_request", `db.$search() reads from a function; the ${base.name} executor doesn't support that`, { table: table.key }));
294
+ const query = (args.vector === void 0 || args.vector === null) && args.text !== void 0 ? null : vectorLiteral(args.vector ?? []);
295
+ const k = args.k ?? 10;
296
+ if (query === void 0 || !Number.isInteger(k) || k < 1) return err(dbError("invalid_input", "db.$search() needs a vector of finite numbers (or text alone on a hybrid entry) and a positive integer k", { table: table.key }));
297
+ const { builder } = runner.runtime;
298
+ const fnArgs = {
299
+ query,
300
+ k,
301
+ ...args.filter === void 0 ? {} : { filter: args.filter },
302
+ ...args.text === void 0 ? {} : { text_query: args.text }
303
+ };
304
+ const hint = (error) => error.code === "PGRST202" || error.code === "42883" ? {
305
+ ...error,
306
+ hint: `Add "${table.schema}.${table.name}" to vectorSearch in better-supabase.config.ts (with prefilter or hybrid for filter and text) and run \`better-supabase upgrade\`.`
307
+ } : error;
308
+ if (args.score) return scoredSearch(runner, table, fnArgs, args, hint);
309
+ const op = {
310
+ kind: "select",
311
+ table,
312
+ selection: builder.selection(table, args.select, args.include),
313
+ where: builder.where(table, args.where),
314
+ orderBy: [],
315
+ limit: k,
316
+ offset: void 0,
317
+ count: void 0,
318
+ head: false,
319
+ single: void 0,
320
+ source: {
321
+ schema: table.schema,
322
+ name: `search_${table.name}`,
323
+ args: fnArgs
324
+ }
325
+ };
326
+ const result = await runner.run(op, {}, args.signal);
327
+ if (result.ok) return ok(result.data.rows);
328
+ return err(hint(result.error));
329
+ });
330
+ }
331
+ // src/core/define-plugins.ts
332
+ function isExecutor(value) {
333
+ return typeof value === "object" && value !== null && typeof value.execute === "function" && typeof value.name === "string";
334
+ }
335
+ /** No plugins, one shared array so the caches keyed on a plugin list hit. */
336
+ const NO_PLUGINS = Object.freeze([]);
337
+ /**
338
+ * The kept lists per installed list and `keep` names, so each is one stable
339
+ * array.
340
+ */
341
+ const keptLists = /* @__PURE__ */ new WeakMap();
342
+ /**
343
+ * The installed plugins named in `keep`; a name that isn't installed throws, so
344
+ * a typo can't drop tracing silently.
345
+ */
346
+ function keptPlugins(plugins, keep) {
347
+ if (keep.length === 0) return NO_PLUGINS;
348
+ let byKeep = keptLists.get(plugins);
349
+ if (!byKeep) {
350
+ byKeep = /* @__PURE__ */ new Map();
351
+ keptLists.set(plugins, byKeep);
352
+ }
353
+ const key = keep.join("\0");
354
+ const cached = byKeep.get(key);
355
+ if (cached) return cached;
356
+ for (const name of keep) if (!plugins.some((plugin) => plugin.name === name)) throw new TypeError(`better-supabase: $withoutPlugins({ keep }) names "${name}", which is not installed. Installed: ${plugins.map((plugin) => plugin.name).join(", ") || "none"}`);
357
+ const kept = plugins.filter((plugin) => keep.includes(plugin.name));
358
+ byKeep.set(key, kept);
359
+ return kept;
360
+ }
361
+ // src/core/diagnostics.ts
362
+ /**
363
+ * Debug records for the `diagnostics` option, after the Supabase SDK capability
364
+ * `client.observability.diagnostic_logging`
365
+ * (`SPEC_PINS.supabaseSdkCapabilities`). Fields are names, kinds, counts and
366
+ * timings only: never tokens, keys, row values, filters, query strings, headers
367
+ * or database error messages, which can quote the data.
368
+ */
369
+ function logDiagnostics(events) {
370
+ const logger = { debug(message, fields) {
371
+ try {
372
+ events.logger.debug(message, fields);
373
+ } catch {}
374
+ } };
375
+ events.on("query", (event) => {
376
+ logger.debug(`${event.operation} ${event.table} ${event.ok ? "ok" : "failed"} in ${String(Math.round(event.durationMs))}ms`, {
377
+ table: event.table,
378
+ operation: event.operation,
379
+ ok: event.ok,
380
+ durationMs: event.durationMs,
381
+ rows: event.rows,
382
+ truncated: event.truncated
383
+ });
384
+ });
385
+ events.on("error", ({ table, error }) => {
386
+ logger.debug(`${error.kind} error${table ? ` on ${table}` : ""}`, {
387
+ ...table ? { table } : {},
388
+ kind: error.kind,
389
+ status: error.status,
390
+ ...error.code ? { code: error.code } : {}
391
+ });
392
+ });
393
+ events.on("refresh", (event) => {
394
+ logger.debug(`session refresh ${event.ok ? "ok" : "failed"} in ${String(Math.round(event.durationMs))}ms`, {
395
+ ok: event.ok,
396
+ shared: event.shared,
397
+ durationMs: event.durationMs
398
+ });
399
+ });
400
+ events.on("auth", (event) => {
401
+ logger.debug(`auth from ${event.source}: ${event.ok ? "user" : event.reason ?? "no user"}`, {
402
+ source: event.source,
403
+ ok: event.ok,
404
+ ...event.reason ? { reason: event.reason } : {}
405
+ });
406
+ });
407
+ }
408
+ /**
409
+ * The event hub of a new definition, with the diagnostic handlers when
410
+ * `diagnostics` is on.
411
+ */
412
+ function definitionEvents(options) {
413
+ const events = new EventHub(options.logger ?? consoleLogger, options.now);
414
+ if (options.diagnostics === true) logDiagnostics(events);
415
+ return events;
416
+ }
417
+ // src/ir/codec.ts
418
+ /** Whether decoding `selection` changes anything, so plain reads skip the walk. */
419
+ function needsDecoding(selection) {
420
+ let needs = decodes.get(selection);
421
+ if (needs === void 0) {
422
+ needs = computeNeedsDecoding(selection);
423
+ decodes.set(selection, needs);
424
+ }
425
+ return needs;
426
+ }
427
+ const decodes = /* @__PURE__ */ new WeakMap();
428
+ function computeNeedsDecoding(selection) {
429
+ return selection.aggregate !== void 0 || selection.columns.some((column) => column.codec !== void 0) || selection.includes.some((include) => include.count !== void 0 || include.aggregate !== void 0 || needsDecoding(include.selection));
430
+ }
431
+ /**
432
+ * PostgREST returns `[{ count }]` for a `(count)` embed; SQL returns the
433
+ * number.
434
+ */
435
+ function countOf$1(value) {
436
+ if (Array.isArray(value)) {
437
+ const first = value[0];
438
+ return Number(first?.count ?? 0);
439
+ }
440
+ return Number(value ?? 0);
441
+ }
442
+ function measureOf(measure, value) {
443
+ if (value === void 0 || value === null) return null;
444
+ return measure.codec ? decodeScalar(measure.codec, value) : value;
445
+ }
446
+ /** Adds `value` under `row[key][name]`, next to what is already there. */
447
+ function fold(row, folded, key, name, value) {
448
+ let target = folded.get(key);
449
+ if (!target) {
450
+ target = { ...row[key] };
451
+ folded.set(key, target);
452
+ row[key] = target;
453
+ }
454
+ target[name] = value;
455
+ }
456
+ const droppedKeys = /* @__PURE__ */ new WeakMap();
457
+ /** Wire keys that decoding folds into `_count`, `_sum` and the rest. */
458
+ function droppedOf(selection) {
459
+ let dropped = droppedKeys.get(selection);
460
+ if (!dropped) {
461
+ dropped = /* @__PURE__ */ new Set([...selection.aggregate?.measures.map((measure) => measure.key) ?? [], ...selection.includes.filter((include) => include.count !== void 0 || include.aggregate !== void 0).map((include) => include.alias)]);
462
+ droppedKeys.set(selection, dropped);
463
+ }
464
+ return dropped;
465
+ }
466
+ function decodeRow$1(selection, row) {
467
+ const dropped = droppedOf(selection);
468
+ const out = {};
469
+ for (const key in row) if (!dropped.has(key) && Object.hasOwn(row, key)) out[key] = row[key];
470
+ const folded = /* @__PURE__ */ new Map();
471
+ for (const column of selection.columns) {
472
+ if (!column.codec || !(column.alias in out)) continue;
473
+ try {
474
+ out[column.alias] = decodeValue(column.codec, out[column.alias]);
475
+ } catch (cause) {
476
+ if (!(cause instanceof DbException) || cause.error.kind !== "invalid_value") throw cause;
477
+ throw new DbException(dbError("invalid_value", `${column.alias}: ${cause.error.message}`, { column: column.alias }));
478
+ }
479
+ }
480
+ if (selection.aggregate) {
481
+ if (selection.aggregate.count) out["_count"] = countOf$1(out["_count"]);
482
+ for (const measure of selection.aggregate.measures) {
483
+ const value = row[measure.key];
484
+ fold(out, folded, `_${measure.fn}`, measure.alias, measureOf(measure, value));
485
+ }
486
+ }
487
+ for (const include of selection.includes) {
488
+ const value = row[include.alias];
489
+ if (include.count !== void 0) {
490
+ if (!(include.alias in row)) continue;
491
+ fold(out, folded, "_count", include.count, countOf$1(value));
492
+ continue;
493
+ }
494
+ if (include.aggregate !== void 0) {
495
+ if (!(include.alias in row)) continue;
496
+ const inner = Array.isArray(value) ? value[0] : value;
497
+ const measures = {};
498
+ for (const measure of include.selection.aggregate?.measures ?? []) measures[measure.alias] = measureOf(measure, inner?.[measure.key]);
499
+ fold(out, folded, `_${include.aggregate.fn}`, include.aggregate.name, measures);
500
+ continue;
501
+ }
502
+ if (Array.isArray(value)) out[include.alias] = value.map((item) => decodeRow$1(include.selection, item));
503
+ else if (value && typeof value === "object") out[include.alias] = decodeRow$1(include.selection, value);
504
+ }
505
+ return out;
506
+ }
507
+ /** Applies column codecs to returned rows, including embedded relations. */
508
+ function decodeRows(selection, rows, checked = false) {
509
+ if (!selection || !checked && !needsDecoding(selection)) return rows;
510
+ return rows.map((row) => decodeRow$1(selection, row));
511
+ }
512
+ // src/core/cursor.ts
513
+ function isBound(value) {
514
+ return typeof value === "object" && value !== null && "s" in value && typeof value.s === "string" && "v" in value && Array.isArray(value.v);
515
+ }
516
+ function parse(cursor) {
517
+ try {
518
+ return JSON.parse(base64ToText(cursor));
519
+ } catch {
520
+ return;
521
+ }
522
+ }
523
+ /** Opaque, URL-safe keyset cursor. */
524
+ function encodeCursor(values) {
525
+ return toBase64Url(JSON.stringify(values));
526
+ }
527
+ /** The values of a cursor from `encodeCursor` or from `page()`. */
528
+ function decodeCursor(cursor) {
529
+ const parsed = parse(cursor);
530
+ if (isList(parsed)) return [...parsed];
531
+ return isBound(parsed) ? parsed.v : void 0;
532
+ }
533
+ /** A short FNV-1a hash of `text`, enough to tell two sorts apart. */
534
+ function sortKey(text) {
535
+ let hash = 2166136261;
536
+ for (let index = 0; index < text.length; index += 1) {
537
+ hash ^= text.codePointAt(index) ?? 0;
538
+ hash = Math.imul(hash, 16777619);
539
+ }
540
+ return (hash >>> 0).toString(36);
541
+ }
542
+ /** A `page()` cursor that only continues the sort `key` names. */
543
+ function encodeBoundCursor(values, key) {
544
+ return toBase64Url(JSON.stringify({
545
+ s: key,
546
+ v: values
547
+ }));
548
+ }
549
+ /**
550
+ * The values of a `page()` cursor made for the sort `key`. `sort` means the
551
+ * cursor is valid but continues another sort or table.
552
+ */
553
+ function decodeBoundCursor(cursor, key) {
554
+ const parsed = parse(cursor);
555
+ if (!isBound(parsed)) return { invalid: "cursor" };
556
+ return parsed.s === key ? { values: parsed.v } : { invalid: "sort" };
557
+ }
558
+ // src/core/keyset.ts
559
+ /**
560
+ * The rows after the cursor `values` in `orderBy` order, as an OR of ANDs: `a >
561
+ * x or (a = x and b > y)`. The SQL compiler sends that shape as the row
562
+ * comparison `(a, b) > (x, y)`. Nulls sort where Postgres puts them: last for
563
+ * `asc`, first for `desc`, unless the term says otherwise.
564
+ */
565
+ function keysetCondition(orderBy, values, nullable) {
566
+ const isNull = (name) => column(name, "is", null);
567
+ const branches = orderBy.flatMap((term, index) => {
568
+ const value = values[index];
569
+ const nullsFirst = (term.nulls ?? (term.direction === "desc" ? "first" : "last")) === "first";
570
+ const after = column(term.column, term.direction === "asc" ? "gt" : "lt", value);
571
+ const step = value === null ? nullsFirst ? not(isNull(term.column)) : void 0 : nullsFirst || !nullable(term.column) ? after : or(after, isNull(term.column));
572
+ if (!step) return [];
573
+ const equal = orderBy.slice(0, index).map((prev, prevIndex) => values[prevIndex] === null ? isNull(prev.column) : column(prev.column, "eq", values[prevIndex]));
574
+ return [and(...equal, step) ?? step];
575
+ });
576
+ if (branches.length === 0) return column(orderBy[0]?.column ?? "", "in", []);
577
+ const after = or(...branches);
578
+ const [first] = orderBy;
579
+ if (orderBy.length < 2 || !first || values[0] === null || nullable(first.column)) return after;
580
+ const bound = column(first.column, first.direction === "asc" ? "gte" : "lte", values[0]);
581
+ return and(bound, after) ?? after;
582
+ }
583
+ // src/core/paginate.ts
584
+ /**
585
+ * The page size and row offset of a list call, or the reason its arguments are
586
+ * invalid.
587
+ */
588
+ function pageWindow(args) {
589
+ if (args["offset"] !== void 0 || args["limit"] !== void 0) {
590
+ if (args["page"] !== void 0 || args["size"] !== void 0) return { invalid: "Pass \"offset\" and \"limit\" or \"page\" and \"size\"" };
591
+ const limit = Number(args["limit"]);
592
+ if (!Number.isInteger(limit) || limit < 1) return { invalid: "\"limit\" must be a positive integer" };
593
+ const offset = Number(args["offset"]);
594
+ if (!Number.isInteger(offset) || offset < 0) return { invalid: "\"offset\" must be a non-negative integer" };
595
+ return {
596
+ size: limit,
597
+ offset
598
+ };
599
+ }
600
+ const size = Number(args["size"]);
601
+ if (!Number.isInteger(size) || size < 1) return { invalid: "\"size\" must be a positive integer" };
602
+ const number = args["page"] === void 0 ? 1 : Number(args["page"]);
603
+ if (!Number.isInteger(number) || number < 1) return { invalid: "\"page\" must be a positive integer" };
604
+ return {
605
+ size,
606
+ offset: (number - 1) * size
607
+ };
608
+ }
609
+ /**
610
+ * The `{ items, page }` answer of an offset page from the rows read with one
611
+ * extra row.
612
+ */
613
+ function offsetEnvelope(rows, total, size, offset) {
614
+ return {
615
+ items: rows.slice(0, size),
616
+ page: {
617
+ number: Math.floor(offset / size) + 1,
618
+ size,
619
+ total,
620
+ pages: total === null ? null : Math.max(1, Math.ceil(total / size)),
621
+ hasMore: rows.length > size
622
+ }
623
+ };
624
+ }
625
+ /** A copy of the row without the given keys. */
626
+ function strip(row, keys) {
627
+ const copy = {};
628
+ for (const key in row) if (!keys.includes(key) && Object.hasOwn(row, key)) copy[key] = row[key];
629
+ return copy;
630
+ }
631
+ // src/core/row-keys.ts
632
+ /** App-cased primary keys of `rows`, or of a `where` that pins the primary key. */
633
+ function keysOf(op, rows) {
634
+ const { primaryKey } = op.table;
635
+ if (primaryKey.length === 0) return;
636
+ const fromRows = rows.flatMap((row) => primaryKey.every((name) => row[name] !== void 0 && row[name] !== null) ? [Object.fromEntries(primaryKey.map((name) => [name, row[name]]))] : []);
637
+ if (fromRows.length > 0) return fromRows;
638
+ if (op.kind === "insert") return;
639
+ return keysFromWhere(op.table, op.where);
640
+ }
641
+ function keysFromWhere(table, where) {
642
+ if (!where) return;
643
+ const { byDb } = lookupOf(table);
644
+ const pinned = /* @__PURE__ */ new Map();
645
+ const items = [];
646
+ const flatten = (condition) => {
647
+ if (condition.kind === "and") for (const item of condition.items) flatten(item);
648
+ else items.push(condition);
649
+ };
650
+ flatten(where);
651
+ for (const item of items) {
652
+ if (item.kind !== "column" || item.path) continue;
653
+ const app = byDb.get(item.column)?.[0];
654
+ if (app === void 0 || !table.primaryKey.includes(app)) continue;
655
+ if (item.op === "eq") pinned.set(app, [item.value]);
656
+ else if (item.op === "in" && Array.isArray(item.value)) pinned.set(app, item.value);
657
+ }
658
+ if (pinned.size !== table.primaryKey.length) return;
659
+ const [first, ...rest] = table.primaryKey;
660
+ if (first === void 0) return;
661
+ if (rest.length === 0) return (pinned.get(first) ?? []).map((value) => ({ [first]: value }));
662
+ if ([...pinned.values()].some((values) => values.length !== 1)) return;
663
+ return [Object.fromEntries(table.primaryKey.map((name) => [name, pinned.get(name)?.[0]]))];
664
+ }
665
+ /**
666
+ * Rows in conflict-key order, so concurrent upserts lock the same rows in the
667
+ * same order instead of deadlocking.
668
+ */
669
+ function byKey(rows, columns) {
670
+ const compare = (left, right) => {
671
+ if (left === right) return 0;
672
+ if (left === null || left === void 0) return 1;
673
+ if (right === null || right === void 0) return -1;
674
+ if (typeof left === "number" && typeof right === "number") return left - right;
675
+ if (typeof left === "bigint" && typeof right === "bigint") return left < right ? -1 : 1;
676
+ const a = String(left);
677
+ const b = String(right);
678
+ return a < b ? -1 : a > b ? 1 : 0;
679
+ };
680
+ const keyed = rows.map((row) => ({
681
+ row,
682
+ key: columns.map((column) => {
683
+ const value = row[column];
684
+ return typeof value === "object" && value !== null ? String(value) : value;
685
+ })
686
+ }));
687
+ keyed.sort((left, right) => {
688
+ for (let index = 0; index < columns.length; index += 1) {
689
+ const order = compare(left.key[index], right.key[index]);
690
+ if (order !== 0) return order;
691
+ }
692
+ return 0;
693
+ });
694
+ return keyed.map((entry) => entry.row);
695
+ }
696
+ // src/core/runner.ts
697
+ const KNOWN_KEYS = /* @__PURE__ */ new Set([
698
+ "select",
699
+ "include",
700
+ "where",
701
+ "orderBy",
702
+ "limit",
703
+ "offset",
704
+ "signal",
705
+ "returning",
706
+ "expect",
707
+ "onConflict",
708
+ "ignoreDuplicates",
709
+ "page",
710
+ "size",
711
+ "count",
712
+ "after",
713
+ "mode",
714
+ "data",
715
+ "groupBy",
716
+ "_count",
717
+ "_sum",
718
+ "_avg",
719
+ "_min",
720
+ "_max",
721
+ "timeout",
722
+ "retry",
723
+ "maxAffected",
724
+ "defaultToNull"
725
+ ]);
726
+ const NO_OPTIONS = Object.freeze({});
727
+ function optionsOf(args) {
728
+ if (!args) return NO_OPTIONS;
729
+ let options;
730
+ for (const key in args) if (!KNOWN_KEYS.has(key) && Object.hasOwn(args, key)) (options ??= {})[key] = args[key];
731
+ return options ?? NO_OPTIONS;
732
+ }
733
+ const hooksByPlugins = /* @__PURE__ */ new WeakMap();
734
+ function hooksOf(plugins) {
735
+ let hooks = hooksByPlugins.get(plugins);
736
+ if (!hooks) {
737
+ hooks = {
738
+ transformQuery: plugins.filter((plugin) => plugin.transformQuery),
739
+ beforeMutation: plugins.filter((plugin) => plugin.beforeMutation),
740
+ afterMutation: plugins.filter((plugin) => plugin.afterMutation)
741
+ };
742
+ hooksByPlugins.set(plugins, hooks);
743
+ }
744
+ return hooks;
745
+ }
746
+ function isThenable(value) {
747
+ return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
748
+ }
749
+ function signalOf(args) {
750
+ const signal = args?.["signal"];
751
+ return signal instanceof AbortSignal ? signal : void 0;
752
+ }
753
+ function cloneRows(rows) {
754
+ return rows.map((row) => cloneValue(row));
755
+ }
756
+ function mutationKind(op) {
757
+ if (op.kind === "insert") return op.onConflict ? "upsert" : "insert";
758
+ return op.kind;
759
+ }
760
+ /** Runs operations through plugins, the executor and the event hub. */
761
+ var OperationRunner = class {
762
+ runtime;
763
+ #hooks;
764
+ constructor(runtime) {
765
+ this.runtime = runtime;
766
+ this.#hooks = hooksOf(runtime.plugins);
767
+ }
768
+ hookArgs(table, options, signal) {
769
+ return {
770
+ table,
771
+ schema: this.runtime.meta,
772
+ context: this.runtime.context,
773
+ options,
774
+ now: this.runtime.now,
775
+ ...signal ? { signal } : {}
776
+ };
777
+ }
778
+ async run(op, options, signal, tuning = NO_TUNING) {
779
+ const { runtime } = this;
780
+ const hooks = this.#hooks;
781
+ if ("invalid" in tuning) return this.fail(op.table, dbError("invalid_request", tuning.invalid));
782
+ const { timeout, retry } = {
783
+ ...runtime.tuning,
784
+ ...tuning
785
+ };
786
+ const invalid = invalidTuning({
787
+ timeout,
788
+ retry
789
+ });
790
+ if (invalid) return this.fail(op.table, dbError("invalid_request", invalid));
791
+ let current = op;
792
+ if (hooks.transformQuery.length > 0 || hooks.beforeMutation.length > 0) {
793
+ const hook = this.hookArgs(op.table, options, signal);
794
+ let active = "";
795
+ try {
796
+ for (const plugin of hooks.transformQuery) {
797
+ active = `plugin "${plugin.name}" transformQuery`;
798
+ current = plugin.transformQuery(current, hook);
799
+ }
800
+ if (current.kind !== "select") {
801
+ let mutation = current;
802
+ for (const plugin of hooks.beforeMutation) {
803
+ active = `plugin "${plugin.name}" beforeMutation`;
804
+ const next = plugin.beforeMutation(mutation, hook);
805
+ mutation = isThenable(next) ? await next : next;
806
+ }
807
+ current = mutation;
808
+ }
809
+ } catch (cause) {
810
+ if (cause instanceof DbException) return this.fail(op.table, cause.error);
811
+ return this.fail(op.table, {
812
+ ...toDbError(cause),
813
+ details: `${active} threw`
814
+ });
815
+ }
816
+ }
817
+ if (current.kind === "update" && Object.keys(current.set).length === 0) return this.fail(op.table, dbError("invalid_request", `The update on "${op.table.key}" sets no columns`));
818
+ const timed = runtime.events.has("query");
819
+ const started = timed ? performance.now() : 0;
820
+ const executed = await this.#execute(current, signal, timeout, retry);
821
+ const selection = current.kind === "select" ? current.selection : current.returning;
822
+ let result = executed;
823
+ if (executed.ok && selection && needsDecoding(selection)) try {
824
+ result = ok({
825
+ ...executed.data,
826
+ rows: decodeRows(selection, executed.data.rows, true)
827
+ });
828
+ } catch (cause) {
829
+ if (cause instanceof DbException) return this.fail(op.table, cause.error);
830
+ throw cause;
831
+ }
832
+ const rows = result.ok ? result.data.rows.length : 0;
833
+ const truncated = current.kind === "select" && current.limit === void 0 && current.single === void 0 && !current.head && rows >= runtime.maxRows;
834
+ if (truncated && !runtime.truncatedTables.has(op.table.key)) {
835
+ runtime.truncatedTables.add(op.table.key);
836
+ runtime.events.logger.warn(`a read on ${op.table.key} returned ${rows} rows, the maxRows cap; add a limit or use page()`, {
837
+ table: op.table.key,
838
+ maxRows: runtime.maxRows
839
+ });
840
+ }
841
+ if (timed) runtime.events.emit("query", {
842
+ table: op.table.key,
843
+ operation: current.kind,
844
+ ok: result.ok,
845
+ durationMs: performance.now() - started,
846
+ rows,
847
+ truncated
848
+ });
849
+ if (!result.ok) return this.fail(op.table, result.error);
850
+ if (current.kind !== "select") await this.afterMutation(current, result.data);
851
+ return result;
852
+ }
853
+ /**
854
+ * Runs `op` without plugins or decoding, with the connection's timeout and
855
+ * retry, and fails on `table`: for reads the library makes itself, such as
856
+ * the scores of `db.$search({ score: true })`.
857
+ */
858
+ async runInternal(op, table, signal) {
859
+ const { timeout, retry } = this.runtime.tuning ?? NO_TUNING;
860
+ const invalid = invalidTuning({
861
+ timeout,
862
+ retry
863
+ });
864
+ if (invalid) return this.fail(table, dbError("invalid_request", invalid));
865
+ const executed = await this.#execute(op, signal, timeout, retry);
866
+ return executed.ok ? executed : this.fail(table, {
867
+ ...executed.error,
868
+ table: table.key
869
+ });
870
+ }
871
+ async #execute(op, signal, timeout, retry) {
872
+ const limit = deadline(signal, timeout);
873
+ const context = {
874
+ errorMappers: this.runtime.errorMappers,
875
+ ...limit.signal ? { signal: limit.signal } : {},
876
+ ...retry === void 0 ? {} : { retry }
877
+ };
878
+ let executed;
879
+ try {
880
+ executed = await this.runtime.executor.execute(op, context);
881
+ } finally {
882
+ limit.clear();
883
+ }
884
+ if (!executed.ok && limit.timedOut()) return err(dbError("timeout", `The request timed out after ${timeout} ms`));
885
+ return executed;
886
+ }
887
+ async afterMutation(op, data) {
888
+ const { runtime } = this;
889
+ const plugins = this.#hooks.afterMutation;
890
+ const listening = runtime.events.has("mutation");
891
+ if (plugins.length === 0 && !listening) return;
892
+ const kind = mutationKind(op);
893
+ const rows = cloneRows(data.rows);
894
+ const keys = keysOf(op, rows);
895
+ const { tenant } = runtime.context;
896
+ const event = {
897
+ table: op.table,
898
+ kind,
899
+ intent: op.intent ?? kind,
900
+ rows,
901
+ ...keys ? { keys } : {},
902
+ ...tenant === void 0 ? {} : { tenant },
903
+ context: runtime.context
904
+ };
905
+ for (const plugin of plugins) try {
906
+ const pending = plugin.afterMutation(event);
907
+ if (isThenable(pending)) await pending;
908
+ } catch (cause) {
909
+ runtime.events.logger.error(`plugin "${plugin.name}" afterMutation threw`, { cause });
910
+ }
911
+ if (listening) runtime.events.emit("mutation", {
912
+ table: op.table.key,
913
+ kind: event.kind,
914
+ ...event.intent ? { intent: event.intent } : {},
915
+ rows: event.rows,
916
+ ...event.keys ? { keys: event.keys } : {},
917
+ ...event.tenant === void 0 ? {} : { tenant: event.tenant },
918
+ context: event.context
919
+ });
920
+ }
921
+ fail(table, error) {
922
+ const withTable = error.table ? error : {
923
+ ...error,
924
+ table: table.key
925
+ };
926
+ if (this.runtime.events.has("error")) this.runtime.events.emit("error", errorEvent(withTable, table.key));
927
+ return err(withTable);
928
+ }
929
+ };
930
+ // src/core/write-args.ts
931
+ const COUNT_MODES = /* @__PURE__ */ new Set([
932
+ "exact",
933
+ "planned",
934
+ "estimated"
935
+ ]);
936
+ function isCountMode(value) {
937
+ return COUNT_MODES.has(value);
938
+ }
939
+ /** `maxAffected` from a call, or a message when it isn't a non-negative integer. */
940
+ function maxAffectedOf(args) {
941
+ const value = args["maxAffected"];
942
+ if (value === void 0) return {};
943
+ return typeof value === "number" && Number.isInteger(value) && value >= 0 ? { maxAffected: value } : { invalid: `"maxAffected" must be a non-negative integer, got ${String(value)}` };
944
+ }
945
+ /** The `count` mode a mutation asks for, when it names a valid one. */
946
+ function countOf(args) {
947
+ const count = args?.["count"];
948
+ return isCountMode(count) ? { count } : {};
949
+ }
950
+ // src/core/repository.ts
951
+ const sensitiveByTable = /* @__PURE__ */ new WeakMap();
952
+ const primaryOrders = /* @__PURE__ */ new WeakMap();
953
+ const RELATED_MEASURES = [
954
+ "_count",
955
+ "_sum",
956
+ "_avg",
957
+ "_min",
958
+ "_max"
959
+ ];
960
+ /** Database names of the table's `config.sensitive` columns. */
961
+ function sensitiveColumnsOf(table) {
962
+ let sensitive = sensitiveByTable.get(table);
963
+ if (!sensitive) {
964
+ sensitive = new Set(lookupOf(table).entries.filter(([, column]) => column.sensitive).map(([, column]) => column.db));
965
+ sensitiveByTable.set(table, sensitive);
966
+ }
967
+ return sensitive;
968
+ }
969
+ /** Creates the runtime repository object for one table. */
970
+ function createRepository(runner, table) {
971
+ const { builder } = runner.runtime;
972
+ const sensitiveDb = sensitiveColumnsOf(table);
973
+ const mutationHooks = runner.runtime.plugins.some((plugin) => plugin.beforeMutation);
974
+ const selection = (args) => {
975
+ const misplaced = RELATED_MEASURES.find((key) => args?.[key] !== void 0);
976
+ if (misplaced !== void 0) invalidRequest(`${misplaced} belongs inside include: { ${misplaced}: { ... } } for related rows; aggregate() covers the table itself`, table.key);
977
+ return builder.selection(table, args?.["select"], args?.["include"]);
978
+ };
979
+ const rowCount = (args, name) => {
980
+ const value = args?.[name];
981
+ if (value === void 0) return;
982
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) invalidRequest(`"${name}" must be a non-negative integer, not ${String(value)}`, table.key);
983
+ return value;
984
+ };
985
+ const selectOp = (args, patch = {}) => ({
986
+ kind: "select",
987
+ table,
988
+ selection: selection(args),
989
+ where: builder.where(table, args?.["where"]),
990
+ orderBy: builder.orderBy(table, args?.["orderBy"]),
991
+ limit: rowCount(args, "limit"),
992
+ offset: rowCount(args, "offset"),
993
+ count: void 0,
994
+ head: false,
995
+ single: void 0,
996
+ ...patch
997
+ });
998
+ /**
999
+ * Writes return every column but the sensitive ones unless they are asked
1000
+ * for.
1001
+ */
1002
+ const returning = (args) => {
1003
+ if (args?.["returning"] === false) return;
1004
+ const all = selection(args);
1005
+ if (args?.["select"] !== void 0 || args?.["sensitive"] === true) return all;
1006
+ const columns = all.columns.filter((entry) => !sensitiveDb.has(entry.column));
1007
+ return columns.length === all.columns.length ? all : {
1008
+ ...all,
1009
+ columns
1010
+ };
1011
+ };
1012
+ const run = (op, args) => runner.run(op, optionsOf(args), signalOf(args), tuningOf(args));
1013
+ /** `primaryKey` holds app names; order terms take database names. */
1014
+ const defaultOrder = () => {
1015
+ let order = primaryOrders.get(table);
1016
+ if (!order) {
1017
+ order = table.primaryKey.map((name) => ({
1018
+ column: builder.column(table, name),
1019
+ direction: "asc",
1020
+ implicit: true
1021
+ }));
1022
+ primaryOrders.set(table, order);
1023
+ }
1024
+ return order;
1025
+ };
1026
+ const notFound = () => runner.fail(table, dbError("not_found", `No ${table.key} row matched`));
1027
+ /**
1028
+ * Arguments the builder rejects fail like any other error: with the table and
1029
+ * an `error` event.
1030
+ */
1031
+ const guarded = (work) => AsyncResult.from(async () => {
1032
+ try {
1033
+ return await work();
1034
+ } catch (cause) {
1035
+ return runner.fail(table, toDbError(cause));
1036
+ }
1037
+ });
1038
+ const createOne = (data, args) => guarded(async () => {
1039
+ const op = insertOp([data], args, void 0);
1040
+ const result = await run(op, args);
1041
+ if (!result.ok) return result;
1042
+ return ok(args?.["returning"] === false ? null : result.data.rows[0] ?? null);
1043
+ });
1044
+ const createRows = (rows, args) => guarded(async () => {
1045
+ if (rows.length === 0) return ok(args?.["returning"] === false ? { count: 0 } : []);
1046
+ const result = await run(insertOp(rows, args, void 0), args);
1047
+ if (!result.ok) return result;
1048
+ return ok(args?.["returning"] === false ? { count: result.data.count ?? rows.length } : result.data.rows);
1049
+ });
1050
+ const updateOne = (id, patch, args) => guarded(async () => {
1051
+ const key = and(builder.primaryKey(table, id), builder.where(table, args?.["where"]));
1052
+ const expect = args?.["expect"] ? builder.where(table, args["expect"]) : void 0;
1053
+ const set = builder.row(table, patch, "update");
1054
+ const empty = !mutationHooks && Object.keys(set).length === 0;
1055
+ const op = {
1056
+ kind: "update",
1057
+ table,
1058
+ set,
1059
+ where: and(key, expect),
1060
+ returning: returning(args)
1061
+ };
1062
+ const result = empty ? await run(selectOp(args, {
1063
+ where: and(key, expect),
1064
+ selection: op.returning ?? {
1065
+ columns: [],
1066
+ includes: []
1067
+ },
1068
+ limit: 1,
1069
+ orderBy: [],
1070
+ offset: void 0
1071
+ }), args) : await run(op, args);
1072
+ if (!result.ok) return result;
1073
+ if ((op.returning || empty ? result.data.rows.length : result.data.count ?? 0) === 0) {
1074
+ if (!expect) return notFound();
1075
+ const exists = await run(selectOp(void 0, {
1076
+ where: key,
1077
+ selection: {
1078
+ columns: [],
1079
+ includes: []
1080
+ },
1081
+ count: "exact",
1082
+ head: true
1083
+ }), args);
1084
+ if (exists.ok && (exists.data.count ?? 0) > 0) return runner.fail(table, dbError("stale", `The ${table.key} row changed since it was read`));
1085
+ return notFound();
1086
+ }
1087
+ return ok(op.returning ? result.data.rows[0] ?? null : null);
1088
+ });
1089
+ const updateWhere = (args) => guarded(async () => {
1090
+ const where = builder.where(table, args["where"]);
1091
+ if (simplify(where) === true && args["allowAll"] !== true) return runner.fail(table, dbError("invalid_request", "update needs a \"where\" that filters rows; pass allowAll: true to update every row"));
1092
+ const rows = args["returning"] === true;
1093
+ const bound = maxAffectedOf(args);
1094
+ if ("invalid" in bound) return runner.fail(table, dbError("invalid_request", bound.invalid));
1095
+ const set = builder.row(table, args["data"], "update");
1096
+ const op = {
1097
+ kind: "update",
1098
+ table,
1099
+ set,
1100
+ where,
1101
+ returning: rows ? returning(args) : void 0,
1102
+ ...bound,
1103
+ ...countOf(args)
1104
+ };
1105
+ if (!mutationHooks && Object.keys(set).length === 0) {
1106
+ if (!rows) return ok({ count: 0 });
1107
+ const found = await run(selectOp(args, {
1108
+ where,
1109
+ selection: op.returning ?? selection(args)
1110
+ }), args);
1111
+ return found.ok ? ok(found.data.rows) : found;
1112
+ }
1113
+ const result = await run(op, args);
1114
+ if (!result.ok) return result;
1115
+ return ok(rows ? result.data.rows : { count: result.data.count ?? 0 });
1116
+ });
1117
+ const upsertOne = (data, args) => guarded(async () => {
1118
+ const op = insertOp([data], args, conflictColumns(args?.["onConflict"]));
1119
+ const result = await run(op, args);
1120
+ if (!result.ok) return result;
1121
+ return ok(args?.["returning"] === false ? null : result.data.rows[0] ?? null);
1122
+ });
1123
+ const upsertRows = (rows, args) => guarded(async () => {
1124
+ if (rows.length === 0) return ok(args?.["returning"] === false ? { count: 0 } : []);
1125
+ const op = insertOp(rows, args, conflictColumns(args?.["onConflict"]));
1126
+ const result = await run(op, args);
1127
+ if (!result.ok) return result;
1128
+ return ok(args?.["returning"] === false ? { count: result.data.count ?? rows.length } : result.data.rows);
1129
+ });
1130
+ const deleteOne = (id, args) => guarded(async () => {
1131
+ const op = {
1132
+ kind: "delete",
1133
+ table,
1134
+ where: builder.primaryKey(table, id),
1135
+ returning: builder.selection(table, table.primaryKey, void 0)
1136
+ };
1137
+ const result = await run(op, args);
1138
+ if (!result.ok) return result;
1139
+ return (result.data.count ?? result.data.rows.length) === 0 ? notFound() : ok(void 0);
1140
+ });
1141
+ const deleteWhere = (args) => guarded(async () => {
1142
+ const where = builder.where(table, args["where"]);
1143
+ if (!where || simplify(where) === true) return runner.fail(table, dbError("invalid_request", "delete needs a \"where\" that filters rows"));
1144
+ const rows = args["returning"] === true;
1145
+ const bound = maxAffectedOf(args);
1146
+ if ("invalid" in bound) return runner.fail(table, dbError("invalid_request", bound.invalid));
1147
+ const op = {
1148
+ kind: "delete",
1149
+ table,
1150
+ where,
1151
+ returning: rows ? returning(args) : void 0,
1152
+ ...bound,
1153
+ ...countOf(args)
1154
+ };
1155
+ const result = await runner.run(op, rows ? {
1156
+ ...optionsOf(args),
1157
+ returning: true
1158
+ } : optionsOf(args), signalOf(args), tuningOf(args));
1159
+ if (!result.ok) return result;
1160
+ return ok(rows ? result.data.rows : { count: result.data.count ?? 0 });
1161
+ });
1162
+ const base = {
1163
+ $tableName: table.key,
1164
+ $meta: table,
1165
+ list(args) {
1166
+ return guarded(async () => {
1167
+ const op = selectOp(args);
1168
+ const ordered = op.orderBy.length > 0 || table.primaryKey.length === 0 ? op : {
1169
+ ...op,
1170
+ orderBy: defaultOrder()
1171
+ };
1172
+ const result = await run(ordered, args);
1173
+ return result.ok ? ok(result.data.rows) : result;
1174
+ });
1175
+ },
1176
+ page(args) {
1177
+ return guarded(async () => "after" in args ? cursorPage(args) : offsetPage(args));
1178
+ },
1179
+ get(key, args) {
1180
+ return guarded(async () => {
1181
+ const filter = filterOf(key);
1182
+ const op = selectOp(args, {
1183
+ where: keyCondition(key, filter),
1184
+ limit: filter === void 0 ? 1 : 2,
1185
+ unpaged: filter !== void 0
1186
+ });
1187
+ const result = await run(op, args);
1188
+ if (!result.ok) return result;
1189
+ if (filter !== void 0 && result.data.rows.length > 1) return runner.fail(table, dbError("multiple_rows", `More than one ${table.key} row matched; get expects at most one`));
1190
+ const row = result.data.rows[0];
1191
+ if (row) return ok(row);
1192
+ return args?.["optional"] === true ? ok(null) : notFound();
1193
+ });
1194
+ },
1195
+ count(args) {
1196
+ return guarded(async () => {
1197
+ const mode = args?.["mode"];
1198
+ const op = selectOp({ where: args?.["where"] }, {
1199
+ selection: {
1200
+ columns: [],
1201
+ includes: []
1202
+ },
1203
+ count: mode === "planned" || mode === "estimated" ? mode : "exact",
1204
+ head: true
1205
+ });
1206
+ const result = await run(op, args);
1207
+ return result.ok ? ok(result.data.count ?? 0) : result;
1208
+ });
1209
+ },
1210
+ aggregate(args) {
1211
+ return guarded(async () => {
1212
+ const aggregation = builder.aggregation(table, args);
1213
+ const orderBy = builder.aggregateOrderBy(table, args["orderBy"], aggregation);
1214
+ const op = selectOp({
1215
+ where: args["where"],
1216
+ limit: args["limit"],
1217
+ offset: args["offset"]
1218
+ }, {
1219
+ selection: aggregation,
1220
+ orderBy
1221
+ });
1222
+ const result = await run(op, args);
1223
+ if (!result.ok) return result;
1224
+ if (args["groupBy"] !== void 0) return ok(result.data.rows);
1225
+ return ok(result.data.rows[0] ?? decodeRows(aggregation, [{}])[0] ?? {});
1226
+ });
1227
+ },
1228
+ create(data, args) {
1229
+ return Array.isArray(data) ? createRows(data, args) : createOne(data, args);
1230
+ },
1231
+ update(target, patch, args) {
1232
+ const filter = filterOf(target);
1233
+ return filter === void 0 ? updateOne(target, patch, args) : updateWhere({
1234
+ ...args,
1235
+ where: filter.where,
1236
+ data: patch
1237
+ });
1238
+ },
1239
+ upsert(data, args) {
1240
+ return Array.isArray(data) ? upsertRows(data, args) : upsertOne(data, args);
1241
+ },
1242
+ delete(target, args) {
1243
+ const filter = filterOf(target);
1244
+ return filter === void 0 ? deleteOne(target, args) : deleteWhere({
1245
+ ...args,
1246
+ where: filter.where
1247
+ });
1248
+ }
1249
+ };
1250
+ function insertOp(rows, args, conflict) {
1251
+ const built = rows.map((row) => builder.row(table, row));
1252
+ return {
1253
+ kind: "insert",
1254
+ table,
1255
+ rows: conflict && built.length > 1 ? byKey(built, conflict) : built,
1256
+ returning: returning(args),
1257
+ onConflict: conflict ? {
1258
+ columns: conflict,
1259
+ action: args?.["ignoreDuplicates"] === true ? "ignore" : "update"
1260
+ } : void 0,
1261
+ defaultToNull: args?.["defaultToNull"] === true,
1262
+ ...countOf(args)
1263
+ };
1264
+ }
1265
+ /** The `{ where }` of `get`, `update` and `delete` when given a filter. */
1266
+ function filterOf(target) {
1267
+ return isPlainObject(target) && Object.hasOwn(target, "where") && !Object.hasOwn(table.columns, "where") ? { where: target["where"] } : void 0;
1268
+ }
1269
+ function keyCondition(key, filter) {
1270
+ if (filter !== void 0) return builder.where(table, filter.where);
1271
+ return isPlainObject(key) ? builder.uniqueKey(table, key) : builder.primaryKey(table, key);
1272
+ }
1273
+ function conflictColumns(target) {
1274
+ if (target === void 0 || target === "primaryKey") return table.primaryKey.map((name) => builder.column(table, name));
1275
+ if (typeof target === "string") {
1276
+ const columns = table.uniqueKeys[target];
1277
+ if (!columns) invalidRequest(`Unknown unique key "${target}" on "${table.key}"`, table.key);
1278
+ return columns.map((name) => builder.column(table, name));
1279
+ }
1280
+ if (Array.isArray(target)) return target.map((name) => builder.column(table, String(name)));
1281
+ return invalidRequest(`Invalid onConflict on "${table.key}"`, table.key);
1282
+ }
1283
+ async function offsetPage(args) {
1284
+ const window = pageWindow(args);
1285
+ if ("invalid" in window) return runner.fail(table, dbError("invalid_request", window.invalid));
1286
+ const { size, offset } = window;
1287
+ const count = args["count"] ?? (args["withCount"] === true ? "exact" : void 0);
1288
+ const orderBy = builder.orderBy(table, args["orderBy"]);
1289
+ const op = selectOp(args, {
1290
+ orderBy: orderBy.length > 0 || table.primaryKey.length === 0 ? orderBy : defaultOrder(),
1291
+ limit: size + 1,
1292
+ lookAhead: true,
1293
+ offset,
1294
+ count: count === "exact" || count === "planned" || count === "estimated" ? count : void 0
1295
+ });
1296
+ const result = await run(op, args);
1297
+ if (!result.ok) return result;
1298
+ return ok(offsetEnvelope(result.data.rows, result.data.count, size, offset));
1299
+ }
1300
+ async function cursorPage(args) {
1301
+ const size = Number(args["size"]);
1302
+ if (!Number.isInteger(size) || size < 1) return runner.fail(table, dbError("invalid_request", "\"size\" must be a positive integer"));
1303
+ const requested = builder.orderBy(table, args["orderBy"]);
1304
+ const related = requested.find((term) => term.relation);
1305
+ if (related) return runner.fail(table, dbError("invalid_request", `Cursor pages can't sort by the relation "${related.relation?.name}"; use an offset page`));
1306
+ const orderBy = withTieBreaker(requested);
1307
+ const { selection: withSort, added } = ensureColumns(selection(args), orderBy);
1308
+ const sort = sortKey(`${table.key}|${orderBy.map((term) => `${term.column}.${term.direction}.${term.nulls ?? ""}`).join(",")}`);
1309
+ let after;
1310
+ if (typeof args["after"] === "string") {
1311
+ const decoded = decodeBoundCursor(args["after"], sort);
1312
+ if ("invalid" in decoded && decoded.invalid === "sort") return runner.fail(table, dbError("invalid_request", "The cursor continues another orderBy; pass after: null to start the new order"));
1313
+ const values = "values" in decoded ? decoded.values : void 0;
1314
+ if (!values || values.length !== orderBy.length) return runner.fail(table, dbError("invalid_request", "Invalid cursor"));
1315
+ const { byDb } = lookupOf(table);
1316
+ after = keysetCondition(orderBy, values, (name) => byDb.get(name)?.[1].nullable ?? true);
1317
+ }
1318
+ const op = selectOp(args, {
1319
+ selection: withSort,
1320
+ where: and(builder.where(table, args["where"]), after),
1321
+ orderBy,
1322
+ limit: size + 1,
1323
+ lookAhead: true,
1324
+ offset: void 0,
1325
+ count: args["withCount"] === true && after === void 0 ? "exact" : void 0
1326
+ });
1327
+ const result = await run(op, args);
1328
+ if (!result.ok) return result;
1329
+ let total = result.data.count;
1330
+ if (args["withCount"] === true && after !== void 0) {
1331
+ const counted = await run(selectOp(args, {
1332
+ selection: {
1333
+ columns: [],
1334
+ includes: []
1335
+ },
1336
+ orderBy: [],
1337
+ limit: void 0,
1338
+ offset: void 0,
1339
+ count: "exact",
1340
+ head: true
1341
+ }), args);
1342
+ if (!counted.ok) return counted;
1343
+ total = counted.data.count;
1344
+ }
1345
+ const rows = result.data.rows.slice(0, size);
1346
+ const hasMore = result.data.rows.length > size;
1347
+ const last = rows.at(-1);
1348
+ const aliases = new Map(withSort.columns.map((entry) => [entry.column, entry.alias]));
1349
+ const nextCursor = hasMore && last ? encodeBoundCursor(orderBy.map((term) => encodeValue(last[aliases.get(term.column) ?? term.column])), sort) : null;
1350
+ return ok({
1351
+ items: added.length > 0 ? rows.map((row) => strip(row, added)) : rows,
1352
+ nextCursor,
1353
+ hasMore,
1354
+ ...args["withCount"] === true ? { total: total ?? 0 } : {}
1355
+ });
1356
+ }
1357
+ function withTieBreaker(orderBy) {
1358
+ const terms = [...orderBy];
1359
+ for (const name of table.primaryKey) {
1360
+ const column = builder.column(table, name);
1361
+ if (!terms.some((term) => term.column === column)) terms.push({
1362
+ column,
1363
+ direction: terms[0]?.direction ?? "asc"
1364
+ });
1365
+ }
1366
+ return terms;
1367
+ }
1368
+ function ensureColumns(base, orderBy) {
1369
+ const columns = [...base.columns];
1370
+ const selected = new Set(columns.map((entry) => entry.column));
1371
+ const { byDb } = lookupOf(table);
1372
+ const added = [];
1373
+ for (const term of orderBy) {
1374
+ if (selected.has(term.column)) continue;
1375
+ const alias = byDb.get(term.column)?.[0];
1376
+ columns.push(alias === void 0 ? {
1377
+ alias: term.column,
1378
+ column: term.column
1379
+ } : builder.selectColumn(table, alias));
1380
+ selected.add(term.column);
1381
+ added.push(alias ?? term.column);
1382
+ }
1383
+ return {
1384
+ selection: {
1385
+ columns,
1386
+ includes: base.includes
1387
+ },
1388
+ added
1389
+ };
1390
+ }
1391
+ return base;
1392
+ }
1393
+ // src/core/rpc-result.ts
1394
+ const columnsByFunction = /* @__PURE__ */ new WeakMap();
1395
+ function columnsOf(meta, fn) {
1396
+ const cached = columnsByFunction.get(fn);
1397
+ if (cached !== void 0) return cached;
1398
+ let columns = null;
1399
+ const { result } = fn;
1400
+ if (result && "table" in result) {
1401
+ const table = meta.tables[result.table];
1402
+ if (table) {
1403
+ columns = /* @__PURE__ */ new Map();
1404
+ for (const [db, [app, column]] of lookupOf(table).byDb) if (app !== db || column.codec) columns.set(db, [app, column.codec]);
1405
+ }
1406
+ } else if (result) columns = new Map(result.columns.map((column) => [column.db, [column.name ?? column.db, column.codec]]));
1407
+ columnsByFunction.set(fn, columns);
1408
+ return columns;
1409
+ }
1410
+ const selectByFunction = /* @__PURE__ */ new WeakMap();
1411
+ /**
1412
+ * The columns `$rpc` selects for a function whose result has a codec column,
1413
+ * with that column cast to text as repository reads do. Undefined when no
1414
+ * result column has a codec, so the call selects everything.
1415
+ */
1416
+ function rpcSelect(meta, fn) {
1417
+ if (!fn) return;
1418
+ let select = selectByFunction.get(fn);
1419
+ if (select === void 0) {
1420
+ const { result } = fn;
1421
+ const table = result && "table" in result ? meta.tables[result.table] : void 0;
1422
+ const columns = table ? [...lookupOf(table).byDb].map(([db, [, column]]) => [db, column.codec]) : result && "columns" in result ? result.columns.map((column) => [column.db, column.codec]) : [];
1423
+ select = columns.some(([, codec]) => codec) ? columns.map(([column, codec]) => codec ? {
1424
+ column,
1425
+ cast: "text"
1426
+ } : { column }) : null;
1427
+ selectByFunction.set(fn, select);
1428
+ }
1429
+ return select ?? void 0;
1430
+ }
1431
+ function decodeRow(columns, row) {
1432
+ if (!isPlainObject(row)) return row;
1433
+ const out = {};
1434
+ for (const key in row) {
1435
+ if (!Object.hasOwn(row, key)) continue;
1436
+ const column = columns.get(key);
1437
+ if (!column) {
1438
+ out[key] = row[key];
1439
+ continue;
1440
+ }
1441
+ const [app, codec] = column;
1442
+ out[app] = codec ? decodeValue(codec, row[key]) : row[key];
1443
+ }
1444
+ return out;
1445
+ }
1446
+ const overloadMeta = /* @__PURE__ */ new WeakMap();
1447
+ /**
1448
+ * The signature `$rpc` calls: PostgREST picks an overload by the argument
1449
+ * names, so a call matches the overload that has every name it passes and every
1450
+ * argument without a default. Undefined when the function is in another schema
1451
+ * or when no overload, or more than one, matches.
1452
+ */
1453
+ function rpcFunction(meta, name, schema, args) {
1454
+ const fn = meta.functions[name];
1455
+ if (!fn || fn.schema !== schema) return;
1456
+ if (!fn.overloads) return fn;
1457
+ const keys = Object.keys(args).filter((key) => args[key] !== void 0);
1458
+ const matches = fn.overloads.filter((overload) => keys.every((key) => overload.args.some((arg) => arg.name === key)) && overload.args.every((arg) => arg.optional === true || keys.includes(arg.name)));
1459
+ const [match] = matches;
1460
+ if (!match || matches.length > 1) return;
1461
+ let resolved = overloadMeta.get(match);
1462
+ if (!resolved) {
1463
+ resolved = {
1464
+ ...match,
1465
+ name: fn.name,
1466
+ schema: fn.schema
1467
+ };
1468
+ overloadMeta.set(match, resolved);
1469
+ }
1470
+ return resolved;
1471
+ }
1472
+ /**
1473
+ * The `$rpc` result in app form: rows of a table or a `returns table (...)`
1474
+ * record get the configured casing and codecs, like repository reads. Scalars,
1475
+ * json and calls without a known signature come back unchanged.
1476
+ */
1477
+ function decodeRpcResult(meta, fn, data) {
1478
+ if (!fn) return data;
1479
+ const columns = columnsOf(meta, fn);
1480
+ if (!columns || columns.size === 0) return data;
1481
+ return Array.isArray(data) ? data.map((row) => decodeRow(columns, row)) : decodeRow(columns, data);
1482
+ }
1483
+ // src/core/define.ts
1484
+ /**
1485
+ * A supabase-js client builds a new storage client on each read of `storage`,
1486
+ * so it is read once per connection.
1487
+ */
1488
+ const clientStorage = /* @__PURE__ */ new WeakMap();
1489
+ function storageOf(source) {
1490
+ if (source.storage) return source.storage;
1491
+ const cached = clientStorage.get(source);
1492
+ if (cached) return cached;
1493
+ const client = source.client;
1494
+ const storage = isRecord(client) ? client["storage"] : void 0;
1495
+ if (isStorageApi(storage)) {
1496
+ clientStorage.set(source, storage);
1497
+ return storage;
1498
+ }
1499
+ throw new TypeError("better-supabase: db.$storage needs a client with storage, or connect(executor, context, { storage })");
1500
+ }
1501
+ /**
1502
+ * The isomorphic definition of your data layer: schema plus plugins. Holds no
1503
+ * secrets and no connection; `connect()` binds it to a client per request.
1504
+ */
1505
+ var BetterSupabase = class BetterSupabase {
1506
+ schema;
1507
+ plugins;
1508
+ events;
1509
+ options;
1510
+ constructor(schema, plugins = [], options = {}, events = definitionEvents(options)) {
1511
+ const names = /* @__PURE__ */ new Set();
1512
+ for (const plugin of plugins) {
1513
+ if (plugin.apiVersion !== 1) throw new TypeError(`better-supabase: plugin "${plugin.name}" targets plugin API v${String(plugin.apiVersion)}; this version supports v1`);
1514
+ if (names.has(plugin.name)) throw new TypeError(`better-supabase: plugin "${plugin.name}" is already installed`);
1515
+ names.add(plugin.name);
1516
+ }
1517
+ this.schema = schema;
1518
+ this.plugins = orderPlugins(plugins);
1519
+ this.options = options;
1520
+ this.events = events;
1521
+ const { temporal } = options;
1522
+ if (temporal !== void 0) {
1523
+ const previous = providedTemporal();
1524
+ if (previous !== void 0 && previous !== temporal) events.logger.warn("defineSupabase got a different `temporal` namespace than the one already provided; decoded rows, jobs and webhooks in this process now use the newer one. Pass the same namespace to every definition.");
1525
+ provideTemporal(temporal);
1526
+ }
1527
+ }
1528
+ get meta() {
1529
+ return this.schema.meta;
1530
+ }
1531
+ /** The `now` option, else this definition's own `Temporal` clock. */
1532
+ #now() {
1533
+ const { now, temporal } = this.options;
1534
+ if (now) return now;
1535
+ return temporal ? () => temporal.Now.instant() : nowInstant;
1536
+ }
1537
+ /**
1538
+ * The `Temporal` this definition uses: the `temporal` option, else the
1539
+ * global.
1540
+ */
1541
+ get temporal() {
1542
+ return this.options.temporal ?? optionalTemporal();
1543
+ }
1544
+ /** The schema set by `claims()`; its output types `session.claims`. */
1545
+ get claimsSchema() {
1546
+ return this.options.claims;
1547
+ }
1548
+ /**
1549
+ * The schema set by `userMetadata()`; its output types
1550
+ * `session.userMetadata`.
1551
+ */
1552
+ get userMetadataSchema() {
1553
+ return this.options.userMetadata;
1554
+ }
1555
+ /**
1556
+ * Returns a new instance whose servers validate verified JWT claims (custom
1557
+ * access token hook output) with `schema`, and whose sessions are typed by
1558
+ * it. A token that fails it resolves to `{ kind: 'invalid', reason: 'claims'
1559
+ * }`.
1560
+ *
1561
+ * ```ts
1562
+ * const betterSupabase = defineSupabase(schema).claims(
1563
+ * z.object({ tenant_id: z.uuid() }),
1564
+ * );
1565
+ * ```
1566
+ */
1567
+ claims(schema) {
1568
+ return new BetterSupabase(this.schema, this.plugins, {
1569
+ ...this.options,
1570
+ claims: schema
1571
+ }, this.events);
1572
+ }
1573
+ /**
1574
+ * Returns a new instance whose sessions parse `user_metadata` with `schema`
1575
+ * into a typed `session.userMetadata`. Users can change their metadata with
1576
+ * `auth.updateUser()`, so a failure only leaves `profile` undefined (with one
1577
+ * warning), and no authorization code reads it. It is for display only:
1578
+ * roles, memberships, the tenant and entitlements come from the verified
1579
+ * claims, never from `profile`.
1580
+ *
1581
+ * ```ts
1582
+ * const betterSupabase = defineSupabase(schema).userMetadata(
1583
+ * z.object({ display_name: z.string() }),
1584
+ * );
1585
+ * ```
1586
+ */
1587
+ userMetadata(schema) {
1588
+ return new BetterSupabase(this.schema, this.plugins, {
1589
+ ...this.options,
1590
+ userMetadata: schema
1591
+ }, this.events);
1592
+ }
1593
+ /**
1594
+ * Returns a new instance whose `.orThrow()` throws `mapper(error)` instead of
1595
+ * a `DbException`, and whose results `toBetterResult` maps the same way.
1596
+ * Results themselves keep their `DbError`.
1597
+ *
1598
+ * ```ts
1599
+ * const betterSupabase = defineSupabase(schema).mapError(
1600
+ * (error) => new AppError(error),
1601
+ * );
1602
+ * ```
1603
+ */
1604
+ mapError(mapper) {
1605
+ return new BetterSupabase(this.schema, this.plugins, {
1606
+ ...this.options,
1607
+ throwAs: mapper
1608
+ }, this.events);
1609
+ }
1610
+ /**
1611
+ * Returns a new instance whose `db.$buckets` has one client per bucket,
1612
+ * connected to `db.$storage` so Storage runs as the same caller.
1613
+ *
1614
+ * ```ts
1615
+ * const betterSupabase = defineSupabase(schema).buckets({ logos, avatars });
1616
+ * betterSupabase.connect(client).$buckets.logos.signedUrl({ ... });
1617
+ * ```
1618
+ */
1619
+ buckets(registered) {
1620
+ return new BetterSupabase(this.schema, this.plugins, {
1621
+ ...this.options,
1622
+ buckets: registered
1623
+ }, this.events);
1624
+ }
1625
+ /**
1626
+ * Returns a new instance whose every `Db` has the installed block instances
1627
+ * as properties, under their keys in camel case. Each client runs as the
1628
+ * `Db`'s caller and acts in its organization (`db.$context.tenant`), so app
1629
+ * code passes neither a transport nor an organization.
1630
+ *
1631
+ * ```ts
1632
+ * export const betterSupabase = defineSupabase(schema).blocks(
1633
+ * defineBlocks(blockConfig, blocks),
1634
+ * );
1635
+ * const db = await bsb.db();
1636
+ * await db.tags.list({ kind: "customer" });
1637
+ * ```
1638
+ */
1639
+ blocks(set) {
1640
+ return new BetterSupabase(this.schema, this.plugins, {
1641
+ ...this.options,
1642
+ blocks: set
1643
+ }, this.events);
1644
+ }
1645
+ #specs;
1646
+ #truncatedTables = /* @__PURE__ */ new Set();
1647
+ /** A hub without listeners, for decoding read-set results. */
1648
+ #decodeEvents;
1649
+ /** One getter per table, shared by every db this instance connects. */
1650
+ #tables;
1651
+ #errorMappers = /* @__PURE__ */ new WeakMap();
1652
+ /**
1653
+ * Builds serializable `QuerySpec`s with the same arguments and result types
1654
+ * as the repository: `betterSupabase.spec.customers.list({ select: ['id']
1655
+ * })`.
1656
+ */
1657
+ get spec() {
1658
+ this.#specs ??= createSpecs(this.meta);
1659
+ return this.#specs;
1660
+ }
1661
+ /**
1662
+ * App keys of every table a spec reads; mutations of any of them make it
1663
+ * stale.
1664
+ */
1665
+ tablesOf(spec) {
1666
+ return specTables(this.meta, spec);
1667
+ }
1668
+ /**
1669
+ * Returns a new instance with the plugin appended. A plugin with the name of
1670
+ * an extension the schema installed replaces it, so
1671
+ * `.use(membershipsExtension({ resolve }))` swaps the organization resolver.
1672
+ * Any other name installed twice throws.
1673
+ */
1674
+ use(plugin) {
1675
+ const fromSchema = new Set(this.schema.extensions);
1676
+ const replaces = this.plugins.some((installed) => installed.name === plugin.name && fromSchema.has(installed));
1677
+ return new BetterSupabase(this.schema, replaces ? this.plugins.map((installed) => installed.name === plugin.name && fromSchema.has(installed) ? plugin : installed) : [...this.plugins, plugin], this.options, this.events);
1678
+ }
1679
+ /**
1680
+ * Declares the tables an RPC writes, so cache adapters and live queries
1681
+ * invalidate them after it succeeds.
1682
+ *
1683
+ * ```ts
1684
+ * betterSupabase.defineRpc("archive_customer", {
1685
+ * invalidates: ["customers", "notes"],
1686
+ * });
1687
+ * ```
1688
+ */
1689
+ defineRpc(name, options) {
1690
+ for (const table of options.invalidates) if (!this.meta.tables[table]) throw new TypeError(`better-supabase: defineRpc("${name}") invalidates unknown table "${table}"`);
1691
+ return new BetterSupabase(this.schema, this.plugins, {
1692
+ ...this.options,
1693
+ rpc: {
1694
+ ...this.options.rpc,
1695
+ [name]: options
1696
+ }
1697
+ }, this.events);
1698
+ }
1699
+ /** Observes queries, mutations, errors, auth and refreshes. */
1700
+ on(name, handler) {
1701
+ return this.events.on(name, handler);
1702
+ }
1703
+ /**
1704
+ * Invalidates `adapter` after every mutation in this runtime. Returns a
1705
+ * function that detaches it. Adapter failures are logged, never thrown.
1706
+ */
1707
+ cache(adapter) {
1708
+ const report = (cause, table) => {
1709
+ this.events.logger.error(`cache adapter "${adapter.name}" failed`, {
1710
+ cause,
1711
+ table
1712
+ });
1713
+ };
1714
+ const invalidate = (target) => {
1715
+ try {
1716
+ const pending = adapter.invalidate(target);
1717
+ if (pending) pending.catch((cause) => {
1718
+ report(cause, target.table);
1719
+ });
1720
+ } catch (cause) {
1721
+ report(cause, target.table);
1722
+ }
1723
+ };
1724
+ const offMutation = this.on("mutation", (notice) => {
1725
+ invalidate(cacheTargetOf(this.meta, notice));
1726
+ });
1727
+ const offRpc = this.on("rpc", (notice) => {
1728
+ for (const target of rpcCacheTargets(this.meta, notice)) invalidate(target);
1729
+ });
1730
+ return () => {
1731
+ offMutation();
1732
+ offRpc();
1733
+ };
1734
+ }
1735
+ connect(source, context = {}, options = {}) {
1736
+ const client = isExecutor(source) ? void 0 : source;
1737
+ const base = options.executor ?? (isExecutor(source) ? source : postgrestExecutor(source, this.executorOptions()));
1738
+ const recorder = new StatsRecorder(options.stats);
1739
+ const tuning = {
1740
+ ...options.timeout === void 0 ? {} : { timeout: options.timeout },
1741
+ ...options.retry === void 0 ? {} : { retry: options.retry }
1742
+ };
1743
+ return this.#db({
1744
+ client,
1745
+ storage: options.storage
1746
+ }, base, context, this.plugins, recorder, tuning);
1747
+ }
1748
+ /**
1749
+ * The `postgrestExecutor` options this definition implies (`urlLengthLimit`,
1750
+ * `postgrestVersion`), for adapters that build their own executor and should
1751
+ * chunk reads the same way.
1752
+ */
1753
+ executorOptions() {
1754
+ const { urlLengthLimit, postgrestVersion } = this.options;
1755
+ return {
1756
+ ...urlLengthLimit === void 0 ? {} : { urlLengthLimit },
1757
+ ...postgrestVersion === void 0 ? {} : { postgrestVersion }
1758
+ };
1759
+ }
1760
+ /** The caller's context with every plugin's `context` hook applied. */
1761
+ #derive(given, plugins) {
1762
+ let context = given;
1763
+ for (const plugin of plugins) {
1764
+ if (!plugin.context) continue;
1765
+ try {
1766
+ context = plugin.context(context, { schema: this.meta });
1767
+ } catch (cause) {
1768
+ this.events.logger.error(`plugin "${plugin.name}" context threw`, { cause });
1769
+ }
1770
+ }
1771
+ return context;
1772
+ }
1773
+ #db(source, base, given, plugins, recorder, tuning = {}, events = this.events) {
1774
+ const context = this.#derive(given, plugins);
1775
+ let executor = base;
1776
+ for (const plugin of plugins) if (plugin.wrapExecutor) executor = plugin.wrapExecutor(executor);
1777
+ const wrapped = executor;
1778
+ executor = recordStats(executor, recorder);
1779
+ const errorMappers = this.#errorMappersFor(plugins);
1780
+ const runner = new OperationRunner({
1781
+ meta: this.meta,
1782
+ builder: builderFor(this.meta),
1783
+ executor,
1784
+ plugins,
1785
+ context,
1786
+ events,
1787
+ errorMappers,
1788
+ now: this.#now(),
1789
+ maxRows: this.options.maxRows ?? 1e3,
1790
+ truncatedTables: this.#truncatedTables,
1791
+ tuning
1792
+ });
1793
+ const db = Object.create(this.#tablePrototype());
1794
+ dbStates.set(db, {
1795
+ runner,
1796
+ plugins,
1797
+ repositories: /* @__PURE__ */ new Map()
1798
+ });
1799
+ const { client } = source;
1800
+ Object.defineProperty(db, "$storage", {
1801
+ get: () => storageOf(source),
1802
+ configurable: true
1803
+ });
1804
+ const { buckets } = this.options;
1805
+ if (buckets) {
1806
+ let connected;
1807
+ Object.defineProperty(db, "$buckets", {
1808
+ get: () => {
1809
+ connected ??= Object.fromEntries(Object.entries(buckets).map(([name, bucket]) => [name, bucket.connect(storageOf(source))]));
1810
+ return connected;
1811
+ },
1812
+ configurable: true
1813
+ });
1814
+ }
1815
+ Object.assign(db, {
1816
+ $client: client,
1817
+ $executor: executor,
1818
+ $context: context,
1819
+ $rpc: (name, ...rest) => rpc(this.schema.meta, executor, errorMappers, tuning, name, rest).map((data) => {
1820
+ const registered = this.options.rpc?.[name];
1821
+ if (registered) this.events.emit("rpc", {
1822
+ name,
1823
+ invalidates: registered.invalidates,
1824
+ context
1825
+ });
1826
+ return data;
1827
+ }).mapError((error) => {
1828
+ if (events.has("error")) events.emit("error", errorEvent(error));
1829
+ return error;
1830
+ }),
1831
+ $with: (extra) => this.#db(source, base, {
1832
+ ...given,
1833
+ ...extra
1834
+ }, plugins, recorder, tuning),
1835
+ $withoutPlugins: (options) => this.#db(source, base, given, keptPlugins(plugins, options?.keep ?? []), recorder, tuning),
1836
+ $stats: () => recorder.snapshot(),
1837
+ $table: (name) => {
1838
+ if (!Object.hasOwn(this.meta.tables, name)) throw new TypeError(`better-supabase: unknown table "${name}". Known: ${Object.keys(this.meta.tables).join(", ")}`);
1839
+ return db[name];
1840
+ },
1841
+ $run: (spec, options) => runSpec(db, spec, options?.signal),
1842
+ $many: (target, ...rest) => {
1843
+ if (isReadSet(target)) {
1844
+ const [values, options] = rest;
1845
+ return readSet(target, values, options?.signal);
1846
+ }
1847
+ const [options] = rest;
1848
+ if (!Array.isArray(target)) return AsyncResult.err(dbError("invalid_request", "db.$many() expects an array of specs or a read set"));
1849
+ return many(target, options?.signal, true);
1850
+ },
1851
+ $search: (name, args) => searchTable(runner, base, this.meta, name, args)
1852
+ });
1853
+ const many = (specs, signal, usePlugins) => AsyncResult.from(async () => {
1854
+ const invalid = specs.findIndex((spec) => !isQuerySpec(spec));
1855
+ if (invalid !== -1) return err(dbError("invalid_request", `db.$many() entry ${invalid} is not a QuerySpec from betterSupabase.spec`));
1856
+ const active = usePlugins ? plugins : [];
1857
+ const batchSource = usePlugins ? wrapped : base;
1858
+ const batch = batchSource.batch?.bind(batchSource);
1859
+ const batching = batch && specs.length > 1 ? batchingExecutor({
1860
+ ...base,
1861
+ batch
1862
+ }, specs.length) : void 0;
1863
+ const target = batching ? this.#db(source, batching.executor, given, active, recorder, tuning) : usePlugins ? db : this.#db(source, base, given, NO_PLUGINS, recorder, tuning);
1864
+ const results = await Promise.all(specs.map(async (spec) => {
1865
+ try {
1866
+ return await runSpec(target, spec, signal);
1867
+ } finally {
1868
+ batching?.done();
1869
+ }
1870
+ }));
1871
+ const data = [];
1872
+ for (const result of results) {
1873
+ if (!result.ok) return result;
1874
+ data.push(result.data);
1875
+ }
1876
+ return ok(data);
1877
+ });
1878
+ const readSet = (set, values, signal) => AsyncResult.from(async () => {
1879
+ const problems = checkParams(set, values);
1880
+ if (problems.length > 0) return err(dbError("invalid_request", `db.$many(${set.name}): ${problems.join(", ")}`));
1881
+ const keys = Object.keys(set.specs);
1882
+ const { specs: bound, noCaller } = bindParams(set, values, context);
1883
+ if (base.batch || !executor.rpc) {
1884
+ if (noCaller) return err(noCaller);
1885
+ const result = await many(keys.map((key) => bound[key]), signal, false);
1886
+ if (!result.ok) return result;
1887
+ return ok(Object.fromEntries(keys.map((key, i) => [key, result.data[i]])));
1888
+ }
1889
+ const called = await executor.rpc(set.functionName, { p: values ?? {} }, {
1890
+ schema: "public",
1891
+ get: true,
1892
+ errorMappers,
1893
+ ...signal ? { signal } : {}
1894
+ });
1895
+ if (!called.ok) return called;
1896
+ return this.#decodeReadSet(source, context, set, bound, called.data);
1897
+ });
1898
+ const throwAs = this.options.throwAs;
1899
+ if (throwAs) for (const name of [
1900
+ "$rpc",
1901
+ "$run",
1902
+ "$many",
1903
+ "$search"
1904
+ ]) db[name] = mapThrows(db[name], throwAs);
1905
+ return db;
1906
+ }
1907
+ /**
1908
+ * Decodes what a read-set function returned (`{ [key]: { rows, count } }`) by
1909
+ * running each spec against those rows, so casing, codecs and aggregates come
1910
+ * out exactly as from `db.$run`.
1911
+ */
1912
+ async #decodeReadSet(source, context, set, specs, data) {
1913
+ const payload = data ?? {};
1914
+ let rows = [];
1915
+ let count = null;
1916
+ const decoder = this.#db(source, {
1917
+ name: "read-set",
1918
+ execute: (op) => {
1919
+ if (op.kind === "select" && op.single) {
1920
+ if (rows.length > 1) return Promise.resolve(err(dbError("multiple_rows", `Expected one ${op.table.key} row`)));
1921
+ if (rows.length === 0 && op.single === "one") return Promise.resolve(err(dbError("not_found", `No ${op.table.key} row matched`)));
1922
+ }
1923
+ return Promise.resolve(ok({
1924
+ rows,
1925
+ count
1926
+ }));
1927
+ }
1928
+ }, context, NO_PLUGINS, new StatsRecorder(), {}, this.#decodeEvents ??= new EventHub(this.events.logger, this.events.now));
1929
+ const out = {};
1930
+ for (const [key, spec] of Object.entries(specs)) {
1931
+ const entry = payload[key];
1932
+ if (!entry) return err(dbError("unexpected", `${set.functionName}() returned no "${key}". Run \`better-supabase gen\` and migrate.`));
1933
+ rows = entry.rows ?? [];
1934
+ count = entry.count ?? null;
1935
+ const result = await runSpec(decoder, spec, void 0);
1936
+ if (!result.ok) return result;
1937
+ out[key] = result.data;
1938
+ }
1939
+ return ok(out);
1940
+ }
1941
+ #errorMappersFor(plugins) {
1942
+ let mappers = this.#errorMappers.get(plugins);
1943
+ if (!mappers) {
1944
+ mappers = [...this.options.errors ?? [], ...plugins.flatMap((plugin) => plugin.mapError ? [plugin.mapError] : [])];
1945
+ this.#errorMappers.set(plugins, mappers);
1946
+ }
1947
+ return mappers;
1948
+ }
1949
+ #tablePrototype() {
1950
+ if (this.#tables) return this.#tables;
1951
+ const tables = {};
1952
+ const throwAs = this.options.throwAs;
1953
+ const build = (state, key) => {
1954
+ let repository = state.repositories.get(key);
1955
+ if (repository) return repository;
1956
+ const table = this.meta.tables[key];
1957
+ repository = this.#repository(state.runner, key, table, state.plugins);
1958
+ if (throwAs) {
1959
+ for (const [name, method] of Object.entries(repository)) if (typeof method === "function" && name !== "extend") repository[name] = mapThrows(method, throwAs);
1960
+ }
1961
+ state.repositories.set(key, repository);
1962
+ return repository;
1963
+ };
1964
+ for (const key of Object.keys(this.meta.tables)) Object.defineProperty(tables, key, {
1965
+ enumerable: true,
1966
+ get() {
1967
+ const state = dbStates.get(this);
1968
+ return state ? build(state, key) : void 0;
1969
+ }
1970
+ });
1971
+ const { blocks, temporal } = this.options;
1972
+ this.#tables = blocks === void 0 ? tables : blocksPrototype(blocks, tables, Object.keys(this.meta.tables), this.events, temporal);
1973
+ return this.#tables;
1974
+ }
1975
+ #repository(runner, key, table, plugins) {
1976
+ const repository = createRepository(runner, table);
1977
+ for (const plugin of plugins) {
1978
+ const methods = plugin.repository?.({
1979
+ table,
1980
+ base: repository
1981
+ });
1982
+ if (!methods) continue;
1983
+ for (const [name, method] of Object.entries(methods)) {
1984
+ if (name in repository) throw new TypeError(`better-supabase: plugin "${plugin.name}" redefines "${key}.${name}"`);
1985
+ repository[name] = method;
1986
+ }
1987
+ }
1988
+ repository["extend"] = (build) => ({
1989
+ ...repository,
1990
+ ...build(repository)
1991
+ });
1992
+ return repository;
1993
+ }
1994
+ };
1995
+ const dbStates = /* @__PURE__ */ new WeakMap();
1996
+ function mapThrows(method, throwAs) {
1997
+ return function mapped(...args) {
1998
+ const value = method.apply(this, args);
1999
+ return value instanceof AsyncResult ? withErrorMapper(value, throwAs) : value;
2000
+ };
2001
+ }
2002
+ function runSpec(db, spec, signal) {
2003
+ if (!isQuerySpec(spec)) return AsyncResult.err(dbError("invalid_request", "db.$run() expects a QuerySpec from betterSupabase.spec"));
2004
+ const method = db[spec.table]?.[spec.method];
2005
+ if (!method) return AsyncResult.err(dbError("invalid_request", `Unknown table "${spec.table}" in QuerySpec`));
2006
+ if (containsPlaceholder(spec.args)) return AsyncResult.err(dbError("invalid_request", "This spec comes from a read set and still holds placeholders; run it with db.$many(readSet, params)"));
2007
+ const args = [...spec.args];
2008
+ if (signal) {
2009
+ const index = spec.method === "get" ? 1 : 0;
2010
+ args[index] = {
2011
+ ...args[index],
2012
+ signal
2013
+ };
2014
+ }
2015
+ return method(...args);
2016
+ }
2017
+ function rpc(meta, executor, errorMappers, defaults, name, rest) {
2018
+ const [given, options] = rest;
2019
+ const args = given === void 0 ? void 0 : encodeArguments(given);
2020
+ return AsyncResult.from(async () => {
2021
+ if (!executor.rpc) return err(dbError("unsupported", `Executor "${executor.name}" does not support rpc()`));
2022
+ const tuning = {
2023
+ ...defaults,
2024
+ ...options?.timeout === void 0 ? {} : { timeout: options.timeout },
2025
+ ...options?.retry === void 0 ? {} : { retry: options.retry }
2026
+ };
2027
+ const invalid = invalidTuning(tuning);
2028
+ if (invalid) return err(dbError("invalid_request", invalid));
2029
+ const limit = deadline(options?.signal, tuning.timeout);
2030
+ const schema = options?.schema ?? "public";
2031
+ const fn = rpcFunction(meta, name, schema, args ?? {});
2032
+ const select = options?.raw === true ? void 0 : rpcSelect(meta, fn);
2033
+ const context = {
2034
+ schema,
2035
+ errorMappers,
2036
+ ...limit.signal ? { signal: limit.signal } : {},
2037
+ ...tuning.retry === void 0 ? {} : { retry: tuning.retry },
2038
+ ...fn ? { function: fn } : {},
2039
+ ...select ? { select } : {}
2040
+ };
2041
+ let result;
2042
+ try {
2043
+ result = await executor.rpc(name, args ?? {}, context);
2044
+ } finally {
2045
+ limit.clear();
2046
+ }
2047
+ if (!result.ok && limit.timedOut()) return err(dbError("timeout", `The request timed out after ${tuning.timeout} ms`));
2048
+ if (!result.ok) return result;
2049
+ let data = result.data;
2050
+ if (options?.raw !== true) try {
2051
+ data = decodeRpcResult(meta, fn, data);
2052
+ } catch (cause) {
2053
+ if (cause instanceof DbException) return err(cause.error);
2054
+ throw cause;
2055
+ }
2056
+ if (!options?.returns) return ok(data);
2057
+ const checked = await validate(options.returns, data, `${name}() result`);
2058
+ return checked.ok ? ok(checked.data) : checked;
2059
+ });
2060
+ }
2061
+ /**
2062
+ * Creates the data-layer definition from the generated `schema`, with the
2063
+ * repository extensions of the installed blocks (organization scope, trash,
2064
+ * `created_by` and `updated_at` stamps, write validation) already in place.
2065
+ *
2066
+ * ```ts
2067
+ * export const betterSupabase = defineSupabase(schema).use(guards());
2068
+ * ```
2069
+ */
2070
+ function defineSupabase(schema, options) {
2071
+ return new BetterSupabase(schema, schema.extensions ?? [], options);
2072
+ }
2073
+ export { decodeRows as a, rowKey as c, encodeCursor as i, rpcCacheTargets as l, defineSupabase as n, cacheTargetOf as o, decodeCursor as r, memoryCache as s, BetterSupabase as t };