better-supabase 0.7.0 → 0.8.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 (500) hide show
  1. package/README.md +6 -2
  2. package/dist/{access-sql-B0dF-SoF.js → access-sql-CrSbK1q-.js} +1 -1
  3. package/dist/{adapter-B-tL8hqg.js → adapter-CN45ibbV.js} +663 -157
  4. package/dist/{agents-CVHGd7It.d.ts → agents-BY_LQXtQ.d.ts} +4 -4
  5. package/dist/{ai-cache-CBWs1W0k.js → ai-cache-Dfgk8nBT.js} +2 -1
  6. package/dist/{ai-cache-DaDu_G5L.d.ts → ai-cache-DrUMMgp6.d.ts} +4 -4
  7. package/dist/{ai-chat-B24UI962.js → ai-chat-CVLRWbtS.js} +4 -3
  8. package/dist/{ai-chat-7amvXjmQ.d.ts → ai-chat-DXkMy74O.d.ts} +5 -5
  9. package/dist/{ai-files-CSPNswUY.js → ai-files-CioLu5du.js} +5 -4
  10. package/dist/ai-message-DfaP8sis.js +14 -0
  11. package/dist/ai-sdk/agents/index.d.ts +4 -4
  12. package/dist/ai-sdk/batches/index.d.ts +4 -4
  13. package/dist/ai-sdk/batches/index.js +4 -4
  14. package/dist/ai-sdk/cache/index.d.ts +2 -2
  15. package/dist/ai-sdk/cache/index.js +2 -2
  16. package/dist/ai-sdk/chat/index.d.ts +1 -1
  17. package/dist/ai-sdk/chat/index.js +8 -20
  18. package/dist/ai-sdk/embeddings/index.d.ts +2 -2
  19. package/dist/ai-sdk/files/index.d.ts +3 -3
  20. package/dist/ai-sdk/files/index.js +4 -4
  21. package/dist/ai-sdk/index.d.ts +37 -9
  22. package/dist/ai-sdk/index.js +3 -2
  23. package/dist/ai-sdk/mcp/index.d.ts +43 -6
  24. package/dist/ai-sdk/mcp/index.js +36 -7
  25. package/dist/ai-sdk/memory/index.d.ts +2 -2
  26. package/dist/ai-sdk/memory/index.js +1 -1
  27. package/dist/ai-sdk/workflow/index.d.ts +6 -6
  28. package/dist/ai-sdk/workflow/index.js +13 -24
  29. package/dist/{ai-tasks-Cd1HMFvB.d.ts → ai-tasks-BRQ6iQLc.d.ts} +4 -4
  30. package/dist/{announcements-ZRGnScWI.d.ts → announcements-Bouy0Ski.d.ts} +3 -3
  31. package/dist/{announcements-CiyOs-xP.js → announcements-p_BFofiR.js} +1 -1
  32. package/dist/api-Dnf2q-Ht.d.ts +370 -0
  33. package/dist/api-DtHFC037.js +676 -0
  34. package/dist/{api-keys-CIjghYjV.d.ts → api-keys-C8BlF3L2.d.ts} +4 -4
  35. package/dist/arazzo/index.d.ts +255 -0
  36. package/dist/arazzo/index.js +622 -0
  37. package/dist/{assistant-DwdpDH1q.d.ts → assistant-DBlFDZsi.d.ts} +5 -5
  38. package/dist/astro/index.d.ts +7 -7
  39. package/dist/astro/index.js +7 -7
  40. package/dist/asyncapi/index.d.ts +103 -0
  41. package/dist/asyncapi/index.js +569 -0
  42. package/dist/authorizer-ayxUDXXP.js +126 -0
  43. package/dist/authorizer-eiOjo-3l.d.ts +73 -0
  44. package/dist/better-result/index.d.ts +118 -0
  45. package/dist/better-result/index.js +64 -0
  46. package/dist/{bind-l4kAvYSv.js → bind-ButSzrHe.js} +1 -1
  47. package/dist/{bind-Bu_ZNa3W.d.ts → bind-CQ5mPyX1.d.ts} +3 -3
  48. package/dist/{block-events-CrT8r7Fe.js → block-events-DTxU5tfr.js} +18 -3
  49. package/dist/{block-fields-GFkxl4dP.js → block-fields-CroxUuF2.js} +3 -3
  50. package/dist/{block-fields-SJ6fEf3o.d.ts → block-fields-D1pfrcIY.d.ts} +2 -2
  51. package/dist/{block-helpers-CKtbFcRv.d.ts → block-helpers-C0Xj8War.d.ts} +2 -2
  52. package/dist/{block-helpers-DWHxHsEQ.js → block-helpers-Cy3pB96I.js} +41 -9
  53. package/dist/{block-hooks-BmjMyXTa.js → block-hooks-BPNMIlLl.js} +3 -3
  54. package/dist/{block-hooks-plbZ0AbJ.d.ts → block-hooks-DaOVC7SC.d.ts} +3 -3
  55. package/dist/{block-transport-BLr-ZgLc.js → block-transport-bAKh-dGc.js} +28 -2
  56. package/dist/{block-transport-DvaoPuZ9.d.ts → block-transport-inD4fFq-.d.ts} +24 -2
  57. package/dist/blocks/agents/index.d.ts +3 -3
  58. package/dist/blocks/agents/index.js +5 -4
  59. package/dist/blocks/ai-cache/index.d.ts +3 -3
  60. package/dist/blocks/ai-cache/index.js +3 -3
  61. package/dist/blocks/ai-chat/index.d.ts +9 -4
  62. package/dist/blocks/ai-chat/index.js +5 -5
  63. package/dist/blocks/ai-chat/react/index.d.ts +3 -3
  64. package/dist/blocks/ai-chat/react/index.js +5 -5
  65. package/dist/blocks/ai-files/index.d.ts +3 -3
  66. package/dist/blocks/ai-files/index.js +3 -3
  67. package/dist/blocks/ai-providers/index.d.ts +3 -3
  68. package/dist/blocks/ai-providers/index.js +8 -7
  69. package/dist/blocks/ai-tasks/index.d.ts +3 -3
  70. package/dist/blocks/ai-tasks/index.js +7 -6
  71. package/dist/blocks/announcements/index.d.ts +3 -3
  72. package/dist/blocks/announcements/index.js +3 -3
  73. package/dist/blocks/announcements/react/index.d.ts +3 -3
  74. package/dist/blocks/announcements/react/index.js +3 -3
  75. package/dist/blocks/api-keys/index.d.ts +5 -5
  76. package/dist/blocks/api-keys/index.js +8 -8
  77. package/dist/blocks/attachments/index.d.ts +12 -8
  78. package/dist/blocks/attachments/index.js +22 -13
  79. package/dist/blocks/audit/index.d.ts +21 -10
  80. package/dist/blocks/audit/index.js +30 -11
  81. package/dist/blocks/billing/index.d.ts +11 -9
  82. package/dist/blocks/billing/index.js +15 -15
  83. package/dist/blocks/comments/index.d.ts +8 -8
  84. package/dist/blocks/comments/index.js +8 -7
  85. package/dist/blocks/connectors/index.d.ts +3 -3
  86. package/dist/blocks/connectors/index.js +7 -6
  87. package/dist/blocks/data-lifecycle/index.d.ts +12 -8
  88. package/dist/blocks/data-lifecycle/index.js +13 -8
  89. package/dist/blocks/entitlements/index.d.ts +3 -3
  90. package/dist/blocks/entitlements/index.js +1 -1
  91. package/dist/blocks/flags/index.d.ts +4 -4
  92. package/dist/blocks/flags/index.js +4 -3
  93. package/dist/blocks/inbox/index.d.ts +3 -3
  94. package/dist/blocks/inbox/index.js +4 -5
  95. package/dist/blocks/inbox/react/index.d.ts +1 -1
  96. package/dist/blocks/inbox/react/index.js +1 -1
  97. package/dist/blocks/inbox/react/server.d.ts +1 -1
  98. package/dist/blocks/index.d.ts +10 -10
  99. package/dist/blocks/index.js +6 -6
  100. package/dist/blocks/jobs/index.d.ts +48 -32
  101. package/dist/blocks/jobs/index.js +44 -287
  102. package/dist/blocks/knowledge/index.d.ts +3 -3
  103. package/dist/blocks/knowledge/index.js +3 -3
  104. package/dist/blocks/memory/index.d.ts +4 -4
  105. package/dist/blocks/memory/index.js +7 -6
  106. package/dist/blocks/notifications/index.d.ts +11 -9
  107. package/dist/blocks/notifications/index.js +20 -25
  108. package/dist/blocks/notifications/react/index.d.ts +1 -1
  109. package/dist/blocks/notifications/react/index.js +1 -1
  110. package/dist/blocks/onboarding/index.d.ts +3 -3
  111. package/dist/blocks/onboarding/index.js +3 -3
  112. package/dist/blocks/onboarding/react/index.d.ts +2 -2
  113. package/dist/blocks/onboarding/react/index.js +2 -2
  114. package/dist/blocks/onboarding/react/server.d.ts +1 -1
  115. package/dist/blocks/organizations/index.d.ts +9 -9
  116. package/dist/blocks/organizations/index.js +11 -18
  117. package/dist/blocks/outbox/index.d.ts +2 -2
  118. package/dist/blocks/outbox/index.js +16 -25
  119. package/dist/blocks/profiles/index.d.ts +7 -7
  120. package/dist/blocks/profiles/index.js +7 -6
  121. package/dist/blocks/push/index.d.ts +4 -4
  122. package/dist/blocks/push/index.js +3 -3
  123. package/dist/blocks/settings/index.d.ts +4 -4
  124. package/dist/blocks/settings/index.js +7 -6
  125. package/dist/blocks/sso/index.d.ts +5 -5
  126. package/dist/blocks/sso/index.js +6 -5
  127. package/dist/blocks/usage/index.d.ts +3 -3
  128. package/dist/blocks/usage/index.js +5 -4
  129. package/dist/blocks/waitlist/index.d.ts +5 -5
  130. package/dist/blocks/waitlist/index.js +5 -4
  131. package/dist/blocks/webhooks/index.d.ts +22 -13
  132. package/dist/blocks/webhooks/index.js +41 -70
  133. package/dist/blocks/workflow-builder/index.d.ts +4 -4
  134. package/dist/blocks/workflow-builder/index.js +3 -3
  135. package/dist/blocks/workflow-builder/react/index.d.ts +4 -4
  136. package/dist/blocks/workflow-builder/react/index.js +4 -4
  137. package/dist/blocks/workflows/index.d.ts +3 -3
  138. package/dist/blocks/workflows/index.js +3 -3
  139. package/dist/blocks/workflows/react/index.d.ts +3 -3
  140. package/dist/blocks/workflows/react/index.js +3 -3
  141. package/dist/build-hPwk3_X5.js +1296 -0
  142. package/dist/{build-BXIzE6Xv.js → build-meLuYGri.js} +3 -3
  143. package/dist/casing-DdFWEtqr.js +16 -0
  144. package/dist/chat-sdk/index.d.ts +6 -6
  145. package/dist/chat-sdk/index.js +5 -4
  146. package/dist/chat-sdk/react/index.d.ts +1 -1
  147. package/dist/chat-sdk/react/server.d.ts +1 -1
  148. package/dist/{claims-DDBQT6BK.js → claims-0KZVT804.js} +1 -1
  149. package/dist/cli/add-1dc5wM5k.js +69 -0
  150. package/dist/cli/arazzo-1.0-BalU61-_.js +532 -0
  151. package/dist/cli/arazzo-1.1-Bnfasbun.js +705 -0
  152. package/dist/cli/asyncapi-3.0.0-C78dBjR6.js +5593 -0
  153. package/dist/cli/asyncapi-3.1.0-g-7aIfV1.js +5833 -0
  154. package/dist/cli/bin.js +4 -4
  155. package/dist/cli/cache-CIfA-jBV.js +483 -0
  156. package/dist/cli/{codemod-Bl_tQpHn.js → codemod-JVlTQQG2.js} +4 -4
  157. package/dist/cli/{command-CK14fP91.js → command-DV-StG1x.js} +5 -0
  158. package/dist/cli/{config-DU7EJImt.js → config-C2Pz2_4A.js} +7 -4
  159. package/dist/cli/config-DpbF8ML3.js +2 -0
  160. package/dist/cli/{config-NiPxAmUF.js → config-M-WzL9O2.js} +116 -18
  161. package/dist/cli/{db-DOBPt660.js → db-BkcfOlyB.js} +2 -1
  162. package/dist/cli/{diff-SjkO5rNr.js → diff-D1jGdb3Y.js} +1 -1
  163. package/dist/cli/{doctor-CVdnLahA.js → doctor-VcDtuusV.js} +317 -222
  164. package/dist/cli/emit-BHHfwUoT.js +1136 -0
  165. package/dist/cli/{env-qXgyMV6r.js → env-B--LMhEe.js} +13 -10
  166. package/dist/cli/env-vzBG90Um.js +2 -0
  167. package/dist/cli/{env-CJLbUVPB.js → env-zHJtMIBo.js} +11 -3
  168. package/dist/cli/{errors-4v4DTtda.js → errors-CqTLXe2M.js} +18 -2
  169. package/dist/cli/{fastest-levenshtein-CFN-lNDv.js → fastest-levenshtein-CF7BCi9l.js} +1 -1
  170. package/dist/cli/files-BVupXPIC.js +34 -0
  171. package/dist/cli/gen-DmVj3u4L.js +322 -0
  172. package/dist/cli/{init-Cr6arjXU.js → glue-C1UE8gQN.js} +16 -313
  173. package/dist/cli/index.d.ts +59 -31
  174. package/dist/cli/index.js +8 -6
  175. package/dist/cli/init-CVZ3s5kl.js +258 -0
  176. package/dist/cli/{introspect-Bzuv1HHj.js → introspect-BToGNfm-.js} +14 -14
  177. package/dist/cli/{io-DI1mTdSA.js → io-CFzJVJ68.js} +5 -1
  178. package/dist/cli/{keys-BGCnnb-s.js → keys-CJhtIxJ3.js} +4 -4
  179. package/dist/cli/metadata-DSRKCaf-.js +133 -0
  180. package/dist/cli/names-D6LrQnOv.js +6 -0
  181. package/dist/cli/openapi-3.0-t7xwkuRH.js +928 -0
  182. package/dist/cli/openapi-3.1-CVze7tBS.js +870 -0
  183. package/dist/cli/openapi-3.2-CFoMYM01.js +1031 -0
  184. package/dist/cli/{openapi-BlRJ18s3.js → openapi-DWa4Ir1q.js} +8 -14
  185. package/dist/cli/prompts-BdeVmVpg.js +2 -0
  186. package/dist/cli/{prompts-BNcNfAve.js → prompts-DZJB1nTw.js} +6 -6
  187. package/dist/cli/{rolldown-runtime-BPOCksWG.js → rolldown-runtime-CMFfr-1z.js} +3 -1
  188. package/dist/cli/run-DA6_lg3w.js +389 -0
  189. package/dist/cli/run-DuN1MX-7.js +705 -0
  190. package/dist/cli/scaffold-5DenHSxF.js +292 -0
  191. package/dist/cli/scaffold-CwQUMFRb.js +2 -0
  192. package/dist/cli/{seed-DQzqT7LP.js → seed-CzBmrGON.js} +14 -18
  193. package/dist/cli/seed-DOmit9Hq.js +2 -0
  194. package/dist/cli/{skills-QQs4q68J.js → skills-CnO8QFS7.js} +7 -6
  195. package/dist/cli/snapshot-Bstk6ulj.js +287 -0
  196. package/dist/cli/source-args-BYfq6imV.js +31 -0
  197. package/dist/cli/spec-CzosTYm3.js +7438 -0
  198. package/dist/cli/spec-T_0Bcyw7.js +2 -0
  199. package/dist/cli/{sql-B8csQPyn.js → sql-BKOOQAX3.js} +240 -218
  200. package/dist/cli/sql-DJrNDxQm.js +3 -0
  201. package/dist/cli/{style-C0NFdJRL.js → style-CB3vxgh0.js} +3 -3
  202. package/dist/cli/typegen-Demi5-VQ.js +486 -0
  203. package/dist/cli/validate-Ca13ktgz.js +7522 -0
  204. package/dist/cli/{version-Bp4fyubI.js → version-B4k0aUxS.js} +1 -1
  205. package/dist/client/index.d.ts +4 -3
  206. package/dist/client/index.js +60 -3
  207. package/dist/client/native/index.d.ts +3 -3
  208. package/dist/client/native/index.js +3 -3
  209. package/dist/{client-CI0Z2zWX.js → client-wxeTQFtB.js} +36 -3
  210. package/dist/{clone-BfgmLU90.js → clone-dN9XOL1K.js} +9 -1
  211. package/dist/{cloud-event-BnmD5fb9.js → cloud-event-CTh9Sr5w.js} +16 -2
  212. package/dist/{cloud-event-C1JCc1bH.d.ts → cloud-event-Dune0KI7.d.ts} +16 -2
  213. package/dist/{compiler-DY_wkj4R.d.ts → compiler-V1qvcST1.d.ts} +2 -2
  214. package/dist/{compose-BIBNgAnq.js → compose-BHej1acw.js} +3 -3
  215. package/dist/{composite-CpHLEo-G.d.ts → composite-CWAJTRBF.d.ts} +6 -6
  216. package/dist/{composite-C6I8ZyaF.js → composite-zTe0TCqj.js} +4 -4
  217. package/dist/config/index.d.ts +3 -4
  218. package/dist/config/index.js +4 -4
  219. package/dist/config-DlKvtt95.js +540 -0
  220. package/dist/{connector-Dv8kK0MO.d.ts → connector-CySQEFcW.d.ts} +1 -1
  221. package/dist/{connectors-CrpknU0P.d.ts → connectors--PGhmiu0.d.ts} +4 -4
  222. package/dist/{context-BCrWe7ow.d.ts → context-DsV2SueA.d.ts} +11 -2
  223. package/dist/context-nPDvQ-Zl.js +41 -0
  224. package/dist/credentials/index.d.ts +5 -5
  225. package/dist/credentials/index.js +9 -17
  226. package/dist/{cron-DVPUg5k3.js → cron-D25Ukpxy.js} +1 -1
  227. package/dist/cron-route-D2AN9SA1.js +24 -0
  228. package/dist/{csv-DCK-PT1n.js → csv-BZnHA1Py.js} +1 -1
  229. package/dist/{define-B-TVjC25.js → define-CFQcvM20.js} +263 -229
  230. package/dist/{define-CJJkkr1-.d.ts → define-DmcfoNXB.d.ts} +136 -111
  231. package/dist/edge/index.d.ts +66 -13
  232. package/dist/edge/index.js +65 -39
  233. package/dist/elysia/index.d.ts +1 -1
  234. package/dist/elysia/index.js +1 -1
  235. package/dist/{embeddings-C9KGQnXt.d.ts → embeddings-B4vhS-dY.d.ts} +1 -1
  236. package/dist/{ended-XjeGQ5XW.d.ts → ended-CcvcRqEd.d.ts} +7 -1
  237. package/dist/{entitlements-DRl6ZJUm.js → entitlements-BYFf0Cdh.js} +2 -2
  238. package/dist/{entitlements-BKSVGtrG.d.ts → entitlements-Ds8qoYZ-.d.ts} +1 -1
  239. package/dist/env/index.d.ts +1 -1
  240. package/dist/env/index.js +9 -2
  241. package/dist/{errors-B11Duf73.js → errors-2M6CKMP4.js} +5 -0
  242. package/dist/{errors-DLjJHPLK.js → errors-rZ7VIqp6.js} +2 -2
  243. package/dist/{escape-like-ImTK0ps_.d.ts → escape-like-DDWoHzh_.d.ts} +1 -1
  244. package/dist/eve/index.d.ts +5 -5
  245. package/dist/eve/index.js +5 -11
  246. package/dist/{eve-gT2Fpjut.d.ts → eve-CoAIcCkq.d.ts} +2 -2
  247. package/dist/events/index.d.ts +4 -4
  248. package/dist/events/index.js +7 -2
  249. package/dist/{events-DWDhx77e.d.ts → events-D1BOCll8.d.ts} +6 -4
  250. package/dist/{executor-Bq28caBo.js → executor-B-fD7DLt.js} +52 -35
  251. package/dist/executor-B_Hfobee.js +162 -0
  252. package/dist/{executor-BVBFM86G.d.ts → executor-CpxLPCiz.d.ts} +1 -1
  253. package/dist/{executor-CaWigTyR.d.ts → executor-DfEtf0cq.d.ts} +43 -27
  254. package/dist/{executor-DvsBbNBS.d.ts → executor-Drzu3dBK.d.ts} +2 -2
  255. package/dist/{executor-DbvExCFC.d.ts → executor-ngjKL_Pe.d.ts} +2 -2
  256. package/dist/expo/index.d.ts +4 -4
  257. package/dist/expo/index.js +6 -6
  258. package/dist/expo-sqlite/index.d.ts +3 -3
  259. package/dist/expo-sqlite/index.js +2 -2
  260. package/dist/extra-CGQ2_q3S.js +10 -0
  261. package/dist/{field-errors-BFOa7WhB.d.ts → field-errors-DIe9XYWL.d.ts} +17 -7
  262. package/dist/{field-errors-VF1yb8yI.js → field-errors-DZVRWRkf.js} +1 -1
  263. package/dist/format-DTXdu8ya.d.ts +70 -0
  264. package/dist/{framework-KIPvRQJU.d.ts → framework-148t1m3C.d.ts} +5 -5
  265. package/dist/{framework-BDCpJI7o.js → framework-3ey3QmrO.js} +2 -2
  266. package/dist/function-contract-BcZenXMO.d.ts +8 -0
  267. package/dist/{gateway-C1ssRHnf.d.ts → gateway-S9vicgeo.d.ts} +4 -4
  268. package/dist/{guards-BnzDvFrz.js → guards-6F2bCtQR.js} +3 -1
  269. package/dist/h3/index.d.ts +1 -1
  270. package/dist/h3/index.js +1 -1
  271. package/dist/h3/v1/index.d.ts +1 -1
  272. package/dist/h3/v1/index.js +1 -1
  273. package/dist/{message-CaKlqdsX.js → history-GH1HJWQV.js} +65 -13
  274. package/dist/hmac-DCud0myt.js +22 -0
  275. package/dist/hono/index.d.ts +19 -14
  276. package/dist/hono/index.js +21 -16
  277. package/dist/{hooks-1BTCJsiw.js → hooks-Bhza9Hnr.js} +68 -100
  278. package/dist/http-sbmBe5d2.js +25 -0
  279. package/dist/{inbox-i7E1ppo6.d.ts → inbox-Cd1KCEBL.d.ts} +3 -3
  280. package/dist/index-B72Rvv_j.d.ts +89 -0
  281. package/dist/{index-DunNRdnT.d.ts → index-BCHR4Ucl.d.ts} +4 -4
  282. package/dist/{index-CLg87OBW.d.ts → index-BUK7jUzR.d.ts} +6 -0
  283. package/dist/{config-D44Y7PAv.d.ts → index-Ba1SI-uO.d.ts} +625 -278
  284. package/dist/{index-D48jVS-N.d.ts → index-BfxOaOYs.d.ts} +4 -5
  285. package/dist/{index-ClmjK_o-.d.ts → index-CicIyqOe.d.ts} +4 -4
  286. package/dist/{index-ACiNPN4Z.d.ts → index-D69h4QqD.d.ts} +1 -1
  287. package/dist/index-DG2SUXDQ.d.ts +58 -0
  288. package/dist/{index-Bepi-Hgg.d.ts → index-DoNVLHOU.d.ts} +3 -3
  289. package/dist/{index-CdZKQF98.d.ts → index-R274XFlg.d.ts} +1 -1
  290. package/dist/{index-CewnYSpv.d.ts → index-_4R4b01v.d.ts} +8 -18
  291. package/dist/index.d.ts +89 -14
  292. package/dist/index.js +12 -11
  293. package/dist/{json-schema-CvER4kgT.js → json-schema-CT4tvrkA.js} +148 -102
  294. package/dist/{kit-Fm-Fv7q5.js → kit-BhHr9T9v.js} +36 -10
  295. package/dist/{kit-CkNzZUqv.d.ts → kit-W99LCPBS.d.ts} +13 -7
  296. package/dist/{knowledge-BXBbT0Tr.d.ts → knowledge-CAReFpRA.d.ts} +5 -5
  297. package/dist/{knowledge-CDmiMLew.js → knowledge-DnHtb64A.js} +4 -3
  298. package/dist/list/index.d.ts +1 -2
  299. package/dist/{list-query-BRt-zDF7.d.ts → list-query-D3JQeEL7.d.ts} +4 -4
  300. package/dist/mcp/index.d.ts +49 -19
  301. package/dist/mcp/index.js +158 -94
  302. package/dist/mcp/sdk/index.d.ts +38 -6
  303. package/dist/mcp/sdk/index.js +88 -6
  304. package/dist/{message-CfDoR0Y6.d.ts → message-B0fNJgq8.d.ts} +1 -2
  305. package/dist/{messages-B9-5887d.js → messages-CJoHHCWT.js} +4 -205
  306. package/dist/{mfa-Daak8ukG.d.ts → mfa-SZc9YYyb.d.ts} +1 -1
  307. package/dist/model-OgBxvk3N.d.ts +300 -0
  308. package/dist/model-messages-Cxw_Up4f.js +206 -0
  309. package/dist/model-messages-D4GZllOD.d.ts +34 -0
  310. package/dist/modules-DksjZyMW.js +77 -0
  311. package/dist/nestjs/index.d.ts +2 -2
  312. package/dist/nestjs/index.js +1 -1
  313. package/dist/next/index.d.ts +105 -55
  314. package/dist/next/index.js +204 -170
  315. package/dist/node/index.d.ts +2 -2
  316. package/dist/node/index.js +1 -1
  317. package/dist/{onboarding-BZGHYJks.d.ts → onboarding-LZvlK1P4.d.ts} +3 -3
  318. package/dist/openapi/index.d.ts +4 -2
  319. package/dist/openapi/index.js +21 -343
  320. package/dist/optional-peer-D1pi-skw.js +24 -0
  321. package/dist/orpc/index.d.ts +8 -8
  322. package/dist/orpc/index.js +21 -20
  323. package/dist/otel/index.d.ts +3 -3
  324. package/dist/otel/index.js +7 -7
  325. package/dist/{outbox-Cq7pPYvl.d.ts → outbox-DZfAvfzC.d.ts} +6 -6
  326. package/dist/overlay/index.d.ts +233 -0
  327. package/dist/overlay/index.js +554 -0
  328. package/dist/{plugin-FGY8UhYm.d.ts → plugin-CPK2HsbY.d.ts} +42 -3
  329. package/dist/plugins/actor/index.d.ts +1 -1
  330. package/dist/plugins/actor/index.js +1 -1
  331. package/dist/plugins/rules/index.d.ts +2 -2
  332. package/dist/plugins/rules/index.js +1 -1
  333. package/dist/plugins/soft-delete/index.d.ts +3 -3
  334. package/dist/plugins/soft-delete/index.js +9 -2
  335. package/dist/plugins/tenant/index.d.ts +7 -2
  336. package/dist/plugins/tenant/index.js +16 -2
  337. package/dist/plugins/timestamps/index.d.ts +1 -1
  338. package/dist/plugins/timestamps/index.js +8 -1
  339. package/dist/plugins/validation/index.d.ts +2 -2
  340. package/dist/plugins/validation/index.js +4 -4
  341. package/dist/{pool-CAu2nLrL.d.ts → pool-gkhbGp2E.d.ts} +2 -2
  342. package/dist/postgres/index.d.ts +4 -4
  343. package/dist/postgres/index.js +2 -1
  344. package/dist/{postgrest-BLVdEnfe.d.ts → postgrest-BUqLag2Q.d.ts} +1 -1
  345. package/dist/powersync/index.d.ts +5 -5
  346. package/dist/powersync/index.js +4 -4
  347. package/dist/powersync/react/index.d.ts +3 -3
  348. package/dist/powersync/react/index.js +1 -1
  349. package/dist/{problem-BreOl8b8.js → problem-CJvFeGu7.js} +13 -2
  350. package/dist/{problem-DD8LZFjc.d.ts → problem-TvGdxO1t.d.ts} +7 -1
  351. package/dist/{provider-Di3sRutW.js → provider-DxRTex4x.js} +1 -1
  352. package/dist/{provider-D-UEMvSD.d.ts → provider-ib9wzUDz.d.ts} +2 -2
  353. package/dist/query/index.d.ts +2 -2
  354. package/dist/query/index.js +1 -1
  355. package/dist/{query-BQ-NaZon.js → query-Ctz-qKRx.js} +1 -1
  356. package/dist/rate-limit-Bw7HgmFj.js +260 -0
  357. package/dist/react/index.d.ts +9 -9
  358. package/dist/react/index.js +4 -4
  359. package/dist/react/native/index.d.ts +1 -1
  360. package/dist/react/native/index.js +2 -2
  361. package/dist/react/server.d.ts +10 -10
  362. package/dist/react/server.js +3 -3
  363. package/dist/react/session.d.ts +2 -2
  364. package/dist/{react-F80mF4-t.js → react-Bmpo59D7.js} +4 -4
  365. package/dist/react-router/index.d.ts +6 -6
  366. package/dist/react-router/index.js +9 -11
  367. package/dist/{read-set-DuKWC9Mj.js → read-set-DAeWhqPf.js} +2 -2
  368. package/dist/realtime/index.d.ts +3 -3
  369. package/dist/realtime/index.js +30 -36
  370. package/dist/{refusal-DhSU2Vvr.d.ts → refusal-CFI8-5nf.d.ts} +4 -1
  371. package/dist/{refusal-CeJWxmkH.js → refusal-K78A1Vmq.js} +5 -5
  372. package/dist/{resolve-tJZY3FEa.js → resolve-Bvgf3ut_.js} +131 -42
  373. package/dist/{resolve-ChTYeTEl.d.ts → resolve-MxXVWyhd.d.ts} +12 -8
  374. package/dist/resource--vTrBe6I.d.ts +103 -0
  375. package/dist/resource-BqNqlYg9.js +91 -0
  376. package/dist/resource-DA811u_4.js +463 -0
  377. package/dist/resource-execute-rbKvuCsY.d.ts +12 -0
  378. package/dist/resource-schemas-BJ518zFH.js +79 -0
  379. package/dist/resource-types-CqB6GWGT.d.ts +141 -0
  380. package/dist/resources-BVYPnuLo.js +56 -0
  381. package/dist/resources-DZSk8tXJ.d.ts +7 -0
  382. package/dist/{respond-DprrgyXX.d.ts → respond-Cw-zanCm.d.ts} +3 -3
  383. package/dist/{respond-BUgsXNgk.js → respond-volM3ByS.js} +4 -4
  384. package/dist/{result-D7y2fT87.d.ts → result-BchM1XZn.d.ts} +7 -1
  385. package/dist/{result-DzUbqgdW.js → result-DEqHCMKP.js} +1 -1
  386. package/dist/server/index.d.ts +81 -19
  387. package/dist/server/index.js +16 -14
  388. package/dist/{server-ZSJ9rCcV.d.ts → server-types-CrAmZ8jv.d.ts} +110 -36
  389. package/dist/{shared-CxWmcyqB.js → shared-DHjhfRdV.js} +2 -15
  390. package/dist/shared-DTneRoxi.js +14 -0
  391. package/dist/{sign-in-Cb1mwv6X.js → sign-in-D_yoP0PF.js} +1 -1
  392. package/dist/signatures-BRS_p3WD.d.ts +34 -0
  393. package/dist/signatures-DsWv_bYR.js +103 -0
  394. package/dist/{signers-4y62_VIi.d.ts → signers-cpdmZYrv.d.ts} +1 -1
  395. package/dist/solid/index.d.ts +9 -18
  396. package/dist/solid/index.js +2 -2
  397. package/dist/solid-start/index.d.ts +6 -6
  398. package/dist/solid-start/index.js +7 -7
  399. package/dist/spec/index.d.ts +134 -0
  400. package/dist/spec/index.js +353 -0
  401. package/dist/{spec-pins-C89s6DyW.d.ts → spec-pins-CwzDY25w.d.ts} +18 -1
  402. package/dist/{spec-pins--j6mTok4.js → spec-pins-DsLfUH7l.js} +14 -1
  403. package/dist/sql/index.d.ts +145 -119
  404. package/dist/sql/index.js +19921 -19798
  405. package/dist/{executor-De1Of3m3.js → sql-CwuqaQ4Y.js} +34 -169
  406. package/dist/ssr/index.d.ts +4 -4
  407. package/dist/ssr/index.js +3 -2
  408. package/dist/{standard-BK0cqJ7y.js → standard-DkzZUneg.js} +2 -2
  409. package/dist/{standard-CYsm7xpT.d.ts → standard-lmkbOtPB.d.ts} +1 -1
  410. package/dist/{stats-D_AD9GGu.js → stats-DhU78Ctf.js} +8 -4
  411. package/dist/storage/index.d.ts +4 -6
  412. package/dist/storage/index.js +16 -17
  413. package/dist/{bucket-Cl46E3jS.d.ts → storage-api-CB7Zl1Ci.d.ts} +243 -8
  414. package/dist/{store-CGjgWu5n.d.ts → store-DsIYEBnv.d.ts} +1 -1
  415. package/dist/streams/index.d.ts +4 -4
  416. package/dist/streams/index.js +5 -4
  417. package/dist/streams/redis/index.d.ts +1 -1
  418. package/dist/streams/redis/index.js +5 -11
  419. package/dist/{stripe-BMj5LtsT.js → stripe-v-Y2lmop.js} +2 -8
  420. package/dist/supabase-mcp-C6tMoEjn.d.ts +43 -0
  421. package/dist/supabase-mcp-Cpn5A4i-.js +28 -0
  422. package/dist/{support-DWwzVf-O.js → support-D1pFFouF.js} +71 -35
  423. package/dist/{support-view-CVOJJLpc.d.ts → support-view-scqMgtOo.d.ts} +1 -1
  424. package/dist/svelte/index.d.ts +8 -17
  425. package/dist/svelte/index.js +2 -2
  426. package/dist/sveltekit/index.d.ts +7 -7
  427. package/dist/sveltekit/index.js +10 -12
  428. package/dist/table-schema-htM_SbCW.js +286 -0
  429. package/dist/{tags-Cx-LnIQP.d.ts → tags-BO9LjtWG.d.ts} +1 -1
  430. package/dist/tanstack-db/index.d.ts +2 -2
  431. package/dist/tanstack-db/supabase/index.d.ts +52 -0
  432. package/dist/tanstack-db/supabase/index.js +97 -0
  433. package/dist/tanstack-start/index.d.ts +6 -6
  434. package/dist/tanstack-start/index.js +8 -12
  435. package/dist/{tee-CoEppCER.js → tee-Cb98Vn3b.js} +1 -1
  436. package/dist/{template--jDkl3UP.js → template-lPVh-EwW.js} +11 -2
  437. package/dist/{temporal-required-BVvW7SYJ.js → temporal-required-BtynQtM-.js} +1 -1
  438. package/dist/{tenant-BxNFk9bx.d.ts → tenant-CM368LXb.d.ts} +2 -2
  439. package/dist/testing/index.d.ts +249 -118
  440. package/dist/testing/index.js +1418 -870
  441. package/dist/ttl-cache-XzZ-Q2eX.js +29 -0
  442. package/dist/types-BRTSpOIh.js +5 -0
  443. package/dist/{types-C05bxW-W.d.ts → types-Bb_4-vdW.d.ts} +4 -4
  444. package/dist/{types-AYOvcyep.d.ts → types-CD6yCDx3.d.ts} +5 -5
  445. package/dist/{types-6rocye-y.d.ts → types-CbOUc5IH.d.ts} +4 -4
  446. package/dist/{types-6BdhkmZe.d.ts → types-CoE5Zwy4.d.ts} +8 -0
  447. package/dist/{types-DGs5L0VN.d.ts → types-DSJ3-m9X.d.ts} +4 -4
  448. package/dist/{queue-CLJurhdy.d.ts → types-D__3EN0q.d.ts} +17 -19
  449. package/dist/{usage-CrvrL2vw.d.ts → usage-D0NNUFfr.d.ts} +3 -3
  450. package/dist/{vault-wlbBhqm7.d.ts → vault-BpmApxxW.d.ts} +3 -3
  451. package/dist/vercel-connect/index.d.ts +1 -1
  452. package/dist/vercel-connect/index.js +5 -11
  453. package/dist/{verify-DPuWngD4.d.ts → verify-C91Wyp40.d.ts} +5 -35
  454. package/dist/verify-CJbYfADA.js +124 -0
  455. package/dist/{version--AolB5ej.js → version-Cq8gfDbd.js} +1 -1
  456. package/dist/{view-BeFcRV6G.js → view-D5ryq3gz.js} +1 -1
  457. package/dist/{view-CF7ihnkg.d.ts → view-TpXEUcVN.d.ts} +3 -3
  458. package/dist/vue/index.d.ts +9 -18
  459. package/dist/vue/index.js +2 -2
  460. package/dist/{watch-Xuxrvxq-.js → watch-BcvtAHOd.js} +2 -2
  461. package/dist/{watch-DI34G86j.d.ts → watch-COzRWvVN.d.ts} +23 -9
  462. package/dist/{wire-DtZQ4sdE.js → wire-Df3EWkG8.js} +2 -2
  463. package/dist/{workflow-builder-DJ1oHn8g.js → workflow-builder-CHqHpAVt.js} +6 -5
  464. package/dist/workflow-sdk/builder/index.d.ts +3 -3
  465. package/dist/workflow-sdk/index.d.ts +1 -1
  466. package/dist/workflow-sdk/world/index.d.ts +23 -17
  467. package/dist/workflow-sdk/world/index.js +59 -76
  468. package/dist/{workflow-sdk-B3yLD6Br.d.ts → workflow-sdk-DTZyrvNo.d.ts} +3 -3
  469. package/dist/{workflow-sdk-world-D-prir6O.js → workflow-sdk-world-CMV1ahFW.js} +528 -526
  470. package/dist/{workflows-B0j9WKPu.d.ts → workflows-CcpCBfIe.d.ts} +3 -3
  471. package/dist/{workflows-wu1WWBn7.js → workflows-IvxzG2cl.js} +5 -4
  472. package/package.json +54 -3
  473. package/schemas/config-v1.json +243 -0
  474. package/schemas/doctor-report-v1.json +4 -1
  475. package/schemas/spec-manifest-v1.json +95 -0
  476. package/skills/better-supabase/SKILL.md +8 -4
  477. package/skills/better-supabase/references/troubleshooting.md +20 -20
  478. package/skills/better-supabase-api/references/expo.md +6 -3
  479. package/skills/better-supabase-api/references/powersync.md +2 -1
  480. package/skills/better-supabase-auth/SKILL.md +8 -4
  481. package/dist/cli/config-B9HkL8nF.js +0 -2
  482. package/dist/cli/gen-AIf4MREI.js +0 -3100
  483. package/dist/cli/gen-DSrahEdX.js +0 -2
  484. package/dist/cli/prompts-BTYQGunc.js +0 -2
  485. package/dist/cli/run-BO052mki.js +0 -361
  486. package/dist/config-Dn7F5k9A.js +0 -202
  487. package/dist/history-BZih6SFP.js +0 -64
  488. package/dist/index-BkWT_uBO.d.ts +0 -51
  489. package/dist/index-Bxih3l0u.d.ts +0 -81
  490. package/dist/index-CaxrMD1A.d.ts +0 -1
  491. package/dist/index-DQh4VCc9.d.ts +0 -98
  492. package/dist/keys-4MnkWTTh.js +0 -35
  493. package/dist/messages-DYP0sUTe.d.ts +0 -59
  494. package/dist/modules-dxrVK3ID.js +0 -228
  495. package/dist/path-Cv__-OTj.d.ts +0 -17
  496. package/dist/resource-BsvzCMlX.js +0 -212
  497. package/dist/resource-IPS5xi9q.d.ts +0 -74
  498. package/dist/template-CwO38Do8.d.ts +0 -6
  499. package/dist/verify-DL41hbvY.js +0 -232
  500. package/dist/cli/{read-sets-CETOSFx4.js → read-sets-DjJrm8Wj.js} +1 -1
@@ -0,0 +1,1296 @@
1
+ import { r as isPlainObject } from "./clone-dN9XOL1K.js";
2
+ import { n as PROBLEM_TYPE_BASE, t as PROBLEM_CONTENT_TYPE } from "./problem-CJvFeGu7.js";
3
+ import { t as buildJsonSchema } from "./json-schema-CT4tvrkA.js";
4
+ import { r as dataschemaOf } from "./cloud-event-CTh9Sr5w.js";
5
+ import { n as planResource } from "./resource-BqNqlYg9.js";
6
+ import { n as pageQuery, r as pageSchema } from "./resource-schemas-BJ518zFH.js";
7
+ import { ROW_EVENT_TYPES } from "./events/index.js";
8
+ //#region src/spec/merge.ts
9
+ /** Escapes a key for a JSON Pointer (RFC 6901). */
10
+ function pointerToken(key) {
11
+ return key.replaceAll("~", "~0").replaceAll("/", "~1");
12
+ }
13
+ /**
14
+ * Deep merge: objects merge key by key, anything else (arrays included)
15
+ * is replaced by the patch. `onConflict` hears each replaced leaf whose value
16
+ * differs, with its JSON Pointer. Neither input is changed.
17
+ */
18
+ function mergeJson(base, patch, onConflict, pointer = "") {
19
+ if (!isPlainObject(base) || !isPlainObject(patch)) {
20
+ if (onConflict && base !== void 0 && JSON.stringify(base) !== JSON.stringify(patch)) onConflict(pointer);
21
+ return patch;
22
+ }
23
+ const out = { ...base };
24
+ for (const [key, value] of Object.entries(patch)) out[key] = Object.hasOwn(base, key) ? mergeJson(base[key], value, onConflict, `${pointer}/${pointerToken(key)}`) : value;
25
+ return out;
26
+ }
27
+ //#endregion
28
+ //#region src/spec/schemas.ts
29
+ /** `customer_tags` to `CustomerTags`. */
30
+ function pascal(value) {
31
+ return value.replaceAll(/(^|[_\-.\s])(\w)/g, (_, _sep, char) => char.toUpperCase());
32
+ }
33
+ const schemaRef = (name) => ({ $ref: `#/components/schemas/${name}` });
34
+ const tableDefs = /* @__PURE__ */ new WeakMap();
35
+ /**
36
+ * The 2020-12 `$defs` for every table (`customersRow`, `customersInsert`),
37
+ * built once per metadata object and JSON column config.
38
+ */
39
+ function tableSchemas(meta, json = {}) {
40
+ let byJson = tableDefs.get(meta);
41
+ if (!byJson) {
42
+ byJson = /* @__PURE__ */ new Map();
43
+ tableDefs.set(meta, byJson);
44
+ }
45
+ const key = JSON.stringify(json);
46
+ let defs = byJson.get(key);
47
+ if (!defs) {
48
+ defs = buildJsonSchema({
49
+ meta,
50
+ config: { json }
51
+ })["$defs"];
52
+ byJson.set(key, defs);
53
+ }
54
+ return defs;
55
+ }
56
+ const converted = /* @__PURE__ */ new WeakMap();
57
+ function nameOf(schema) {
58
+ const id = schema["$id"] ?? schema["id"];
59
+ if (typeof id !== "string" || id === "") return void 0;
60
+ return (id.split(/[/#]/u).findLast((part) => part !== "") ?? id).replace(/\.(?:schema\.)?json$/u, "");
61
+ }
62
+ /**
63
+ * Converts a Standard Schema through Standard JSON Schema (2020-12), or
64
+ * `undefined` when the library does not implement it. The schema's `$id`,
65
+ * `id` and `$schema` are lifted out: the id becomes the component name.
66
+ */
67
+ function convertStandard(schema, direction) {
68
+ let cache = converted.get(schema);
69
+ if (!cache) {
70
+ cache = /* @__PURE__ */ new Map();
71
+ converted.set(schema, cache);
72
+ }
73
+ const hit = cache.get(direction);
74
+ if (hit !== void 0) return hit ?? void 0;
75
+ const convert = schema["~standard"].jsonSchema?.[direction];
76
+ if (typeof convert !== "function") {
77
+ cache.set(direction, null);
78
+ return;
79
+ }
80
+ const raw = convert({ target: "draft-2020-12" });
81
+ const name = nameOf(raw);
82
+ const { $schema: _schema, $id: _id, id: _plainId, ...rest } = raw;
83
+ const result = {
84
+ schema: rest,
85
+ ...name ? { name } : {}
86
+ };
87
+ cache.set(direction, result);
88
+ return result;
89
+ }
90
+ //#endregion
91
+ //#region src/spec/events.ts
92
+ const OPEN = { type: "object" };
93
+ const DEFAULT_INTENTS = [
94
+ "insert",
95
+ "update",
96
+ "delete"
97
+ ];
98
+ /** An id safe for AsyncAPI channel, operation and component keys. */
99
+ function safeKey(value) {
100
+ return value.replaceAll(/[^A-Za-z0-9_-]/g, "_");
101
+ }
102
+ const keyPart = (value) => safeKey(pascal(value));
103
+ /** The CloudEvents attributes in HTTP binary mode (`ce-*` headers). */
104
+ const CLOUD_EVENT_TRAIT = {
105
+ description: "CloudEvents 1.0 attributes in HTTP binary mode.",
106
+ contentType: "application/json",
107
+ headers: {
108
+ type: "object",
109
+ properties: {
110
+ "ce-specversion": {
111
+ type: "string",
112
+ const: "1.0"
113
+ },
114
+ "ce-id": { type: "string" },
115
+ "ce-source": {
116
+ type: "string",
117
+ format: "uri-reference"
118
+ },
119
+ "ce-type": { type: "string" },
120
+ "ce-subject": { type: "string" },
121
+ "ce-time": {
122
+ type: "string",
123
+ format: "date-time"
124
+ },
125
+ "ce-dataschema": {
126
+ type: "string",
127
+ format: "uri"
128
+ },
129
+ "ce-partitionkey": { type: "string" }
130
+ }
131
+ }
132
+ };
133
+ function cloudEventHeaders(type, dataschema) {
134
+ return {
135
+ type: "object",
136
+ required: [
137
+ "ce-specversion",
138
+ "ce-id",
139
+ "ce-source",
140
+ "ce-type"
141
+ ],
142
+ properties: {
143
+ "ce-type": {
144
+ type: "string",
145
+ const: type
146
+ },
147
+ ...dataschema ? { "ce-dataschema": {
148
+ type: "string",
149
+ const: dataschema
150
+ } } : {}
151
+ }
152
+ };
153
+ }
154
+ function convert(schema, where, ctx) {
155
+ if (schema === true) return OPEN;
156
+ const converted = convertStandard(schema, "output");
157
+ if (converted) return converted.schema;
158
+ ctx.report({
159
+ code: "asyncapi-schema-opaque",
160
+ severity: "warning",
161
+ message: `${where}: the schema does not implement Standard JSON Schema; the payload is left open`
162
+ });
163
+ return OPEN;
164
+ }
165
+ function tableChannels(ctx, selection, channels, messages) {
166
+ if (selection === false) return;
167
+ const realtime = ctx.meta.realtime ?? {};
168
+ const keys = selection === true ? Object.keys(realtime) : selection;
169
+ for (const key of keys) {
170
+ const table = ctx.meta.tables[key];
171
+ const config = realtime[key];
172
+ if (!table || !config) {
173
+ ctx.report({
174
+ code: "asyncapi-table-unknown",
175
+ severity: "error",
176
+ message: `events.tables names "${key}", which is not in realtime.tables`
177
+ });
178
+ continue;
179
+ }
180
+ const id = `table${keyPart(key)}`;
181
+ const base = `bs:t:${table.schema}.${table.name}`;
182
+ const address = config.user ? `${base}:u:{userId}` : config.tenant ? `${base}:{tenant}` : base;
183
+ const messageId = `${id}Change`;
184
+ messages[messageId] = {
185
+ id: messageId,
186
+ name: "change",
187
+ title: `${key} changed`,
188
+ summary: `A row of ${table.schema}.${table.name} was inserted, updated or deleted. Clients refetch through row-level security.`,
189
+ contentType: "application/json",
190
+ payload: {
191
+ type: "object",
192
+ required: [
193
+ "schema",
194
+ "table",
195
+ "operation"
196
+ ],
197
+ properties: {
198
+ schema: {
199
+ type: "string",
200
+ const: table.schema
201
+ },
202
+ table: {
203
+ type: "string",
204
+ const: table.name
205
+ },
206
+ operation: {
207
+ type: "string",
208
+ enum: [
209
+ "INSERT",
210
+ "UPDATE",
211
+ "DELETE"
212
+ ]
213
+ }
214
+ }
215
+ },
216
+ extensions: { [`${ctx.prefix}event`]: "change" }
217
+ };
218
+ channels.push({
219
+ id,
220
+ address,
221
+ title: `${key} changes`,
222
+ protocol: "ws",
223
+ ...config.user ? { parameters: { userId: { description: "The signed-in user's id." } } } : config.tenant ? { parameters: { tenant: { description: `The row's \`${config.tenant}\` value.` } } } : {},
224
+ messages: [messageId],
225
+ operations: [{
226
+ id: `receive${keyPart(key)}Changes`,
227
+ action: "receive",
228
+ summary: `Change signals for ${key}`
229
+ }],
230
+ extensions: { [`${ctx.prefix}table`]: `${table.schema}.${table.name}` }
231
+ });
232
+ }
233
+ }
234
+ function topicChannels(ctx, topics, channels, messages) {
235
+ for (const [key, topic] of Object.entries(topics)) {
236
+ const id = `topic${keyPart(key)}`;
237
+ const ids = [];
238
+ const events = Object.entries(topic.events ?? {});
239
+ if (events.length === 0) {
240
+ ctx.report({
241
+ code: "asyncapi-topic-open",
242
+ severity: "info",
243
+ message: `Topic "${key}" lists no events; it is documented with one open message`
244
+ });
245
+ events.push(["*", true]);
246
+ }
247
+ for (const [event, schema] of events) {
248
+ const messageId = `${id}${event === "*" ? "Any" : keyPart(event)}`;
249
+ ids.push(messageId);
250
+ messages[messageId] = {
251
+ id: messageId,
252
+ ...event === "*" ? {} : { name: event },
253
+ title: event === "*" ? `${key} broadcast` : `${key} ${event}`,
254
+ contentType: "application/json",
255
+ payload: convert(schema, `topics.${key}.events.${event}`, ctx),
256
+ extensions: { [`${ctx.prefix}event`]: event }
257
+ };
258
+ }
259
+ if (topic.presence) {
260
+ const messageId = `${id}Presence`;
261
+ ids.push(messageId);
262
+ messages[messageId] = {
263
+ id: messageId,
264
+ name: "presence",
265
+ title: `${key} presence`,
266
+ contentType: "application/json",
267
+ payload: OPEN,
268
+ extensions: { [`${ctx.prefix}event`]: "presence" }
269
+ };
270
+ }
271
+ const permission = topic.permission === void 0 ? void 0 : ctx.keyOf(topic.permission, `topics.${key}`);
272
+ const extra = permission === void 0 ? {} : { permission };
273
+ const operations = [{
274
+ id: `receive${keyPart(key)}`,
275
+ action: "receive",
276
+ ...topic.summary ? { summary: topic.summary } : {},
277
+ ...extra
278
+ }];
279
+ if (topic.send || topic.presence) operations.push({
280
+ id: `send${keyPart(key)}`,
281
+ action: "send",
282
+ ...extra
283
+ });
284
+ const params = [...topic.template.matchAll(/\{([^}]+)\}/g)].map((match) => match[1] ?? "");
285
+ channels.push({
286
+ id,
287
+ address: topic.template,
288
+ ...topic.summary ? { summary: topic.summary } : {},
289
+ ...topic.description ? { description: topic.description } : {},
290
+ title: topic.name ?? key,
291
+ ...params.length > 0 ? { parameters: Object.fromEntries(params.map((name) => [name, {}])) } : {},
292
+ protocol: "ws",
293
+ messages: ids,
294
+ operations,
295
+ extensions: { [`${ctx.prefix}private`]: topic.private ?? true }
296
+ });
297
+ }
298
+ }
299
+ function withActor(schema) {
300
+ const properties = schema["properties"];
301
+ if (!isPlainObject(properties) || "actorId" in properties) return schema;
302
+ return {
303
+ ...schema,
304
+ properties: {
305
+ ...properties,
306
+ actorId: {
307
+ type: "string",
308
+ description: "Who caused the event."
309
+ }
310
+ }
311
+ };
312
+ }
313
+ function cloudEventChannel(ctx, input, channels, messages) {
314
+ const ids = [];
315
+ const add = (messageId, type, title, payload, table) => {
316
+ const { dataschema } = dataschemaOf(input, {
317
+ type,
318
+ ...table ? { table } : {}
319
+ });
320
+ ids.push(messageId);
321
+ messages[messageId] = {
322
+ id: messageId,
323
+ name: type,
324
+ title,
325
+ contentType: "application/json",
326
+ headers: cloudEventHeaders(type, dataschema),
327
+ payload,
328
+ traits: ["cloudEvent"],
329
+ extensions: {
330
+ [`${ctx.prefix}cloudevent-type`]: type,
331
+ ...dataschema ? { [`${ctx.prefix}dataschema`]: dataschema } : {}
332
+ }
333
+ };
334
+ };
335
+ const rows = input.rows ?? false;
336
+ const rowTables = rows === true ? Object.keys(ctx.meta.tables) : rows === false ? [] : rows;
337
+ const defs = rowTables.length > 0 ? tableSchemas(ctx.meta, ctx.json) : {};
338
+ for (const table of rowTables) {
339
+ if (!ctx.meta.tables[table]) {
340
+ ctx.report({
341
+ code: "asyncapi-table-unknown",
342
+ severity: "error",
343
+ message: `events.cloudEvents.rows names an unknown table "${table}"`
344
+ });
345
+ continue;
346
+ }
347
+ const component = ctx.served.get(table)?.components.Row;
348
+ const row = component ? schemaRef(component) : defs[`${table}Row`] ?? OPEN;
349
+ for (const intent of input.intents ?? DEFAULT_INTENTS) {
350
+ const last = ROW_EVENT_TYPES[intent].split(".").at(-1) ?? intent;
351
+ const type = input.typePrefix ? `${input.typePrefix}.row.${last}` : ROW_EVENT_TYPES[intent];
352
+ add(`row${keyPart(table)}${keyPart(last)}`, type, `${table} ${last}`, {
353
+ type: "object",
354
+ required: ["table", "row"],
355
+ properties: {
356
+ table: {
357
+ type: "string",
358
+ const: table
359
+ },
360
+ row,
361
+ actorId: { type: "string" }
362
+ }
363
+ }, table);
364
+ }
365
+ }
366
+ for (const [event, schema] of Object.entries(input.blocks ?? {})) {
367
+ const type = `${input.typePrefix ?? "dev.better-supabase"}.${event}`;
368
+ add(`block${keyPart(event)}`, type, event, withActor(convert(schema, `events.cloudEvents.blocks.${event}`, ctx)));
369
+ }
370
+ if (ids.length === 0) return false;
371
+ channels.push({
372
+ id: "cloudEvents",
373
+ address: input.address ?? "events",
374
+ title: "CloudEvents",
375
+ description: `CloudEvents from \`${input.source}\`, sent to the event sink.`,
376
+ protocol: "http",
377
+ messages: ids,
378
+ operations: [{
379
+ id: "sendCloudEvents",
380
+ action: "send"
381
+ }]
382
+ });
383
+ return true;
384
+ }
385
+ /**
386
+ * The built channels and messages first, then the app's own (which win on
387
+ * an id), and the workflows with every `WorkflowSource` run on `operations`.
388
+ */
389
+ function eventParts(options, ctx, operations) {
390
+ const built = buildEvents(options.events, ctx);
391
+ return {
392
+ channels: [...built.channels, ...options.channels ?? []],
393
+ messages: {
394
+ ...built.messages,
395
+ ...options.messages
396
+ },
397
+ ...Object.keys(built.messageTraits).length > 0 ? { messageTraits: built.messageTraits } : {},
398
+ workflows: (options.workflows ?? []).flatMap((workflow) => typeof workflow === "function" ? workflow(operations) : [workflow])
399
+ };
400
+ }
401
+ /** Channels and messages from the realtime tables, topics and CloudEvents. */
402
+ function buildEvents(events, ctx) {
403
+ const channels = [];
404
+ const messages = {};
405
+ const messageTraits = {};
406
+ if (!events) return {
407
+ channels,
408
+ messages,
409
+ messageTraits
410
+ };
411
+ tableChannels(ctx, events.tables ?? true, channels, messages);
412
+ topicChannels(ctx, events.topics ?? {}, channels, messages);
413
+ if (events.cloudEvents && cloudEventChannel(ctx, events.cloudEvents, channels, messages)) messageTraits["cloudEvent"] = CLOUD_EVENT_TRAIT;
414
+ return {
415
+ channels,
416
+ messages,
417
+ messageTraits
418
+ };
419
+ }
420
+ //#endregion
421
+ //#region src/spec/presets.ts
422
+ /** JSON Schema for RFC 9457 Problem Details as better-supabase sends them. */
423
+ const PROBLEM_SCHEMA = {
424
+ type: "object",
425
+ required: [
426
+ "type",
427
+ "title",
428
+ "status"
429
+ ],
430
+ properties: {
431
+ type: {
432
+ type: "string",
433
+ format: "uri-reference",
434
+ examples: [`${PROBLEM_TYPE_BASE}not-found`]
435
+ },
436
+ title: { type: "string" },
437
+ status: {
438
+ type: "integer",
439
+ minimum: 100,
440
+ maximum: 599
441
+ },
442
+ detail: { type: "string" },
443
+ instance: { type: "string" },
444
+ kind: { type: "string" },
445
+ code: { type: "string" },
446
+ hint: { type: "string" },
447
+ constraint: { type: "string" },
448
+ column: { type: "string" },
449
+ columns: {
450
+ type: "array",
451
+ items: { type: "string" }
452
+ },
453
+ required: {
454
+ type: "string",
455
+ enum: ["aal1", "aal2"]
456
+ },
457
+ scopes: {
458
+ type: "array",
459
+ items: { type: "string" }
460
+ },
461
+ permission: { type: "string" },
462
+ approval: {
463
+ type: "object",
464
+ required: ["id"],
465
+ properties: { id: { type: "string" } }
466
+ },
467
+ issues: {
468
+ type: "array",
469
+ items: {
470
+ type: "object",
471
+ required: ["message"],
472
+ properties: {
473
+ message: { type: "string" },
474
+ path: {
475
+ type: "array",
476
+ items: { type: ["string", "integer"] }
477
+ }
478
+ }
479
+ }
480
+ }
481
+ }
482
+ };
483
+ /** The default error responses: today's Problem Details answers, 400 to 422. */
484
+ const DEFAULT_ERRORS = [
485
+ {
486
+ name: "BadRequest",
487
+ status: 400,
488
+ description: "The request is invalid."
489
+ },
490
+ {
491
+ name: "Unauthorized",
492
+ status: 401,
493
+ description: "Missing or invalid credentials."
494
+ },
495
+ {
496
+ name: "Forbidden",
497
+ status: 403,
498
+ description: "Row-level security or a plugin denied the request."
499
+ },
500
+ {
501
+ name: "NotFound",
502
+ status: 404,
503
+ description: "No row matches."
504
+ },
505
+ {
506
+ name: "Conflict",
507
+ status: 409,
508
+ description: "A unique or foreign key constraint failed."
509
+ },
510
+ {
511
+ name: "Unprocessable",
512
+ status: 422,
513
+ description: "Validation or a check constraint failed."
514
+ }
515
+ ];
516
+ /** Name of the shared 403 response of operations that declare a permission. */
517
+ const PERMISSION_DENIED = "PermissionDenied";
518
+ const problem = (code, detail, extra = {}) => ({ value: {
519
+ type: `${PROBLEM_TYPE_BASE}forbidden`,
520
+ title: "Forbidden",
521
+ status: 403,
522
+ kind: "forbidden",
523
+ code,
524
+ detail,
525
+ ...extra
526
+ } });
527
+ /** The 403 of an operation with a permission, with one example per problem code. */
528
+ function permissionDeniedResponse() {
529
+ return {
530
+ description: "The authorizer denied the permission (`PERMISSION_DENIED`), the token lacks an OAuth scope (`INSUFFICIENT_SCOPE`), the action needs an approval (`APPROVAL_REQUIRED`), or row-level security denied the request.",
531
+ content: { [PROBLEM_CONTENT_TYPE]: {
532
+ schema: schemaRef("Problem"),
533
+ examples: {
534
+ permissionDenied: {
535
+ summary: "PERMISSION_DENIED",
536
+ ...problem("PERMISSION_DENIED", "Permission invoices.update is required", { permission: "invoices.update" })
537
+ },
538
+ insufficientScope: {
539
+ summary: "INSUFFICIENT_SCOPE",
540
+ ...problem("INSUFFICIENT_SCOPE", "The token lacks a required scope", { scopes: ["invoices.update"] })
541
+ },
542
+ approvalRequired: {
543
+ summary: "APPROVAL_REQUIRED",
544
+ ...problem("APPROVAL_REQUIRED", "invoices.update needs an approval", {
545
+ permission: "invoices.update",
546
+ approval: { id: "apr_123" }
547
+ })
548
+ }
549
+ }
550
+ } }
551
+ };
552
+ }
553
+ function errorResponse(error) {
554
+ return {
555
+ description: error.description,
556
+ content: { [PROBLEM_CONTENT_TYPE]: { schema: schemaRef("Problem") } }
557
+ };
558
+ }
559
+ /** The scheme name of the `oauth2` preset. */
560
+ const OAUTH_SCHEME = "supabaseOAuth";
561
+ /** Security schemes and top-level requirements for the presets. */
562
+ function resolveSecurity(presets, supabaseUrl, oauthScopes = {}) {
563
+ const schemes = {};
564
+ const requirements = [];
565
+ for (const preset of presets) {
566
+ if (typeof preset === "object") {
567
+ schemes[preset.name] = preset.scheme;
568
+ requirements.push({ [preset.name]: preset.scopes ?? [] });
569
+ continue;
570
+ }
571
+ switch (preset) {
572
+ case "bearer":
573
+ schemes["supabaseJwt"] = {
574
+ type: "http",
575
+ scheme: "bearer",
576
+ bearerFormat: "JWT",
577
+ description: "A Supabase access token. Requests run as that user under row-level security."
578
+ };
579
+ requirements.push({ supabaseJwt: [] });
580
+ break;
581
+ case "oauth2": {
582
+ if (!supabaseUrl) throw new TypeError("better-supabase/spec: oauth2 security needs supabaseUrl");
583
+ const origin = supabaseUrl.replace(/\/$/, "");
584
+ const auth = `${origin}/auth/v1`;
585
+ schemes[OAUTH_SCHEME] = {
586
+ type: "oauth2",
587
+ description: "The Supabase OAuth 2.1 server.",
588
+ flows: { authorizationCode: {
589
+ authorizationUrl: `${auth}/oauth/authorize`,
590
+ tokenUrl: `${auth}/oauth/token`,
591
+ scopes: oauthScopes
592
+ } },
593
+ metadataUrl: `${origin}/.well-known/oauth-authorization-server/auth/v1`
594
+ };
595
+ requirements.push({ [OAUTH_SCHEME]: [] });
596
+ break;
597
+ }
598
+ case "apiKey":
599
+ schemes["supabaseApiKey"] = {
600
+ type: "apiKey",
601
+ name: "apikey",
602
+ in: "header",
603
+ description: "The project's publishable key."
604
+ };
605
+ requirements.push({ supabaseApiKey: [] });
606
+ break;
607
+ default: throw new TypeError(`Unknown security preset "${String(preset)}"`);
608
+ }
609
+ }
610
+ return {
611
+ schemes,
612
+ requirements
613
+ };
614
+ }
615
+ //#endregion
616
+ //#region src/spec/build.ts
617
+ const METHODS = /* @__PURE__ */ new Set([
618
+ "get",
619
+ "put",
620
+ "post",
621
+ "patch",
622
+ "delete",
623
+ "head",
624
+ "options",
625
+ "trace",
626
+ "query"
627
+ ]);
628
+ function isMethod(value) {
629
+ return METHODS.has(value);
630
+ }
631
+ const READ_METHODS = /* @__PURE__ */ new Set([
632
+ "get",
633
+ "head",
634
+ "options",
635
+ "query"
636
+ ]);
637
+ /** The error statuses each operation can answer with. */
638
+ const OPERATION_STATUSES = {
639
+ list: [
640
+ 400,
641
+ 401,
642
+ 403
643
+ ],
644
+ create: [
645
+ 400,
646
+ 401,
647
+ 403,
648
+ 409,
649
+ 422
650
+ ],
651
+ get: [
652
+ 401,
653
+ 403,
654
+ 404
655
+ ],
656
+ update: [
657
+ 400,
658
+ 401,
659
+ 403,
660
+ 404,
661
+ 409,
662
+ 422
663
+ ],
664
+ delete: [
665
+ 401,
666
+ 403,
667
+ 404,
668
+ 409
669
+ ]
670
+ };
671
+ /** Statuses an operation only documents when it can answer with them; other errors apply everywhere. */
672
+ const SCOPED_STATUSES = /* @__PURE__ */ new Set([
673
+ 400,
674
+ 401,
675
+ 403,
676
+ 404,
677
+ 409,
678
+ 422
679
+ ]);
680
+ const JSON_TYPE = "application/json";
681
+ function pageParameters(cursor, maxPageSize) {
682
+ return pageQuery(cursor, maxPageSize).map((p) => ({
683
+ name: p.name,
684
+ in: "query",
685
+ required: false,
686
+ description: p.description,
687
+ schema: p.schema
688
+ }));
689
+ }
690
+ function isParameter(value) {
691
+ return isPlainObject(value) && typeof value["name"] === "string" && typeof value["in"] === "string" && isPlainObject(value["schema"]);
692
+ }
693
+ function isPlanCarrier(input) {
694
+ return typeof input === "object" && "plan" in input;
695
+ }
696
+ /** `description` and `deprecated` from comments, read structurally so older metadata still works. */
697
+ function docsOf(value) {
698
+ if (!value) return {};
699
+ const description = "description" in value ? value.description : void 0;
700
+ const deprecated = "deprecated" in value ? value.deprecated : void 0;
701
+ return {
702
+ ...typeof description === "string" && description !== "" ? { description } : {},
703
+ ...deprecated === true ? { deprecated: true } : {}
704
+ };
705
+ }
706
+ function jsonContent(schema) {
707
+ return { [JSON_TYPE]: { schema } };
708
+ }
709
+ function jsonResponse(schema, description) {
710
+ return {
711
+ description,
712
+ content: jsonContent(schema)
713
+ };
714
+ }
715
+ function mutableProperties(schema) {
716
+ const properties = schema["properties"];
717
+ if (!isPlainObject(properties)) return void 0;
718
+ const copy = {};
719
+ for (const [key, value] of Object.entries(properties)) if (isPlainObject(value)) copy[key] = { ...value };
720
+ schema["properties"] = copy;
721
+ return copy;
722
+ }
723
+ const modelCache = /* @__PURE__ */ new WeakMap();
724
+ const NO_PLUGINS = [];
725
+ /**
726
+ * Builds the version-neutral API model once per metadata, plugin list and
727
+ * options object. Formats lower it to each version; `defineApi` wraps it.
728
+ */
729
+ function buildApiModel(source, options) {
730
+ const plugins = source.plugins ?? NO_PLUGINS;
731
+ let byPlugins = modelCache.get(source.meta);
732
+ if (!byPlugins) {
733
+ byPlugins = /* @__PURE__ */ new WeakMap();
734
+ modelCache.set(source.meta, byPlugins);
735
+ }
736
+ let byOptions = byPlugins.get(plugins);
737
+ if (!byOptions) {
738
+ byOptions = /* @__PURE__ */ new WeakMap();
739
+ byPlugins.set(plugins, byOptions);
740
+ }
741
+ let built = byOptions.get(options);
742
+ if (!built) {
743
+ built = build(source.meta, plugins, options);
744
+ byOptions.set(options, built);
745
+ }
746
+ return built;
747
+ }
748
+ function build(meta, plugins, options) {
749
+ const prefix = options.extensionPrefix ?? "x-better-supabase-";
750
+ const diagnostics = [];
751
+ const report = (diagnostic) => {
752
+ diagnostics.push(diagnostic);
753
+ };
754
+ const base = (options.basePath ?? "").replace(/\/$/, "");
755
+ const globalErrors = options.errors ?? DEFAULT_ERRORS;
756
+ const schemas = { Problem: structuredClone(PROBLEM_SCHEMA) };
757
+ const responses = {};
758
+ for (const error of globalErrors) responses[error.name] = errorResponse(error);
759
+ const operations = [];
760
+ const tags = [...options.tags ?? []];
761
+ const served = /* @__PURE__ */ new Map();
762
+ const { authorizer } = options;
763
+ const addTag = (name, description) => {
764
+ if (tags.some((tag) => tag.name === name)) return;
765
+ tags.push({
766
+ name,
767
+ ...description ? { description } : {}
768
+ });
769
+ };
770
+ const addComponent = (name, schema) => {
771
+ const existing = schemas[name];
772
+ if (existing && JSON.stringify(existing) !== JSON.stringify(schema)) {
773
+ report({
774
+ code: "component-conflict",
775
+ severity: "error",
776
+ message: `Two different schemas are named "${name}"; the first one is kept`,
777
+ pointer: `/components/schemas/${pointerToken(name)}`
778
+ });
779
+ return;
780
+ }
781
+ schemas[name] = schema;
782
+ };
783
+ const keyOf = (ref, where) => {
784
+ if (authorizer) try {
785
+ return authorizer.key(ref);
786
+ } catch {
787
+ report({
788
+ code: "permission-unresolved",
789
+ severity: "error",
790
+ message: `${where}: the authorizer has no key for this permission`
791
+ });
792
+ return;
793
+ }
794
+ if (typeof ref === "string") return ref;
795
+ report({
796
+ code: "permission-unresolved",
797
+ severity: "error",
798
+ message: `${where}: a permission that is not a string needs an authorizer`
799
+ });
800
+ };
801
+ const converted = (standard, direction, where) => {
802
+ const result = convertStandard(standard, direction);
803
+ if (!result) report({
804
+ code: "schema-unconvertible",
805
+ severity: "warning",
806
+ message: `${where}: the schema does not implement Standard JSON Schema, so the spec allows any value`
807
+ });
808
+ return result;
809
+ };
810
+ const schemaOf = (standard, direction, role, operationId) => {
811
+ const result = converted(standard, direction, `${operationId} ${role}`);
812
+ if (!result) return {};
813
+ const name = options.componentName ? options.componentName({
814
+ kind: "schema",
815
+ id: result.name,
816
+ schema: result.schema,
817
+ role,
818
+ operationId
819
+ }) : result.name;
820
+ if (!name) return structuredClone(result.schema);
821
+ addComponent(name, structuredClone(result.schema));
822
+ return schemaRef(name);
823
+ };
824
+ const objectParameters = (standard, location, where) => {
825
+ const result = converted(standard, "input", where);
826
+ const properties = result?.schema["properties"];
827
+ if (!result || !isPlainObject(properties)) return [];
828
+ const required = result.schema["required"];
829
+ const requiredNames = Array.isArray(required) ? required : [];
830
+ return Object.entries(properties).flatMap(([name, schema]) => {
831
+ if (!isPlainObject(schema)) return [];
832
+ const description = schema["description"];
833
+ return [{
834
+ name,
835
+ in: location,
836
+ required: location === "path" || requiredNames.includes(name),
837
+ ...typeof description === "string" ? { description } : {},
838
+ schema: structuredClone(schema)
839
+ }];
840
+ });
841
+ };
842
+ const usedErrors = (errors, statuses, permission) => {
843
+ const out = {};
844
+ for (const error of errors) {
845
+ if (SCOPED_STATUSES.has(error.status) && !statuses.includes(error.status)) continue;
846
+ const status = String(error.status);
847
+ if (Object.hasOwn(out, status)) continue;
848
+ if (error.status === 403 && permission) continue;
849
+ responses[error.name] ??= errorResponse(error);
850
+ out[status] = { ref: error.name };
851
+ }
852
+ if (permission) {
853
+ responses[PERMISSION_DENIED] ??= permissionDeniedResponse();
854
+ out["403"] = { ref: PERMISSION_DENIED };
855
+ }
856
+ return out;
857
+ };
858
+ const extendFor = (extend, name) => {
859
+ if (!extend) return void 0;
860
+ const all = extend["*"];
861
+ const own = extend[name];
862
+ if (!all && !own) return void 0;
863
+ return mergeJson(all ?? {}, own ?? {});
864
+ };
865
+ for (const [key, input] of Object.entries(options.resources ?? {})) {
866
+ let plan;
867
+ if (isPlanCarrier(input)) plan = input.plan;
868
+ else {
869
+ if (!meta.tables[key]) throw new TypeError(`better-supabase/spec: unknown table "${key}"`);
870
+ plan = planResource(meta, key, input === true ? {} : input, authorizer);
871
+ }
872
+ const tableKey = plan.table;
873
+ const table = plan.meta;
874
+ const description = plan.description;
875
+ const name = pascal(tableKey);
876
+ const tableDocs = docsOf(table);
877
+ const defs = tableSchemas(meta, options.json ?? {});
878
+ const componentFor = (variant) => {
879
+ const defaultName = `${name}${variant}`;
880
+ return options.componentName?.({
881
+ kind: "table",
882
+ table: tableKey,
883
+ variant,
884
+ defaultName
885
+ }) ?? defaultName;
886
+ };
887
+ const components = {};
888
+ for (const variant of [
889
+ "Row",
890
+ "Insert",
891
+ "Update"
892
+ ]) {
893
+ const def = defs[`${tableKey}${variant}`];
894
+ if (!def) continue;
895
+ const schema = structuredClone(def);
896
+ if (tableDocs.description && schema["description"] === void 0) schema["description"] = tableDocs.description;
897
+ if (tableDocs.deprecated) schema["deprecated"] = true;
898
+ const properties = mutableProperties(schema);
899
+ for (const [column, property] of Object.entries(properties ?? {})) {
900
+ const docs = docsOf(table.columns[column]);
901
+ if (docs.description && property["description"] === void 0) property["description"] = docs.description;
902
+ if (docs.deprecated) property["deprecated"] = true;
903
+ }
904
+ const examples = options.examples?.[tableKey];
905
+ if (variant === "Row" && examples && examples.length > 0) schema["examples"] = structuredClone(examples);
906
+ const componentName = componentFor(variant);
907
+ components[variant] = componentName;
908
+ addComponent(componentName, schema);
909
+ }
910
+ const rowName = components.Row ?? componentFor("Row");
911
+ const cursor = plan.pagination === "cursor";
912
+ const pageName = componentFor("Page");
913
+ addComponent(pageName, pageSchema(schemaRef(rowName), cursor));
914
+ const tag = description.tag ?? tableKey;
915
+ addTag(tag, description.description ?? tableDocs.description);
916
+ const collection = `${base}${description.path ?? `/${tableKey}`}`;
917
+ const keyParam = plan.keyParam;
918
+ const rowProperties = defs[`${tableKey}Row`]?.["properties"];
919
+ const keySchema = keyParam && isPlainObject(rowProperties) ? rowProperties[keyParam] : void 0;
920
+ const idParameter = keyParam ? {
921
+ name: keyParam,
922
+ in: "path",
923
+ required: true,
924
+ schema: isPlainObject(keySchema) ? structuredClone(keySchema) : { type: "string" }
925
+ } : void 0;
926
+ const item = keyParam ? `${collection}/{${keyParam}}` : void 0;
927
+ const errors = description.errors ?? globalErrors;
928
+ const servedTable = {
929
+ table,
930
+ components,
931
+ operations: []
932
+ };
933
+ served.set(tableKey, servedTable);
934
+ const names = /* @__PURE__ */ new Set([...plan.operations, ...plan.actions.map((action) => action.name)]);
935
+ for (const extendKey of Object.keys(description.extend ?? {})) if (extendKey !== "*" && !names.has(extendKey)) report({
936
+ code: "extend-unknown",
937
+ severity: "warning",
938
+ message: `${tableKey}.extend.${extendKey} names no operation or action of the resource`
939
+ });
940
+ const add = (opName, source, method, path, fields) => {
941
+ const defaultId = `${opName}${name}`;
942
+ const id = options.operationId?.({
943
+ source,
944
+ method,
945
+ path,
946
+ defaultId
947
+ }) ?? defaultId;
948
+ const ref = plan.permissions[opName];
949
+ const permission = ref === void 0 ? void 0 : keyOf(ref, `${tableKey}.${opName}`);
950
+ const extend = extendFor(description.extend, opName);
951
+ const { extensions, ...rest } = fields;
952
+ const operation = {
953
+ id,
954
+ method,
955
+ path,
956
+ tags: [tag],
957
+ source,
958
+ ...rest,
959
+ extensions: {
960
+ [`${prefix}table`]: `${table.schema}.${table.name}`,
961
+ ...extensions,
962
+ ...permission === void 0 ? {} : { [`${prefix}permission`]: permission }
963
+ },
964
+ ...permission === void 0 ? {} : { permission },
965
+ ...description.security ? { security: description.security } : {},
966
+ ...extend ? { extend } : {},
967
+ ...tableDocs.deprecated ? { deprecated: true } : {}
968
+ };
969
+ operations.push(operation);
970
+ servedTable.operations.push(operation);
971
+ };
972
+ const outputOf = (operation, fallback) => {
973
+ const output = description.output?.[operation];
974
+ return output ? schemaOf(output, "output", "output", `${operation}${name}`) : fallback;
975
+ };
976
+ const resourceOp = (operation) => ({
977
+ kind: "resource",
978
+ table: tableKey,
979
+ operation
980
+ });
981
+ const errorsFor = (operation) => usedErrors(errors, OPERATION_STATUSES[operation], plan.permissions[operation] !== void 0);
982
+ const opExtension = (operation) => ({ [`${prefix}operation`]: operation });
983
+ for (const operation of plan.operations) switch (operation) {
984
+ case "list": {
985
+ const listOutput = description.output?.list;
986
+ const pageRef = listOutput ? pageSchema(schemaOf(listOutput, "output", "item", `list${name}`), cursor) : schemaRef(pageName);
987
+ add("list", resourceOp("list"), "get", collection, {
988
+ summary: `List ${tableKey}`,
989
+ extensions: opExtension("list"),
990
+ parameters: description.list ? description.list.openapi.filter(isParameter) : pageParameters(cursor, plan.maxPageSize),
991
+ responses: {
992
+ "200": jsonResponse(pageRef, `A page of ${tableKey}.`),
993
+ ...errorsFor("list")
994
+ }
995
+ });
996
+ break;
997
+ }
998
+ case "create": {
999
+ const body = description.input?.create ? schemaOf(description.input.create, "input", "input", `create${name}`) : schemaRef(components.Insert ?? componentFor("Insert"));
1000
+ add("create", resourceOp("create"), "post", collection, {
1001
+ summary: `Create a ${tableKey} row`,
1002
+ extensions: opExtension("create"),
1003
+ parameters: [],
1004
+ requestBody: {
1005
+ required: true,
1006
+ content: jsonContent(body)
1007
+ },
1008
+ responses: {
1009
+ "201": jsonResponse(outputOf("create", schemaRef(rowName)), "Created."),
1010
+ ...errorsFor("create")
1011
+ }
1012
+ });
1013
+ break;
1014
+ }
1015
+ case "get":
1016
+ if (!item || !idParameter) break;
1017
+ add("get", resourceOp("get"), "get", item, {
1018
+ summary: `Get a ${tableKey} row`,
1019
+ extensions: opExtension("get"),
1020
+ parameters: [idParameter],
1021
+ responses: {
1022
+ "200": jsonResponse(outputOf("get", schemaRef(rowName)), "The row."),
1023
+ ...errorsFor("get")
1024
+ }
1025
+ });
1026
+ break;
1027
+ case "update": {
1028
+ if (!item || !idParameter) break;
1029
+ const body = description.input?.update ? schemaOf(description.input.update, "input", "input", `update${name}`) : schemaRef(components.Update ?? componentFor("Update"));
1030
+ add("update", resourceOp("update"), "patch", item, {
1031
+ summary: `Update a ${tableKey} row`,
1032
+ extensions: opExtension("update"),
1033
+ parameters: [idParameter],
1034
+ requestBody: {
1035
+ required: true,
1036
+ content: jsonContent(body)
1037
+ },
1038
+ responses: {
1039
+ "200": jsonResponse(outputOf("update", schemaRef(rowName)), "Updated."),
1040
+ ...errorsFor("update")
1041
+ }
1042
+ });
1043
+ break;
1044
+ }
1045
+ case "delete":
1046
+ if (!item || !idParameter) break;
1047
+ add("delete", resourceOp("delete"), "delete", item, {
1048
+ summary: `Delete a ${tableKey} row`,
1049
+ extensions: opExtension("delete"),
1050
+ parameters: [idParameter],
1051
+ responses: {
1052
+ "204": { description: "Deleted." },
1053
+ ...errorsFor("delete")
1054
+ }
1055
+ });
1056
+ break;
1057
+ default: throw new TypeError(`better-supabase/spec: unknown operation "${String(operation)}"`);
1058
+ }
1059
+ for (const action of plan.actions) {
1060
+ const method = action.method.toLowerCase();
1061
+ if (!isMethod(method)) throw new TypeError(`${tableKey}.actions.${action.name}: unknown method`);
1062
+ const operationId = `${action.name}${name}`;
1063
+ const parameters = [...action.params.length > 0 && idParameter ? [idParameter] : [], ...action.query ? objectParameters(action.query, "query", `${operationId} query`) : []];
1064
+ const status = String(action.status ?? (action.output ? 200 : 204));
1065
+ const statuses = [
1066
+ ...action.input || action.query ? [400] : [],
1067
+ 401,
1068
+ 403,
1069
+ ...action.params.length > 0 ? [404] : [],
1070
+ ...action.input ? [422] : []
1071
+ ];
1072
+ add(action.name, {
1073
+ kind: "action",
1074
+ table: tableKey,
1075
+ action: action.name
1076
+ }, method, `${collection}${action.path}`, {
1077
+ ...action.summary ? { summary: action.summary } : {},
1078
+ ...action.description ? { description: action.description } : {},
1079
+ ...action.deprecated ? { deprecated: true } : {},
1080
+ extensions: {
1081
+ [`${prefix}action`]: action.name,
1082
+ ...action.emits ? { [`${prefix}emits`]: [...action.emits] } : {}
1083
+ },
1084
+ parameters,
1085
+ ...action.input ? { requestBody: {
1086
+ required: true,
1087
+ content: jsonContent(schemaOf(action.input, "input", "input", operationId))
1088
+ } } : {},
1089
+ responses: {
1090
+ [status]: action.output ? jsonResponse(schemaOf(action.output, "output", "output", operationId), action.summary ?? "Done.") : { description: action.summary ?? "Done." },
1091
+ ...usedErrors(errors, statuses, action.permission !== void 0)
1092
+ }
1093
+ });
1094
+ }
1095
+ }
1096
+ for (const [index, route] of (options.routes ?? []).entries()) {
1097
+ const method = route.method.toLowerCase();
1098
+ if (!isMethod(method)) throw new TypeError(`better-supabase/spec: routes[${index}] has an unknown method "${route.method}"`);
1099
+ const path = `${base}${route.path}`;
1100
+ const defaultId = `${method}${route.path.split("/").filter(Boolean).map((segment) => segment.replaceAll(/[{}]/g, "")).map(pascal).join("")}`;
1101
+ const source = { kind: "route" };
1102
+ const id = route.operationId ?? options.operationId?.({
1103
+ source,
1104
+ method,
1105
+ path,
1106
+ defaultId
1107
+ }) ?? defaultId;
1108
+ const declared = route.params ? objectParameters(route.params, "path", `${id} params`) : [];
1109
+ const parameters = [];
1110
+ for (const [, param] of path.matchAll(/\{(\w+)\}/g)) parameters.push(declared.find((entry) => entry.name === param) ?? {
1111
+ name: param,
1112
+ in: "path",
1113
+ required: true,
1114
+ schema: { type: "string" }
1115
+ });
1116
+ if (route.query) parameters.push(...objectParameters(route.query, "query", `${id} query`));
1117
+ const permission = route.permission === void 0 ? void 0 : keyOf(route.permission, `routes[${index}]`);
1118
+ const secured = route.security === void 0 || route.security.length > 0;
1119
+ const status = String(route.status ?? (route.output || route.stream ? 200 : 204));
1120
+ const success = route.stream ? {
1121
+ description: route.summary ?? "A stream of events.",
1122
+ content: { [route.stream.contentType ?? "text/event-stream"]: { itemSchema: schemaOf(route.stream.item, "output", "item", id) } }
1123
+ } : route.output ? jsonResponse(schemaOf(route.output, "output", "output", id), route.summary ?? "OK.") : { description: route.summary ?? "Done." };
1124
+ const routeTags = [...route.tags ?? []];
1125
+ for (const tag of routeTags) addTag(tag);
1126
+ operations.push({
1127
+ id,
1128
+ method,
1129
+ path,
1130
+ tags: routeTags,
1131
+ source,
1132
+ ...route.summary ? { summary: route.summary } : {},
1133
+ ...route.description ? { description: route.description } : {},
1134
+ ...route.deprecated ? { deprecated: true } : {},
1135
+ parameters,
1136
+ ...route.input ? { requestBody: {
1137
+ required: true,
1138
+ content: jsonContent(schemaOf(route.input, "input", "input", id))
1139
+ } } : {},
1140
+ responses: {
1141
+ [status]: success,
1142
+ ...usedErrors(route.errors ?? globalErrors, [...route.input || route.query ? [400, 422] : [], ...secured ? [401, 403] : []], permission !== void 0)
1143
+ },
1144
+ ...route.security ? { security: route.security } : {},
1145
+ ...permission === void 0 ? {} : { permission },
1146
+ extensions: permission === void 0 ? {} : { [`${prefix}permission`]: permission },
1147
+ ...route.extend ? { extend: route.extend } : {}
1148
+ });
1149
+ }
1150
+ const oauthScopes = {};
1151
+ if (options.permissionScopes === "keys") {
1152
+ for (const operation of operations) if (operation.permission) oauthScopes[operation.permission] = `Permission ${operation.permission}.`;
1153
+ }
1154
+ const security = resolveSecurity(options.security ?? ["bearer"], options.supabaseUrl, oauthScopes);
1155
+ if (options.permissionScopes === "keys") for (const operation of operations) {
1156
+ const key = operation.permission;
1157
+ if (!key || operation.security?.length === 0) continue;
1158
+ operation.security = (operation.security ?? security.requirements).map((requirement) => {
1159
+ const scopes = requirement[OAUTH_SCHEME];
1160
+ return scopes ? {
1161
+ ...requirement,
1162
+ [OAUTH_SCHEME]: [...scopes, key]
1163
+ } : requirement;
1164
+ });
1165
+ }
1166
+ const describe = describeApi(meta, prefix, served, schemas);
1167
+ for (const plugin of plugins) {
1168
+ if (!plugin.describe) continue;
1169
+ try {
1170
+ plugin.describe(describe);
1171
+ } catch (error) {
1172
+ report({
1173
+ code: "plugin-describe-failed",
1174
+ severity: "warning",
1175
+ message: `The ${plugin.name} plugin's describe() threw: ${error instanceof Error ? error.message : String(error)}`
1176
+ });
1177
+ }
1178
+ }
1179
+ if (options.requirePermissions) {
1180
+ for (const operation of operations) if ((operation.source.kind === "resource" ? operation.source.operation !== "list" && operation.source.operation !== "get" : !READ_METHODS.has(operation.method)) && operation.permission === void 0) report({
1181
+ code: "permission-missing",
1182
+ severity: "error",
1183
+ message: `${operation.id} writes but declares no permission`,
1184
+ pointer: `/operations/${pointerToken(operation.id)}`
1185
+ });
1186
+ }
1187
+ const seen = /* @__PURE__ */ new Set();
1188
+ for (const operation of operations) {
1189
+ if (seen.has(operation.id)) report({
1190
+ code: "operation-id-duplicate",
1191
+ severity: "error",
1192
+ message: `Two operations have the id "${operation.id}"`,
1193
+ pointer: `/operations/${pointerToken(operation.id)}`
1194
+ });
1195
+ seen.add(operation.id);
1196
+ }
1197
+ const { enrich } = options;
1198
+ const finalSchemas = {};
1199
+ for (const [name, schema] of Object.entries(schemas)) finalSchemas[name] = enrich?.schema?.(schema, { name }) ?? schema;
1200
+ const finalOperations = operations.map((operation) => enrich?.operation?.(operation) ?? operation);
1201
+ const { messageTraits, ...parts } = eventParts(options, {
1202
+ meta,
1203
+ json: options.json ?? {},
1204
+ prefix,
1205
+ served,
1206
+ keyOf,
1207
+ report
1208
+ }, finalOperations);
1209
+ const messages = {};
1210
+ for (const [id, message] of Object.entries(parts.messages)) messages[id] = enrich?.message?.(message, { id }) ?? message;
1211
+ return {
1212
+ model: {
1213
+ info: options.info,
1214
+ ...options.self ? { self: options.self } : {},
1215
+ servers: options.servers ?? [],
1216
+ tags,
1217
+ operations: finalOperations,
1218
+ schemas: finalSchemas,
1219
+ responses,
1220
+ securitySchemes: security.schemes,
1221
+ security: security.requirements,
1222
+ ...options.securityProfileRequirements ? { securityProfileRequirements: options.securityProfileRequirements } : {},
1223
+ channels: parts.channels.map((channel) => enrich?.channel?.(channel) ?? channel),
1224
+ messages,
1225
+ ...messageTraits ? { messageTraits } : {},
1226
+ webhooks: options.webhooks ?? [],
1227
+ workflows: parts.workflows.map((workflow) => enrich?.workflow?.(workflow) ?? workflow),
1228
+ fragments: options.fragments ?? [],
1229
+ ...options.realtimeUrl ? { realtimeUrl: options.realtimeUrl } : {},
1230
+ extensionPrefix: prefix
1231
+ },
1232
+ diagnostics
1233
+ };
1234
+ }
1235
+ function describeApi(meta, prefix, served, schemas) {
1236
+ const columnSchemas = (table, column) => {
1237
+ const entry = served.get(table);
1238
+ if (!entry) return [];
1239
+ return [
1240
+ "Row",
1241
+ "Insert",
1242
+ "Update"
1243
+ ].flatMap((variant) => {
1244
+ const name = entry.components[variant];
1245
+ const schema = name ? schemas[name] : void 0;
1246
+ const properties = schema?.["properties"];
1247
+ if (!schema || !isPlainObject(properties)) return [];
1248
+ const property = properties[column];
1249
+ if (!isPlainObject(property)) return [];
1250
+ return [{
1251
+ variant,
1252
+ schema,
1253
+ properties,
1254
+ property
1255
+ }];
1256
+ });
1257
+ };
1258
+ const replace = (schema, properties, column, property) => {
1259
+ schema["properties"] = {
1260
+ ...properties,
1261
+ [column]: property
1262
+ };
1263
+ };
1264
+ return {
1265
+ schema: meta,
1266
+ extensionPrefix: prefix,
1267
+ resources: [...served.values()].map((entry) => ({
1268
+ table: entry.table,
1269
+ operations: entry.operations.map((operation) => operation.source.kind === "action" ? operation.source.action : operation.source.kind === "resource" ? operation.source.operation : operation.id)
1270
+ })),
1271
+ addParameter(table, parameter, names) {
1272
+ for (const operation of served.get(table)?.operations ?? []) {
1273
+ const name = operation.source.kind === "action" ? operation.source.action : operation.source.kind === "resource" ? operation.source.operation : operation.id;
1274
+ if (names && !names.includes(name)) continue;
1275
+ if (operation.parameters.some((entry) => entry.name === parameter.name && entry.in === parameter.in)) continue;
1276
+ operation.parameters.push({ ...parameter });
1277
+ }
1278
+ },
1279
+ markReadOnly(table, column, description) {
1280
+ for (const { variant, schema, properties, property } of columnSchemas(table, column)) {
1281
+ replace(schema, properties, column, {
1282
+ ...property,
1283
+ readOnly: true,
1284
+ ...description && property["description"] === void 0 ? { description } : {}
1285
+ });
1286
+ const required = schema["required"];
1287
+ if (variant !== "Row" && Array.isArray(required)) schema["required"] = required.filter((name) => name !== column);
1288
+ }
1289
+ },
1290
+ describeColumn(table, column, patch) {
1291
+ for (const { schema, properties, property } of columnSchemas(table, column)) replace(schema, properties, column, mergeJson(property, patch));
1292
+ }
1293
+ };
1294
+ }
1295
+ //#endregion
1296
+ export { safeKey as a, mergeJson as c, CLOUD_EVENT_TRAIT as i, pointerToken as l, DEFAULT_ERRORS as n, convertStandard as o, PROBLEM_SCHEMA as r, pascal as s, buildApiModel as t };