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,2216 @@
1
+ import { n as CliError, r as errorText } from "./errors-DcJ_PayO.js";
2
+ import { n as importPath } from "./io-CQzy8PEZ.js";
3
+ import { i as cachedTypesModule, n as cachedDatabaseTypes, s as typesModuleKey } from "./cache-CvBRwv02.js";
4
+ import { t as byCodePoint } from "./compare-yl4sSwVn.js";
5
+ import { f as generateDatabaseTypes, h as restrictSchemas, p as oxfmtInstalled, v as tsTypeOf } from "./snapshot-Dd_8B9g-.js";
6
+ import { s as providerTruncatedClaim } from "./authorization-DJkkOjjG.js";
7
+ import { t as isRecord$1 } from "./guards-DxwRG0Uv.js";
8
+ import { a as toCatalog } from "./source-BYvVe_Es.js";
9
+ import { m as withTableTags } from "./config-DrrkMihk.js";
10
+ import { basename, dirname, isAbsolute, join, posix, relative, resolve } from "node:path";
11
+ import { entityNames } from "better-supabase/blocks";
12
+ import { DEFAULT_CLAIMS, blockEntities, blockEntityRenames, blockSubjectTypes, tenantClaimPaths, tenantNameOf } from "better-supabase/config";
13
+ import { PRESET_CATALOG } from "better-supabase/preset";
14
+ import { BLOCK_OPTION_SCHEMAS, DEFAULT_ROLES, SQL_MODULES, appTableEventTypes, instanceFunctions, modulePermissionKeys, resolveBlock, resolveBlocks, resolveProviderSql } from "better-supabase/sql";
15
+ import { toCamel } from "better-supabase";
16
+ // src/cli/gen/model-types.ts
17
+ const applyCasing = (name, casing) => casing === "camel" ? toCamel(name) : name;
18
+ /** The Postgres type name of each app column type, as introspection reports it. */
19
+ const APP_COLUMN_UDT = {
20
+ text: "text",
21
+ integer: "int4",
22
+ bigint: "int8",
23
+ numeric: "numeric",
24
+ boolean: "bool",
25
+ uuid: "uuid",
26
+ timestamptz: "timestamptz",
27
+ date: "date",
28
+ jsonb: "jsonb",
29
+ "text[]": "_text"
30
+ };
31
+ const CODEC_TYPE = {
32
+ instant: "Temporal.Instant",
33
+ plainDateTime: "Temporal.PlainDateTime",
34
+ bigint: "bigint",
35
+ string: "string",
36
+ utcString: "string"
37
+ };
38
+ function codecFor(udt, config) {
39
+ const { codecs } = config;
40
+ if (codecs.timestamptz === "utc" && udt === "timestamptz") return "utcString";
41
+ if (codecs.timestamptz === "instant") {
42
+ if (udt === "timestamptz") return "instant";
43
+ if (udt === "timestamp") return "plainDateTime";
44
+ }
45
+ if (udt === "int8" && codecs.int8 !== "number") return codecs.int8;
46
+ if (udt === "numeric" && codecs.numeric === "string") return "string";
47
+ }
48
+ function enumType(values) {
49
+ return values.map((value) => JSON.stringify(value)).join(" | ");
50
+ }
51
+ // src/cli/gen/shared.ts
52
+ const q = (value) => JSON.stringify(value);
53
+ /**
54
+ * The import path of a runtime subpath: `better-supabase/blocks/trash`, or
55
+ * `../src/blocks/trash/index.ts` when the runtime is imported from source.
56
+ */
57
+ const runtimeSubpath = (runtime, subpath) => runtime.endsWith("/index.ts") ? `${runtime.slice(0, -8)}${subpath}/index.ts` : `${runtime}/${subpath}`;
58
+ /** A property key: bare when it is a valid identifier, quoted otherwise. */
59
+ function prop(name) {
60
+ return /^[A-Za-z_$][\w$]*$/.test(name) ? name : q(name);
61
+ }
62
+ function nullable(type, isNullable) {
63
+ return isNullable ? `${type} | null` : type;
64
+ }
65
+ /** `T[]`, parenthesized when `T` is a union or other compound type. */
66
+ function arrayOf(type) {
67
+ return /^[\w.$]+$/.test(type) ? `${type}[]` : `(${type})[]`;
68
+ }
69
+ function indent(lines, depth) {
70
+ const pad = " ".repeat(depth);
71
+ return lines.flatMap((line) => line.split("\n")).map((line) => line === "" ? line : pad + line);
72
+ }
73
+ /** `name: {` + indented children + `};`, or an inline empty type. */
74
+ function block(name, children, empty = "{ [_ in never]: never }") {
75
+ if (children.length === 0) return [`${name}: ${empty};`];
76
+ return [
77
+ `${name}: {`,
78
+ ...indent(children, 1),
79
+ "};"
80
+ ];
81
+ }
82
+ function sameColumns(left, right) {
83
+ return left.length === right.length && left.every((column) => right.includes(column));
84
+ }
85
+ function singular(name) {
86
+ if (name.endsWith("ies")) return `${name.slice(0, -3)}y`;
87
+ if (name.endsWith("sses")) return name.slice(0, -2);
88
+ if (name.endsWith("s") && !name.endsWith("ss")) return name.slice(0, -1);
89
+ return name;
90
+ }
91
+ function pascal$2(name) {
92
+ return name.replaceAll(/(^|[_-]+)([a-z0-9])/g, (_, __, char) => char.toUpperCase()).replace(/^[a-z]/, (char) => char.toUpperCase());
93
+ }
94
+ /**
95
+ * A valid TypeScript identifier: other characters become `_`, a leading digit
96
+ * gets one.
97
+ */
98
+ function identifier(name) {
99
+ const safe = name.replaceAll(/[^\w$]/g, "_");
100
+ return /^\d/.test(safe) ? `_${safe}` : safe;
101
+ }
102
+ /**
103
+ * The config entry for a database object, keyed `schema.name` or `name`. The
104
+ * qualified key wins.
105
+ */
106
+ function configFor(entries, schema, name) {
107
+ return entries[`${schema}.${name}`] ?? entries[name];
108
+ }
109
+ function isJsonUdt(udt) {
110
+ return udt === "json" || udt === "jsonb";
111
+ }
112
+ const CHECK_ANY = /^CHECK \(\(\(?"?(\w+)"?\)?(?:::\w+)? = ANY \(\(?ARRAY\[(.+)\]\)?(?:::\w+\[\])?\)\)\)$/;
113
+ const CHECK_OR = /^CHECK \(\((.+)\)\)$/;
114
+ const OR_TERM = /^\(?"?(\w+)"?\)?(?:::\w+)? = '((?:[^']|'')*)'(?:::\w+)?\)?$/;
115
+ const LITERAL = /'((?:[^']|'')*)'(?:::[\w ]+)?/g;
116
+ /**
117
+ * Extracts `column in ('a', 'b')` CHECK constraints, which Postgres stores as
118
+ * `CHECK ((col = ANY (ARRAY['a'::text, 'b'::text])))` or an OR chain.
119
+ */
120
+ function parseCheckUnion(definition) {
121
+ const any = CHECK_ANY.exec(definition);
122
+ if (any?.[1] && any[2]) {
123
+ const values = [...any[2].matchAll(LITERAL)].map((match) => (match[1] ?? "").replaceAll("''", "'"));
124
+ return values.length > 0 ? {
125
+ column: any[1],
126
+ values
127
+ } : void 0;
128
+ }
129
+ const chain = CHECK_OR.exec(definition);
130
+ if (chain?.[1]) {
131
+ const terms = chain[1].split(/\) OR \(|\s+OR\s+/);
132
+ let column;
133
+ const values = [];
134
+ for (const term of terms) {
135
+ const match = OR_TERM.exec(term.trim());
136
+ if (!match?.[1]) return;
137
+ if (column && column !== match[1]) return;
138
+ column = match[1];
139
+ values.push((match[2] ?? "").replaceAll("''", "'"));
140
+ }
141
+ return column && values.length > 1 ? {
142
+ column,
143
+ values
144
+ } : void 0;
145
+ }
146
+ }
147
+ /** The text inside one pair of parentheses that wraps all of `text`, if any. */
148
+ function unwrap(text) {
149
+ let current = text.trim();
150
+ while (current.startsWith("(") && current.endsWith(")")) {
151
+ let depth = 0;
152
+ let wraps = true;
153
+ for (let index = 0; index < current.length; index += 1) {
154
+ const char = current[index];
155
+ if (char === "(") depth += 1;
156
+ else if (char === ")") depth -= 1;
157
+ if (depth === 0 && index < current.length - 1) {
158
+ wraps = false;
159
+ break;
160
+ }
161
+ }
162
+ if (!wraps) break;
163
+ current = current.slice(1, -1).trim();
164
+ }
165
+ return current;
166
+ }
167
+ /** Splits `text` on a keyword outside parentheses and quotes. */
168
+ function splitTopLevel(text, keyword) {
169
+ const parts = [];
170
+ let depth = 0;
171
+ let quote;
172
+ let start = 0;
173
+ const separator = ` ${keyword} `;
174
+ for (let index = 0; index < text.length; index += 1) {
175
+ const char = text[index];
176
+ if (quote) {
177
+ if (char === quote) quote = void 0;
178
+ continue;
179
+ }
180
+ if (char === "'" || char === "\"") quote = char;
181
+ else if (char === "(") depth += 1;
182
+ else if (char === ")") depth -= 1;
183
+ else if (depth === 0 && text.slice(index, index + separator.length).toUpperCase() === separator) {
184
+ parts.push(text.slice(start, index));
185
+ start = index + separator.length;
186
+ index += separator.length - 1;
187
+ }
188
+ }
189
+ parts.push(text.slice(start));
190
+ return parts.map((part) => part.trim());
191
+ }
192
+ const IS_NOT_NULL = /^(?:"((?:[^"]|"")+)"|([\w$]+)) IS NOT NULL$/i;
193
+ /**
194
+ * Columns a CHECK constraint makes not null: `CHECK ((slug IS NOT NULL))` and
195
+ * the `IS NOT NULL` terms of a top-level `AND`. A term under `OR`, `NOT` or any
196
+ * other expression narrows nothing, and neither does a `NOT VALID` one.
197
+ */
198
+ function parseCheckNotNull(definition) {
199
+ const text = definition.trim();
200
+ if (/\bNOT VALID$/i.test(text)) return [];
201
+ const body = /^CHECK\s*(.*)$/is.exec(text)?.[1];
202
+ if (!body) return [];
203
+ const expression = unwrap(body);
204
+ if (splitTopLevel(expression, "OR").length > 1) return [];
205
+ return splitTopLevel(expression, "AND").flatMap((term) => {
206
+ const match = IS_NOT_NULL.exec(unwrap(term));
207
+ if (!match) return [];
208
+ return [match[1]?.replaceAll("\"\"", "\"") ?? match[2] ?? ""];
209
+ });
210
+ }
211
+ // src/cli/gen/block-names.ts
212
+ const PLACEHOLDER = /\{(\.\.\.)?([A-Za-z_][\w]*)\}/g;
213
+ function isRecord(value) {
214
+ return typeof value === "object" && value !== null && !Array.isArray(value);
215
+ }
216
+ function camel$1(name) {
217
+ return name.replaceAll(/[-_]([a-z0-9])/g, (_, c) => c.toUpperCase());
218
+ }
219
+ function pascal$1(name) {
220
+ const camelled = camel$1(name);
221
+ return camelled.charAt(0).toUpperCase() + camelled.slice(1);
222
+ }
223
+ function union(values) {
224
+ return [...new Set(values)].toSorted().map((value) => q(value)).join(" | ");
225
+ }
226
+ /**
227
+ * A template with `{placeholders}` as an arrow function over their values: `(v:
228
+ * { readonly userId: string }) => \`notifications:${v.userId}\``. `rename` maps
229
+ * a placeholder to the property the caller passes.
230
+ */
231
+ function templateFunction(template, rename = (name) => name, value = "string") {
232
+ const names = [];
233
+ let body = "";
234
+ let last = 0;
235
+ for (const match of template.matchAll(PLACEHOLDER)) {
236
+ const name = rename(match[2] ?? "");
237
+ if (!names.includes(name)) names.push(name);
238
+ body += `${literalPart(template.slice(last, match.index))}\${String(v.${name})}`;
239
+ last = match.index + match[0].length;
240
+ }
241
+ body += literalPart(template.slice(last));
242
+ if (names.length === 0) return `() => ${q(template)}`;
243
+ return `(v: { ${names.map((name) => `readonly ${name}: ${value}`).join("; ")} }) => \`${body}\``;
244
+ }
245
+ function literalPart(text) {
246
+ return text.replaceAll(/[`\\]|\$\{/g, (match) => `\\${match}`);
247
+ }
248
+ /** Permission keys by owner (block, subject or app table), then action. */
249
+ function permissionGroups(config) {
250
+ const groups = {};
251
+ for (const entry of modulePermissionKeys(config.blocks, config.blockNames, config.subjects)) groups[entry.module] = {
252
+ ...groups[entry.module],
253
+ [entry.action]: entry.key
254
+ };
255
+ for (const [name, subject] of Object.entries(config.subjects)) if (subject.permissions) groups[name] = {
256
+ ...groups[name],
257
+ ...Object.fromEntries(Object.entries(subject.permissions).flatMap(([action, value]) => {
258
+ const key = typeof value === "string" ? value : value.key;
259
+ return key === void 0 ? [] : [[action, key]];
260
+ }))
261
+ };
262
+ for (const table of Object.values(config.appTables)) {
263
+ const subject = table.subject;
264
+ if (subject?.permissions) groups[subject.type] = {
265
+ ...groups[subject.type],
266
+ ...subject.permissions
267
+ };
268
+ }
269
+ return groups;
270
+ }
271
+ /** Whether `blocks.generated.ts` exports `permissions`. */
272
+ function hasPermissionConstants(config) {
273
+ return Object.values(permissionGroups(config)).some((group) => Object.keys(group).length > 0);
274
+ }
275
+ function permissionLines(config) {
276
+ const groups = permissionGroups(config);
277
+ const keys = Object.values(groups).flatMap((group) => Object.values(group));
278
+ if (keys.length === 0) return [];
279
+ return [
280
+ "",
281
+ "/**",
282
+ " * The permission keys the installed blocks, subjects and app tables check,",
283
+ " * by owner and action.",
284
+ " * @public",
285
+ " */",
286
+ "export const permissions = {",
287
+ ...Object.entries(groups).toSorted(([a], [b]) => a.localeCompare(b)).flatMap(([owner, actions]) => [
288
+ ` ${prop(owner)}: {`,
289
+ ...Object.entries(actions).map(([action, key]) => ` ${prop(action)}: ${q(key)},`),
290
+ " },"
291
+ ]),
292
+ "} as const;",
293
+ "",
294
+ "/**",
295
+ " * Every permission key, for `defineAuthorizer<PermissionKey>()` and",
296
+ " * the `permission` of actions and routes.",
297
+ " * @public",
298
+ " */",
299
+ `export type PermissionKey = ${union(keys)};`
300
+ ];
301
+ }
302
+ function roleLines(config, entries) {
303
+ if (entries["permissions"] === void 0) return [];
304
+ const access = config.blocks.permissions;
305
+ const settings = typeof access === "object" ? access : void 0;
306
+ if ((settings?.model ?? "roles") !== "roles") return [];
307
+ const roles = settings?.roles ?? DEFAULT_ROLES;
308
+ return [
309
+ "",
310
+ "/** The roles `blocks.permissions.roles` defines. @public */",
311
+ `export type RoleName = ${union(Object.keys(roles))};`
312
+ ];
313
+ }
314
+ function blockEventLists(entries) {
315
+ return PRESET_CATALOG.manifests.flatMap((manifest) => {
316
+ const events = manifest.events;
317
+ const client = manifest.client;
318
+ if (events === void 0 || !client) return [];
319
+ const lists = Object.entries(entries).filter(([key, entry]) => (entry.block ?? key) === manifest.name).map(([key, entry]) => {
320
+ const renames = entry.names?.entities ?? [];
321
+ const names = entityNames(renames);
322
+ const type = renames.length === 0 ? events.type : key === manifest.name ? names.rename(events.type) : `${pascalOf(key)}Events`;
323
+ return {
324
+ specifier: renames.length === 0 ? `import type { ${events.type} } from ${q(client.subpath)};` : "",
325
+ type,
326
+ types: events.types.map((each) => names.rename(each))
327
+ };
328
+ });
329
+ return lists.filter((list, index) => lists.findIndex((other) => other.type === list.type) === index);
330
+ });
331
+ }
332
+ function pascalOf(instance) {
333
+ const camel = instance.replaceAll(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
334
+ return camel.charAt(0).toUpperCase() + camel.slice(1);
335
+ }
336
+ function eventLines(entries) {
337
+ const lists = blockEventLists(entries);
338
+ if (lists.length === 0) return {
339
+ specifiers: [],
340
+ imports: [],
341
+ lines: []
342
+ };
343
+ const types = [...new Set(lists.flatMap((list) => list.types))].toSorted();
344
+ return {
345
+ specifiers: ["type Events"],
346
+ imports: lists.flatMap((list) => list.specifier === "" ? [] : [list.specifier]),
347
+ lines: [
348
+ "",
349
+ "/** Every installed block's events: type to data. @public */",
350
+ `export type BlockEvents = ${lists.map((list) => list.type).join(" & ")};`,
351
+ "",
352
+ "/**",
353
+ " * The installed blocks' event types under the configured names, for",
354
+ " * `onBlockEvent` and the sinks.",
355
+ " * @public",
356
+ " */",
357
+ "export const blockEvents: Events<BlockEvents> = {",
358
+ " types: [",
359
+ ...types.map((type) => ` ${q(type)},`),
360
+ " ],",
361
+ "};",
362
+ "",
363
+ "/**",
364
+ " * The block events with an open payload, for AsyncAPI's `cloudEvents.blocks`.",
365
+ " * @public",
366
+ " */",
367
+ "export const blockEventSchemas = {",
368
+ ...types.map((type) => ` ${q(type)}: true,`),
369
+ "} as const;"
370
+ ]
371
+ };
372
+ }
373
+ function urlLines(config, entries) {
374
+ const templates = /* @__PURE__ */ new Map();
375
+ for (const name of Object.keys(entries)) for (const entity of blockEntities(name, config.blocks)) if (entity.url !== void 0) templates.set(camel$1(entity.to.singular), entity.url);
376
+ for (const [type, subject] of Object.entries(config.subjects)) {
377
+ const key = camel$1(type);
378
+ if (subject.url !== void 0 && !templates.has(key)) templates.set(key, subject.url);
379
+ }
380
+ const urls = [...templates].map(([key, template]) => ` ${prop(key)}: ${templateFunction(template, (column) => applyCasing(column, config.casing), "string | number")},`);
381
+ return urls.length === 0 ? [] : [
382
+ "",
383
+ "/**",
384
+ " * The path of each subject type with a `url`: block entities, `records`",
385
+ " * and `tables` subjects.",
386
+ " * @public",
387
+ " */",
388
+ "export const urls = {",
389
+ ...urls,
390
+ "} as const;"
391
+ ];
392
+ }
393
+ function topicLines(entries) {
394
+ const topics = Object.entries(entries).flatMap(([name, entry]) => Object.entries(entry.options).flatMap(([option, value]) => {
395
+ if (!/^(?:topic|[a-z]+Topic)$/.test(option) || typeof value !== "string") return [];
396
+ return [` ${prop(option === "topic" ? camel$1(name) : `${camel$1(name)}${pascal$1(option.replace(/Topic$/, ""))}`)}: ${templateFunction(value)},`];
397
+ }));
398
+ return topics.length === 0 ? [] : [
399
+ "",
400
+ "/** The realtime topics the blocks broadcast on, with their placeholders filled. @public */",
401
+ "export const topics = {",
402
+ ...topics,
403
+ "} as const;"
404
+ ];
405
+ }
406
+ function pathLines(config) {
407
+ const paths = Object.entries(config.buckets).map(([name, bucket]) => {
408
+ const key = prop(camel$1(name));
409
+ return typeof bucket.path === "string" ? ` ${key}: ${templateFunction(bucket.path)},` : ` ${key}: [${bucket.path.map((path) => templateFunction(path)).join(", ")}],`;
410
+ });
411
+ return paths.length === 0 ? [] : [
412
+ "",
413
+ "/** Object paths in each bucket, from `buckets.<name>.path`. @public */",
414
+ "export const paths = {",
415
+ ...paths,
416
+ "} as const;"
417
+ ];
418
+ }
419
+ function optionOf(config, module, option) {
420
+ return config.blockNames.includes(module) || config.blocks[module] !== void 0 ? resolveBlock(config.blocks[module]).options[option] : void 0;
421
+ }
422
+ function settingKeys(config) {
423
+ const option = optionOf(config, "settings", "schemas");
424
+ const schemas = isRecord(option) && isRecord(option["schemas"]) ? option["schemas"] : option;
425
+ if (!isRecord(schemas)) return [];
426
+ return [
427
+ "user",
428
+ "organization",
429
+ "platform"
430
+ ].flatMap((scope) => {
431
+ const keys = schemas[scope];
432
+ return isRecord(keys) ? Object.keys(keys) : [];
433
+ });
434
+ }
435
+ function meterNames(config) {
436
+ const option = optionOf(config, "usage", "meters");
437
+ return isRecord(option) && typeof option["table"] !== "string" ? Object.keys(option) : [];
438
+ }
439
+ function keyUnionLines(config) {
440
+ return [[
441
+ "SettingKey",
442
+ "`blocks.settings.options.schemas`",
443
+ settingKeys(config)
444
+ ], [
445
+ "MeterName",
446
+ "`blocks.usage.options.meters`",
447
+ meterNames(config)
448
+ ]].flatMap(([name, source, keys]) => keys.length === 0 ? [] : [
449
+ "",
450
+ `/** The keys ${source} names. @public */`,
451
+ `export type ${name} = ${union(keys)};`
452
+ ]);
453
+ }
454
+ /**
455
+ * The constants app code references by name, from the config: permission keys,
456
+ * role names, block events, entity URLs, realtime topics, bucket paths, and the
457
+ * settings and meter keys.
458
+ */
459
+ function nameConstantLines(config, entries) {
460
+ const events = eventLines(entries);
461
+ return {
462
+ specifiers: events.specifiers,
463
+ imports: events.imports,
464
+ lines: [
465
+ ...permissionLines(config),
466
+ ...roleLines(config, entries),
467
+ ...events.lines,
468
+ ...urlLines(config, entries),
469
+ ...topicLines(entries),
470
+ ...pathLines(config),
471
+ ...keyUnionLines(config)
472
+ ]
473
+ };
474
+ }
475
+ // src/cli/gen/comment.ts
476
+ /**
477
+ * The metadata a `COMMENT ON` adds to a table or column: its description,
478
+ * without the `@example` lines the validator generators read, and `deprecated`
479
+ * when a line starts with `@deprecated`. The library's `parseComment`
480
+ * (`src/generators/shared.ts`) reads comments the same way.
481
+ */
482
+ function commentMeta(comment) {
483
+ if (!comment) return {};
484
+ const deprecated = /^\s*@deprecated\b/m.test(comment);
485
+ const description = comment.replaceAll(/^\s*@example\s+(.+?)\s*$/gm, "").replaceAll(/^\s*@deprecated\b.*$/gm, "").trim();
486
+ return {
487
+ ...description ? { description } : {},
488
+ ...deprecated ? { deprecated: true } : {}
489
+ };
490
+ }
491
+ // src/cli/gen/model-functions.ts
492
+ const NOT_NULL_TAG = /@notNull(?:\(([^)]*)\))?/u;
493
+ /**
494
+ * The `@notNull` tag in a function's comment: `true` for every result, or the
495
+ * columns `@notNull(a, b)` names. `undefined` without a tag.
496
+ */
497
+ function notNullTag(comment) {
498
+ const match = comment === void 0 ? null : NOT_NULL_TAG.exec(comment);
499
+ if (!match) return;
500
+ const list = match[1];
501
+ return list === void 0 ? true : list.split(",").map((name) => name.trim()).filter((name) => name !== "");
502
+ }
503
+ /** The callable functions; warns about functions another schema shadows. */
504
+ function buildFunctions(ctx, tableModels) {
505
+ const { config, catalog, enumsByName, tsType, warnings } = ctx;
506
+ const tablesByName = new Map(tableModels.map((table) => [`${table.snapshot.schema}.${table.snapshot.name}`, table]));
507
+ const callable = catalog.functions.filter((fn) => config.schemas.includes(fn.schema)).filter((fn) => fn.returns !== "trigger" && fn.returns !== "event_trigger").filter((fn) => !fn.args.some((arg) => arg.udt === "internal"));
508
+ const ownerSchema = /* @__PURE__ */ new Map();
509
+ for (const schema of config.schemas) for (const fn of callable) if (fn.schema === schema && !ownerSchema.has(fn.name)) ownerSchema.set(fn.name, schema);
510
+ const shadowed = /* @__PURE__ */ new Set();
511
+ const unpromised = [];
512
+ const functions = callable.filter((fn) => {
513
+ if (ownerSchema.get(fn.name) === fn.schema) return true;
514
+ shadowed.add(`${fn.schema}.${fn.name}`);
515
+ return false;
516
+ }).map((fn) => {
517
+ const typeOf = (format, typeSchema) => {
518
+ const isArray = format.startsWith("_");
519
+ const values = enumsByName.get(`${typeSchema ?? fn.schema}.${isArray ? format.slice(1) : format}`);
520
+ if (values) return isArray ? arrayOf(enumType(values)) : enumType(values);
521
+ return tsType(fn.schema, format, typeSchema);
522
+ };
523
+ const configured = configFor(config.functions, fn.schema, fn.name)?.notNull;
524
+ const notNull = configured ?? notNullTag(fn.comment);
525
+ const source = configured === void 0 ? `the @notNull tag on ${fn.schema}.${fn.name}` : `functions.${fn.name}.notNull`;
526
+ const notNullColumns = new Set(Array.isArray(notNull) ? notNull : []);
527
+ if (Array.isArray(notNull)) {
528
+ for (const name of notNullColumns) if (!fn.returnsTable?.some((column) => column.name === name)) throw new TypeError(`${source}: "${name}" is not a column the function returns`);
529
+ }
530
+ const orNull = (type, column) => notNull === true || column !== void 0 && notNullColumns.has(column) || type === "undefined" || type === "Json" || type === "unknown" ? type : `${type} | null`;
531
+ let returns;
532
+ let result;
533
+ const rowTable = fn.returnsRelation ? tablesByName.get(fn.returnsRelation) : void 0;
534
+ if (fn.returnsTable) {
535
+ const columns = fn.returnsTable.map((column) => {
536
+ const codec = codecFor(column.udt, config);
537
+ const tsType = codec ? CODEC_TYPE[codec] : typeOf(column.udt, column.typeSchema);
538
+ return {
539
+ db: column.name,
540
+ app: applyCasing(column.name, config.casing),
541
+ codec,
542
+ tsType: column.notNull ? tsType : orNull(tsType, column.name)
543
+ };
544
+ });
545
+ if (notNull === void 0 && columns.some((column) => column.tsType.endsWith(" | null"))) unpromised.push(`${fn.schema}.${fn.name}`);
546
+ returns = `{ ${columns.map((column) => `${JSON.stringify(column.app)}: ${column.tsType}`).join("; ")} }[]`;
547
+ if (columns.some((column) => column.codec !== void 0 || column.app !== column.db)) result = { columns: columns.map(({ db, app, codec }) => ({
548
+ db,
549
+ ...app === db ? {} : { name: app },
550
+ ...codec ? { codec } : {}
551
+ })) };
552
+ } else if (rowTable) {
553
+ returns = `Models[${JSON.stringify(rowTable.key)}]['Row']`;
554
+ returns = fn.returnsSet ? arrayOf(returns) : orNull(returns);
555
+ if (rowTable.columns.some((column) => column.codec !== void 0 || column.app !== column.db)) result = { table: rowTable.key };
556
+ } else {
557
+ returns = orNull(typeOf(fn.returns, fn.returnsSchema));
558
+ if (fn.returnsSet) returns = arrayOf(returns);
559
+ }
560
+ return {
561
+ key: fn.name,
562
+ meta: {
563
+ name: fn.name,
564
+ schema: fn.schema,
565
+ args: fn.args.map((arg) => ({
566
+ name: arg.name,
567
+ type: arg.udt
568
+ })),
569
+ returns: fn.returns,
570
+ returnsSet: fn.returnsSet,
571
+ volatility: fn.volatility,
572
+ ...result ? { result } : {}
573
+ },
574
+ args: fn.args.map((arg) => ({
575
+ name: arg.name,
576
+ tsType: typeOf(arg.isArray ? `_${arg.udt}` : arg.udt, arg.typeSchema),
577
+ optional: arg.hasDefault,
578
+ values: enumsByName.get(`${arg.typeSchema ?? fn.schema}.${arg.udt}`)
579
+ })),
580
+ returns
581
+ };
582
+ });
583
+ for (const name of Object.keys(config.functions)) if (!functions.some((fn) => fn.key === name || `${fn.meta.schema}.${fn.key}` === name)) throw new TypeError(`functions.${name}: no function "${name}" in ${config.schemas.join(", ")}`);
584
+ if (unpromised.length > 0) {
585
+ const names = [...new Set(unpromised)];
586
+ ctx.notices.push(`Notice: Postgres can't declare a \`returns table\` column not null, so ${names.length === 1 ? "this function's columns are" : `the columns of these ${names.length} functions are`} typed \`| null\`: ${names.join(", ")}. Name the columns that are never null with an \`@notNull(a, b)\` tag in the function's comment or with \`gen.functions.<name>.notNull\`; \`notNull: []\` keeps them all nullable and silences this notice.`);
587
+ }
588
+ for (const id of shadowed) {
589
+ const name = id.slice(id.indexOf(".") + 1);
590
+ warnings.push(`${id}: ${ownerSchema.get(name) ?? ""}.${name} has the same name and comes first in \`schemas\`, so ${id} gets no \`$rpc\` types.`);
591
+ }
592
+ return functions;
593
+ }
594
+ // src/cli/gen/model-relations.ts
595
+ function buildRelations(ctx, tables) {
596
+ const { config, keyOf } = ctx;
597
+ const byKey = /* @__PURE__ */ new Map();
598
+ for (const entry of tables) byKey.set(`${entry.table.schema}.${entry.table.name}`, entry);
599
+ const appName = (schema, table, column) => {
600
+ return byKey.get(`${schema}.${table}`)?.byDb.get(column)?.app ?? column;
601
+ };
602
+ const relations = /* @__PURE__ */ new Map();
603
+ const push = (tableId, relation) => {
604
+ const list = relations.get(tableId);
605
+ if (list) list.push(relation);
606
+ else relations.set(tableId, [relation]);
607
+ };
608
+ for (const { table, casing, byDb: own } of tables) {
609
+ const sourceId = `${table.schema}.${table.name}`;
610
+ for (const fk of table.foreignKeys) {
611
+ const targetId = `${fk.refSchema}.${fk.refTable}`;
612
+ const target = byKey.get(targetId);
613
+ if (!target) continue;
614
+ const targetKey = keyOf.get(targetId) ?? fk.refTable;
615
+ const sourceColumns = fk.columns.map((column) => appName(table.schema, table.name, column));
616
+ const targetColumns = fk.refColumns.map((column) => appName(fk.refSchema, fk.refTable, column));
617
+ const nullable = config.relations.nullableUnderRls && target.table.rls || fk.columns.some((column) => own.get(column)?.nullable ?? true);
618
+ const onDelete = fk.onDelete === "cascade" || fk.onDelete === "set null" || fk.onDelete === "set default" ? { onDelete: fk.onDelete } : {};
619
+ const naming = namingColumns(fk.columns, fk.refColumns);
620
+ const [only] = naming;
621
+ const forwardBase = naming.length === 1 && only?.endsWith("_id") ? only.slice(0, -3) : singular(fk.refTable);
622
+ push(sourceId, {
623
+ name: applyCasing(forwardBase, casing),
624
+ base: forwardBase,
625
+ fkColumns: fk.columns,
626
+ refColumns: fk.refColumns,
627
+ meta: {
628
+ table: targetKey,
629
+ kind: "one",
630
+ nullable,
631
+ foreignKey: fk.name,
632
+ columns: sourceColumns,
633
+ references: targetColumns,
634
+ direction: "forward",
635
+ ...onDelete
636
+ }
637
+ });
638
+ const unique = fk.oneToOne || sameColumns(table.primaryKey, fk.columns) || table.uniques.some((key) => sameColumns(key.columns, fk.columns));
639
+ const reverseBase = unique ? singular(table.name) : table.name;
640
+ push(targetId, {
641
+ name: applyCasing(reverseBase, target.casing),
642
+ base: reverseBase,
643
+ fkColumns: fk.columns,
644
+ refColumns: fk.refColumns,
645
+ meta: {
646
+ table: keyOf.get(sourceId) ?? table.name,
647
+ kind: unique ? "one" : "many",
648
+ nullable: true,
649
+ foreignKey: fk.name,
650
+ columns: targetColumns,
651
+ references: sourceColumns,
652
+ direction: "reverse",
653
+ ...onDelete
654
+ }
655
+ });
656
+ }
657
+ }
658
+ return relations;
659
+ }
660
+ /**
661
+ * The columns that name a relation. A composite key that repeats a column on
662
+ * both sides, such as `(customer_id, organization_id)` referencing `(id,
663
+ * organization_id)` to keep rows in one tenant, is named by the rest.
664
+ */
665
+ function namingColumns(columns, references) {
666
+ const own = columns.filter((column, index) => column !== references[index]);
667
+ return own.length > 0 ? own : columns;
668
+ }
669
+ // src/cli/gen/model.ts
670
+ const SOFT_DELETE_UDTS = /* @__PURE__ */ new Set(["timestamptz", "timestamp"]);
671
+ /** The overloads of each function name, in model order. */
672
+ function functionGroups(functions) {
673
+ const groups = /* @__PURE__ */ new Map();
674
+ for (const fn of functions) {
675
+ const group = groups.get(fn.key);
676
+ if (group) group.push(fn);
677
+ else groups.set(fn.key, [fn]);
678
+ }
679
+ return groups;
680
+ }
681
+ function signatureOf(fn) {
682
+ const { name: _name, schema: _schema, ...signature } = fn.meta;
683
+ return {
684
+ ...signature,
685
+ args: signature.args.map((arg, index) => fn.args[index]?.optional ? {
686
+ ...arg,
687
+ optional: true
688
+ } : arg)
689
+ };
690
+ }
691
+ function tableKey(table, casing, schemas) {
692
+ const base = applyCasing(table.name, casing);
693
+ if (schemas.length === 1 || table.schema === "public") return base;
694
+ return applyCasing(`${table.schema}_${table.name}`, casing);
695
+ }
696
+ const TEXT_UDTS = /* @__PURE__ */ new Set([
697
+ "text",
698
+ "varchar",
699
+ "bpchar"
700
+ ]);
701
+ /**
702
+ * `config.storagePaths` resolved to bucket ids, with a check that every key is
703
+ * used.
704
+ */
705
+ function numberedColumnsOf(config) {
706
+ const columns = /* @__PURE__ */ new Map();
707
+ const block = config.blocks["numbering"];
708
+ if (!config.blockNames.includes("numbering") || block?.mode === "custom" || !isRecord$1(block?.options?.["entities"])) return columns;
709
+ for (const entry of Object.values(block.options["entities"])) {
710
+ if (!isRecord$1(entry) || typeof entry["table"] !== "string" || typeof entry["column"] !== "string") continue;
711
+ const key = entry["table"].includes(".") ? entry["table"] : `public.${entry["table"]}`;
712
+ const set = columns.get(key) ?? /* @__PURE__ */ new Set();
713
+ set.add(entry["column"]);
714
+ if (typeof entry["sequenceColumn"] === "string") set.add(entry["sequenceColumn"]);
715
+ columns.set(key, set);
716
+ }
717
+ return columns;
718
+ }
719
+ function storagePathsOf(config) {
720
+ const bucketId = (name) => {
721
+ const bucket = config.buckets[name];
722
+ if (!bucket) return name;
723
+ return bucket.id ?? name.replaceAll(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
724
+ };
725
+ const unused = new Set(Object.keys(config.storagePaths));
726
+ return {
727
+ lookup(schema, table, column, udt) {
728
+ const key = [`${schema}.${table}.${column}`, `${table}.${column}`].find((candidate) => candidate in config.storagePaths);
729
+ if (key === void 0) return;
730
+ unused.delete(key);
731
+ if (!TEXT_UDTS.has(udt)) throw new TypeError(`storagePaths["${key}"]: ${schema}.${table}.${column} is ${udt}, not a text column`);
732
+ return bucketId(config.storagePaths[key]);
733
+ },
734
+ assertUsed() {
735
+ const [first] = unused;
736
+ if (first !== void 0) throw new TypeError(`storagePaths["${first}"]: no such column. Use \`table.column\` or \`schema.table.column\` (database names) in \`schemas\`.`);
737
+ }
738
+ };
739
+ }
740
+ function prepareCatalog(snapshot, config) {
741
+ const catalog = toCatalog(snapshot);
742
+ const introspection = restrictSchemas(snapshot.generator, config.schemas);
743
+ const tsType = (schema, format, typeSchema) => tsTypeOf(introspection, schema, format, typeSchema).replaceAll(/\(([\w.$]+)\)\[\]/g, "$1[]");
744
+ const enumsByName = /* @__PURE__ */ new Map();
745
+ for (const entry of catalog.enums) enumsByName.set(`${entry.schema}.${entry.name}`, entry.values);
746
+ const jsonImports = /* @__PURE__ */ new Map();
747
+ const unusedJson = new Set(Object.keys(config.json));
748
+ const jsonTypeFor = (schema, table, column) => {
749
+ const key = [`${schema}.${table}.${column}`, `${table}.${column}`].find((candidate) => candidate in config.json);
750
+ const override = key === void 0 ? void 0 : config.json[key];
751
+ if (key === void 0 || !override) return;
752
+ unusedJson.delete(key);
753
+ if ("type" in override) return override.type;
754
+ const [from, name] = override.import.split("#");
755
+ if (!from || !name) throw new TypeError(`json["${key}"].import must look like "./path.ts#TypeName"`);
756
+ jsonImports.set(name, {
757
+ name,
758
+ from
759
+ });
760
+ return name;
761
+ };
762
+ const optionsOf = (table) => configFor(config.tables, table.schema, table.name);
763
+ const included = catalog.tables.filter((table) => config.schemas.includes(table.schema) && !optionsOf(table)?.exclude);
764
+ const keyOf = /* @__PURE__ */ new Map();
765
+ const ownerOf = /* @__PURE__ */ new Map();
766
+ for (const table of included) {
767
+ const id = `${table.schema}.${table.name}`;
768
+ const key = tableKey(table, config.casing, config.schemas);
769
+ const other = ownerOf.get(key);
770
+ if (other !== void 0) throw new TypeError(`${other} and ${id} both generate the model key "${key}". Exclude one with \`tables["${id}"].exclude\`, or rename one of the tables.`);
771
+ ownerOf.set(key, id);
772
+ keyOf.set(id, key);
773
+ }
774
+ return {
775
+ config,
776
+ catalog,
777
+ introspection,
778
+ enumsByName,
779
+ jsonImports,
780
+ unusedJson,
781
+ included,
782
+ keyOf,
783
+ warnings: [],
784
+ notices: [],
785
+ tsType,
786
+ jsonTypeFor,
787
+ optionsOf
788
+ };
789
+ }
790
+ function draftTables(ctx) {
791
+ const { config, included, enumsByName, tsType, jsonTypeFor, optionsOf } = ctx;
792
+ const storagePaths = storagePathsOf(config);
793
+ const numbered = numberedColumnsOf(config);
794
+ const tables = included.map((table) => {
795
+ const casing = optionsOf(table)?.casing ?? config.casing;
796
+ const checks = /* @__PURE__ */ new Map();
797
+ const checkedNotNull = /* @__PURE__ */ new Set();
798
+ for (const check of table.checks) {
799
+ const union = parseCheckUnion(check.definition);
800
+ if (union) checks.set(union.column, union.values);
801
+ for (const column of parseCheckNotNull(check.definition)) checkedNotNull.add(column);
802
+ }
803
+ const fillers = table.triggers.filter((trigger) => trigger.timing === "before" && trigger.level === "row" && trigger.events.includes("insert"));
804
+ const insertOptional = new Set(optionsOf(table)?.insertOptional);
805
+ const numberedColumns = numbered.get(`${table.schema}.${table.name}`);
806
+ for (const name of insertOptional) if (!table.columns.some((column) => column.name === name)) throw new TypeError(`tables.${table.name}.insertOptional: "${name}" is not a column of ${table.schema}.${table.name}`);
807
+ const columns = table.columns.map((column) => {
808
+ const values = (column.isEnum ? enumsByName.get(`${column.typeSchema}.${column.udt}`) : void 0) ?? checks.get(column.name);
809
+ const appColumn = table.schema === "public" ? config.appTables[table.name]?.columns?.[column.name] : void 0;
810
+ const sealed = appColumn?.encrypted === true ? APP_COLUMN_UDT[appColumn.type] : void 0;
811
+ const udt = sealed ?? column.udt;
812
+ const format = sealed ?? column.format;
813
+ const json = isJsonUdt(udt);
814
+ const override = json ? jsonTypeFor(table.schema, table.name, column.name) : void 0;
815
+ const storage = storagePaths.lookup(table.schema, table.name, column.name, udt);
816
+ const codec = override || values || storage ? void 0 : codecFor(udt, config);
817
+ const base = override ?? (values ? enumType(values) : storage ? `StoragePath<${JSON.stringify(storage)}>` : codec ? CODEC_TYPE[codec] : void 0);
818
+ const columnType = base === void 0 ? tsType(table.schema, format, sealed === void 0 ? column.typeSchema : "pg_catalog") : column.isArray ? arrayOf(base) : base;
819
+ const readonly = column.generated || column.identity === "always";
820
+ const narrowed = column.nullable && checkedNotNull.has(column.name);
821
+ const nullable = column.nullable && !narrowed;
822
+ const filled = column.hasDefault || insertOptional.has(column.name) || (numberedColumns?.has(column.name) ?? false) || narrowed && fillers.some((trigger) => trigger.fills?.includes(column.name) ?? true);
823
+ const insertable = !readonly && table.insertable && (table.kind !== "view" || column.updatable);
824
+ const updatable = !readonly && table.updatable && column.updatable;
825
+ return {
826
+ ...appColumn?.access === "server" || appColumn?.encrypted === true ? { selectable: false } : {},
827
+ app: applyCasing(column.name, casing),
828
+ db: column.name,
829
+ snapshot: column,
830
+ tsType: columnType,
831
+ nullable,
832
+ filled,
833
+ optional: nullable || filled || readonly,
834
+ readonly,
835
+ values,
836
+ json,
837
+ codec,
838
+ storage,
839
+ insertable,
840
+ updatable
841
+ };
842
+ });
843
+ const byApp = /* @__PURE__ */ new Map();
844
+ for (const column of columns) {
845
+ const other = byApp.get(column.app);
846
+ if (other !== void 0) throw new TypeError(`${table.schema}.${table.name}: columns "${other}" and "${column.db}" both become "${column.app}". Rename one, or set \`tables["${table.schema}.${table.name}"].casing: "snake"\`.`);
847
+ byApp.set(column.app, column.db);
848
+ }
849
+ return {
850
+ table,
851
+ casing,
852
+ columns,
853
+ byDb: new Map(columns.map((column) => [column.db, column]))
854
+ };
855
+ });
856
+ storagePaths.assertUsed();
857
+ return tables;
858
+ }
859
+ /** Config entries that match no table or column. */
860
+ function configWarnings(ctx) {
861
+ const { config, catalog, unusedJson } = ctx;
862
+ const schemasOf = /* @__PURE__ */ new Map();
863
+ for (const table of catalog.tables) {
864
+ if (!config.schemas.includes(table.schema)) continue;
865
+ schemasOf.set(table.name, [...schemasOf.get(table.name) ?? [], table.schema]);
866
+ }
867
+ const known = (key) => {
868
+ const dot = key.indexOf(".");
869
+ if (dot === -1) return schemasOf.has(key);
870
+ return schemasOf.get(key.slice(dot + 1))?.includes(key.slice(0, dot)) ?? false;
871
+ };
872
+ return [
873
+ ...Object.keys(config.tables).filter((name) => !known(name)).map((name) => `tables["${name}"]: no table by that name in ${config.schemas.join(", ")}, so the entry does nothing.`),
874
+ ...Object.keys(config.tables).flatMap((name) => {
875
+ const shared = (schemasOf.get(name) ?? []).filter((schema) => !(`${schema}.${name}` in config.tables)).map((schema) => `${schema}.${name}`);
876
+ return shared.length > 1 ? [`tables["${name}"]: ${shared.join(" and ")} share the name, so the entry applies to each. Key it \`schema.table\` to pick one.`] : [];
877
+ }),
878
+ ...[...unusedJson].map((key) => `json["${key}"]: no json or jsonb column by that name, so the type is not used. Keys are \`table.column\` or \`schema.table.column\` with database names.`)
879
+ ];
880
+ }
881
+ function toTableModels(ctx, tables, relations) {
882
+ const { config, keyOf, optionsOf } = ctx;
883
+ const flagsConfig = config.extensions;
884
+ const subjectDeletedAt = /* @__PURE__ */ new Map();
885
+ const subjectTenant = /* @__PURE__ */ new Map();
886
+ for (const [type, subject] of Object.entries(config.subjects)) {
887
+ const table = subject.table.includes(".") ? subject.table : `public.${subject.table}`;
888
+ if (typeof subject.tenant === "string") subjectTenant.set(table, subject.tenant);
889
+ if (subject.deletedAt !== void 0) subjectDeletedAt.set(table, {
890
+ db: subject.deletedAt,
891
+ source: `subjects.${type}.deletedAt`
892
+ });
893
+ }
894
+ return tables.map(({ table, casing, columns, byDb }) => {
895
+ const id = `${table.schema}.${table.name}`;
896
+ const renames = optionsOf(table)?.relations ?? {};
897
+ const columnNames = new Set(columns.map((column) => column.app));
898
+ const list = dedupeRelations(relations.get(id) ?? [], columnNames, casing).map((relation) => ({
899
+ ...relation,
900
+ name: renames[relation.name] ?? relation.name
901
+ }));
902
+ const has = (db) => byDb.get(db)?.app;
903
+ const flags = {};
904
+ const subjectColumn = subjectDeletedAt.get(id);
905
+ const softDelete = subjectColumn !== void 0 && byDb.has(subjectColumn.db) ? subjectColumn : flagsConfig.softDelete ? {
906
+ db: flagsConfig.softDelete.column,
907
+ source: "blocks.trash.options.deletedAt"
908
+ } : void 0;
909
+ const softDeleteColumn = softDelete && byDb.get(softDelete.db);
910
+ if (softDelete && softDeleteColumn) {
911
+ const udt = softDeleteColumn.snapshot.udt;
912
+ if (softDeleteColumn.snapshot.isArray || !SOFT_DELETE_UDTS.has(udt)) throw new TypeError(`${softDelete.source}: ${id}.${softDelete.db} is ${udt}, but the trash extension writes a timestamp. Use timestamptz or timestamp.`);
913
+ flags.softDelete = softDeleteColumn.app;
914
+ }
915
+ if (flagsConfig.timestamps) {
916
+ const createdAt = has(flagsConfig.timestamps.createdAt);
917
+ const updatedAt = has(flagsConfig.timestamps.updatedAt);
918
+ if (createdAt || updatedAt) flags.timestamps = {
919
+ ...createdAt ? { createdAt } : {},
920
+ ...updatedAt ? { updatedAt } : {}
921
+ };
922
+ }
923
+ if (flagsConfig.tenant) {
924
+ const mapped = subjectTenant.get(id);
925
+ const column = (mapped === void 0 ? void 0 : has(mapped)) ?? has(flagsConfig.tenant.column);
926
+ if (column) flags.tenant = column;
927
+ }
928
+ if (flagsConfig.actor) {
929
+ const createdBy = has(flagsConfig.actor.createdBy);
930
+ const updatedBy = has(flagsConfig.actor.updatedBy);
931
+ const impersonatedBy = has(flagsConfig.actor.impersonatedBy);
932
+ if (createdBy || updatedBy || impersonatedBy) flags.actor = {
933
+ ...createdBy ? { createdBy } : {},
934
+ ...updatedBy ? { updatedBy } : {},
935
+ ...impersonatedBy ? { impersonatedBy } : {}
936
+ };
937
+ }
938
+ const key = keyOf.get(id) ?? table.name;
939
+ const columnMeta = {};
940
+ for (const column of columns) {
941
+ const meta = {
942
+ db: column.db,
943
+ type: column.snapshot.udt,
944
+ nullable: column.nullable,
945
+ hasDefault: column.filled
946
+ };
947
+ if (column.readonly) meta.generated = true;
948
+ if (column.snapshot.identity) meta.identity = column.snapshot.identity;
949
+ if (!column.readonly && !column.insertable) meta.insertable = false;
950
+ if (!column.readonly && !column.updatable) meta.updatable = false;
951
+ if (column.selectable === false) meta.selectable = false;
952
+ if (column.snapshot.isArray) meta.array = true;
953
+ if (column.json) meta.json = true;
954
+ if (column.values) meta.enum = column.values;
955
+ if (column.codec) meta.codec = column.codec;
956
+ if (column.storage) meta.storage = column.storage;
957
+ if (config.sensitive.includes(`${table.name}.${column.db}`) || config.sensitive.includes(`${table.schema}.${table.name}.${column.db}`)) meta.sensitive = true;
958
+ Object.assign(meta, commentMeta(column.snapshot.comment));
959
+ columnMeta[column.app] = meta;
960
+ }
961
+ const app = (db) => byDb.get(db)?.app ?? db;
962
+ const uniqueKeys = {};
963
+ for (const unique of table.uniques) uniqueKeys[unique.name] = unique.columns.map(app);
964
+ const relationMeta = {};
965
+ for (const relation of list) relationMeta[relation.name] = relation.meta;
966
+ return {
967
+ key,
968
+ snapshot: table,
969
+ casing,
970
+ columns,
971
+ relations: list,
972
+ meta: {
973
+ key,
974
+ name: table.name,
975
+ schema: table.schema,
976
+ kind: table.kind,
977
+ columns: columnMeta,
978
+ primaryKey: table.primaryKey.map(app),
979
+ uniqueKeys,
980
+ relations: relationMeta,
981
+ flags,
982
+ ...commentMeta(table.comment)
983
+ }
984
+ };
985
+ });
986
+ }
987
+ function buildEnums(ctx) {
988
+ const { config, catalog } = ctx;
989
+ const includedEnums = catalog.enums.filter((entry) => config.schemas.includes(entry.schema));
990
+ const enumNameCount = /* @__PURE__ */ new Map();
991
+ for (const entry of includedEnums) enumNameCount.set(entry.name, (enumNameCount.get(entry.name) ?? 0) + 1);
992
+ return includedEnums.map((entry) => {
993
+ const key = entry.schema !== "public" && (enumNameCount.get(entry.name) ?? 0) > 1 ? `${entry.schema}_${entry.name}` : entry.name;
994
+ return {
995
+ schema: entry.schema,
996
+ name: entry.name,
997
+ key,
998
+ constant: identifier(`${toCamel(key)}Values`),
999
+ typeName: identifier(pascal$2(key)),
1000
+ values: entry.values
1001
+ };
1002
+ });
1003
+ }
1004
+ function assembleMeta(config, tableModels, enums, functions) {
1005
+ const tablesMeta = {};
1006
+ for (const table of tableModels) tablesMeta[table.key] = table.meta;
1007
+ const enumsMeta = {};
1008
+ for (const entry of enums) enumsMeta[entry.key] = entry.values;
1009
+ const functionsMeta = {};
1010
+ for (const [key, group] of functionGroups(functions)) {
1011
+ const [first] = group;
1012
+ if (!first) continue;
1013
+ functionsMeta[key] = group.length === 1 ? first.meta : {
1014
+ ...first.meta,
1015
+ overloads: group.map(signatureOf)
1016
+ };
1017
+ }
1018
+ const claimOverrides = {};
1019
+ for (const key of Object.keys(DEFAULT_CLAIMS)) if (config.claims[key] !== DEFAULT_CLAIMS[key]) claimOverrides[key] = config.claims[key];
1020
+ const truncatedClaim = providerTruncatedClaim(config.authorization);
1021
+ if (truncatedClaim !== void 0) claimOverrides.permissionsTruncated = truncatedClaim;
1022
+ const tenantClaim = config.claims.tenant === DEFAULT_CLAIMS.tenant ? void 0 : tenantClaimPaths(config.claims.tenant);
1023
+ return {
1024
+ version: 1,
1025
+ casing: config.casing,
1026
+ tables: tablesMeta,
1027
+ enums: enumsMeta,
1028
+ functions: functionsMeta,
1029
+ ...Object.keys(config.buckets).length > 0 ? { buckets: Object.fromEntries(Object.entries(config.buckets).map(([name, bucket]) => [name, {
1030
+ id: bucket.id ?? name.replaceAll(/[A-Z]/g, (char) => `-${char.toLowerCase()}`),
1031
+ public: bucket.public ?? false,
1032
+ path: bucket.path,
1033
+ ...bucket.policy ? { policy: typeof bucket.policy === "string" ? bucket.policy : resolveProviderSql(`buckets.${name}`, bucket.policy, config.authorization?.functions) } : {},
1034
+ ...bucket.policy === "tenant" && tenantClaim ? { tenant: { claim: tenantClaim } } : {},
1035
+ ...bucket.fileSizeLimit ? { fileSizeLimit: bucket.fileSizeLimit } : {},
1036
+ ...bucket.allowedMimeTypes ? { allowedMimeTypes: bucket.allowedMimeTypes } : {},
1037
+ ...bucket.versioning ? { versioning: true } : {},
1038
+ ...bucket.lifecycle ? { lifecycle: bucket.lifecycle } : {}
1039
+ }])) } : {},
1040
+ ...Object.keys(config.topics).length > 0 ? { topics: config.topics } : {},
1041
+ ...config.realtime.tables.length > 0 ? { realtime: realtimeMeta(config.realtime.tables, config.realtime.users, tableModels) } : {},
1042
+ ...Object.keys(claimOverrides).length > 0 ? { claims: claimOverrides } : {}
1043
+ };
1044
+ }
1045
+ /** Builds the codegen model from a snapshot and config. */
1046
+ function buildModel(snapshot, config) {
1047
+ const ctx = prepareCatalog(snapshot, config);
1048
+ const tables = draftTables(ctx);
1049
+ ctx.warnings.push(...configWarnings(ctx));
1050
+ const tableModels = toTableModels(ctx, tables, buildRelations(ctx, tables));
1051
+ const enums = buildEnums(ctx);
1052
+ const functions = buildFunctions(ctx, tableModels);
1053
+ return {
1054
+ tables: tableModels,
1055
+ enums,
1056
+ functions,
1057
+ jsonImports: [...ctx.jsonImports.values()],
1058
+ meta: assembleMeta(config, tableModels, enums, functions),
1059
+ config,
1060
+ catalog: ctx.catalog,
1061
+ introspection: ctx.introspection,
1062
+ warnings: ctx.warnings,
1063
+ notices: ctx.notices
1064
+ };
1065
+ }
1066
+ function deepFreeze(value) {
1067
+ if (typeof value === "object" && value !== null && !Object.isFrozen(value)) {
1068
+ Object.freeze(value);
1069
+ for (const entry of Object.values(value)) deepFreeze(entry);
1070
+ }
1071
+ return value;
1072
+ }
1073
+ /**
1074
+ * The public, frozen view of the model that generators receive, with the
1075
+ * installed blocks `generatorBlocks` lists.
1076
+ */
1077
+ function generatorModel(model, blocks = []) {
1078
+ return deepFreeze({
1079
+ tables: model.tables.map((table) => ({
1080
+ key: table.key,
1081
+ schema: table.snapshot.schema,
1082
+ name: table.snapshot.name,
1083
+ casing: table.casing,
1084
+ columns: table.columns.map((column) => ({
1085
+ app: column.app,
1086
+ db: column.db,
1087
+ tsType: column.tsType,
1088
+ nullable: column.nullable,
1089
+ optional: column.optional,
1090
+ readonly: column.readonly,
1091
+ values: column.values === void 0 ? void 0 : [...column.values],
1092
+ json: column.json
1093
+ }))
1094
+ })),
1095
+ enums: model.enums.map((entry) => ({
1096
+ schema: entry.schema,
1097
+ name: entry.name,
1098
+ values: [...entry.values]
1099
+ })),
1100
+ functions: model.functions.map((fn) => ({
1101
+ key: fn.key,
1102
+ schema: fn.meta.schema,
1103
+ args: fn.args.map((arg) => ({
1104
+ name: arg.name,
1105
+ tsType: arg.tsType,
1106
+ optional: arg.optional,
1107
+ values: arg.values === void 0 ? void 0 : [...arg.values]
1108
+ })),
1109
+ returns: fn.returns,
1110
+ returnsSet: fn.meta.returnsSet,
1111
+ volatility: fn.meta.volatility
1112
+ })),
1113
+ blocks
1114
+ });
1115
+ }
1116
+ /**
1117
+ * Makes relation names unique per table and distinct from column names: two FKs
1118
+ * to the same table become `customersByPrimaryContact`-style names. When those
1119
+ * still collide, the names use every column of the key
1120
+ * (`locationsByCustomerOrganization`), then the constraint name, and only then
1121
+ * a trailing `_`.
1122
+ */
1123
+ function dedupeRelations(list, columns, casing) {
1124
+ const suffixed = (relation, suffix) => applyCasing(`${relation.base}_by_${suffix}`, casing);
1125
+ const keyColumns = (relation, all) => (all ? relation.fkColumns : namingColumns(relation.fkColumns, relation.refColumns)).map((column) => column.replace(/_?[iI]d$/, "")).join("_");
1126
+ const repeated = (names) => {
1127
+ const seen = /* @__PURE__ */ new Set();
1128
+ const twice = /* @__PURE__ */ new Set();
1129
+ for (const name of names) (seen.has(name) ? twice : seen).add(name);
1130
+ return twice;
1131
+ };
1132
+ const plain = repeated(list.map((relation) => relation.name));
1133
+ const names = [(relation) => suffixed(relation, keyColumns(relation, true)), (relation) => suffixed(relation, relation.meta.foreignKey)].reduce((current, step) => {
1134
+ const clash = repeated(current);
1135
+ return list.map((relation, index) => {
1136
+ const name = current[index] ?? relation.name;
1137
+ return clash.has(name) || columns.has(name) ? step(relation) : name;
1138
+ });
1139
+ }, list.map((relation) => plain.has(relation.name) || columns.has(relation.name) ? suffixed(relation, keyColumns(relation, false)) : relation.name));
1140
+ const used = /* @__PURE__ */ new Set();
1141
+ return list.map((relation, index) => {
1142
+ let name = names[index] ?? relation.name;
1143
+ while (used.has(name) || columns.has(name)) name = `${name}_`;
1144
+ used.add(name);
1145
+ return {
1146
+ ...relation,
1147
+ name
1148
+ };
1149
+ });
1150
+ }
1151
+ function realtimeMeta(names, users, tables) {
1152
+ const out = {};
1153
+ for (const name of names) {
1154
+ const table = tables.find((candidate) => candidate.meta.name === name || `${candidate.meta.schema}.${candidate.meta.name}` === name);
1155
+ if (!table) throw new CliError("config_invalid", `database.realtime.tables: unknown table "${name}". Check the name and \`schemas\`.`);
1156
+ const owner = users[name];
1157
+ if (owner !== void 0) {
1158
+ const user = Object.entries(table.meta.columns).find(([, column]) => column.db === owner)?.[0];
1159
+ if (user === void 0) throw new CliError("config_invalid", `database.realtime.users: "${name}" has no column "${owner}".`);
1160
+ out[table.key] = { user };
1161
+ continue;
1162
+ }
1163
+ const tenant = table.meta.flags.tenant;
1164
+ out[table.key] = tenant ? { tenant } : {};
1165
+ }
1166
+ return out;
1167
+ }
1168
+ // src/cli/gen/emit.ts
1169
+ const GENERATED_HEADER = "// @generated by better-supabase gen. Do not edit; run `better-supabase gen` instead.";
1170
+ function rowEntries(columns, name) {
1171
+ return columns.map((column) => `${prop(column[name])}${column.selectable === false ? "?" : ""}: ${nullable(column.tsType, column.nullable)};`);
1172
+ }
1173
+ function insertEntries(columns, name) {
1174
+ return columns.map((column) => {
1175
+ if (!column.insertable) return `${prop(column[name])}?: never;`;
1176
+ const optional = column.optional ? "?" : "";
1177
+ return `${prop(column[name])}${optional}: ${nullable(column.tsType, column.nullable)};`;
1178
+ });
1179
+ }
1180
+ function updateEntries(columns, name) {
1181
+ return columns.map((column) => {
1182
+ if (!column.updatable) return `${prop(column[name])}?: never;`;
1183
+ return `${prop(column[name])}?: ${nullable(column.tsType, column.nullable)};`;
1184
+ });
1185
+ }
1186
+ /**
1187
+ * Postgres passes `null` to any argument, so every argument accepts it. This
1188
+ * only widens what a caller may pass; no result type changes with it. An
1189
+ * optional argument also accepts `undefined`, which `rpc()` leaves out, so
1190
+ * `exactOptionalPropertyTypes` apps can pass a maybe-missing value.
1191
+ */
1192
+ function argEntries(fn) {
1193
+ return fn.args.map((arg) => `${prop(arg.name)}${arg.optional ? "?" : ""}: ${nullable(arg.tsType, true)}${arg.optional ? " | undefined" : ""};`);
1194
+ }
1195
+ function enrichedDatabase(model) {
1196
+ const schemas = model.config.schemas.flatMap((schema) => {
1197
+ const tables = model.tables.filter((t) => t.snapshot.schema === schema).flatMap((table) => {
1198
+ const overrides = table.columns.filter((column) => column.values !== void 0 && !column.snapshot.isEnum || column.json && column.tsType !== "Json" || column.storage !== void 0).map((column) => `${prop(column.db)}: ${column.tsType};`);
1199
+ return overrides.length > 0 ? block(prop(table.snapshot.name), overrides) : [];
1200
+ });
1201
+ return tables.length > 0 ? block(prop(schema), tables) : [];
1202
+ });
1203
+ if (schemas.length === 0) return ["export type Database = SupabaseDatabase;"];
1204
+ return [
1205
+ "export type Database = EnrichDatabase<",
1206
+ " SupabaseDatabase,",
1207
+ " {",
1208
+ ...indent(schemas, 2),
1209
+ " }",
1210
+ ">;"
1211
+ ];
1212
+ }
1213
+ function modelsType(model) {
1214
+ return [
1215
+ "export type Models = {",
1216
+ ...indent(model.tables.flatMap((table) => {
1217
+ const relations = table.relations.map((relation) => `${prop(relation.name)}: { table: ${q(relation.meta.table)}; kind: ${q(relation.meta.kind)}; nullable: ${String(relation.meta.nullable)} };`);
1218
+ const pk = table.meta.primaryKey;
1219
+ const uniques = Object.entries(table.meta.uniqueKeys).map(([name, columns]) => `${prop(name)}: readonly [${columns.map(q).join(", ")}];`);
1220
+ const flags = [];
1221
+ const tableFlags = table.meta.flags;
1222
+ if (tableFlags.softDelete) flags.push(`softDelete: ${q(tableFlags.softDelete)};`);
1223
+ if (tableFlags.timestamps) flags.push("timestamps: true;");
1224
+ if (tableFlags.tenant) flags.push(`tenant: ${q(tableFlags.tenant)};`);
1225
+ if (tableFlags.actor) flags.push("actor: true;");
1226
+ const none = "Record<never, never>";
1227
+ const union = (names) => names.length === 0 ? "never" : names.map(q).join(" | ");
1228
+ return block(prop(table.key), [
1229
+ ...block("Row", rowEntries(table.columns, "app"), none),
1230
+ ...table.snapshot.insertable ? block("Insert", insertEntries(table.columns, "app"), none) : ["Insert: never;"],
1231
+ ...table.snapshot.updatable ? block("Update", updateEntries(table.columns, "app"), none) : ["Update: never;"],
1232
+ ...block("Relations", relations, none),
1233
+ `PrimaryKey: ${union(pk)};`,
1234
+ ...block("UniqueKeys", uniques, none),
1235
+ `Checks: ${union(table.snapshot.checks.map((check) => check.name))};`,
1236
+ `ForeignKeys: ${union(table.snapshot.foreignKeys.map((fk) => fk.name))};`,
1237
+ ...block("Flags", flags, none)
1238
+ ]);
1239
+ }), 1),
1240
+ "};"
1241
+ ];
1242
+ }
1243
+ function functionsType(model) {
1244
+ if (model.functions.length === 0) return ["export type Functions = Record<never, never>;"];
1245
+ return [
1246
+ "export type Functions = {",
1247
+ ...indent([...functionGroups(model.functions)].flatMap(([key, group]) => {
1248
+ const [first] = group;
1249
+ if (group.length === 1 && first) return block(prop(key), [...block("Args", argEntries(first), "Record<never, never>"), `Returns: ${first.returns};`]);
1250
+ return [`${prop(key)}:`, ...indent(group.flatMap((fn, index) => {
1251
+ const lines = [...block("Args", argEntries(fn), "Record<PropertyKey, never>"), `Returns: ${fn.returns};`];
1252
+ const end = index === group.length - 1 ? "};" : "}";
1253
+ return [
1254
+ "| {",
1255
+ ...indent(lines, 1),
1256
+ end
1257
+ ];
1258
+ }), 1)];
1259
+ }), 1),
1260
+ "};"
1261
+ ];
1262
+ }
1263
+ /**
1264
+ * The metadata module next to `generated.ts`: `generated.meta.js` and its
1265
+ * `.d.ts`.
1266
+ */
1267
+ function metaPaths(output) {
1268
+ const base = output.replace(/\.[cm]?[jt]sx?$/, "");
1269
+ return {
1270
+ js: `${base}.meta.js`,
1271
+ dts: `${base}.meta.d.ts`
1272
+ };
1273
+ }
1274
+ /**
1275
+ * JSON with one line per table, function and other named entry, so the module
1276
+ * stays small to load and a schema change still diffs per entry.
1277
+ */
1278
+ function compactJson(meta) {
1279
+ return `{\n${Object.entries(meta).map(([key, value]) => {
1280
+ const name = JSON.stringify(key);
1281
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return ` ${name}: ${JSON.stringify(value)}`;
1282
+ const inner = Object.entries(value).map(([entry, item]) => ` ${JSON.stringify(entry)}: ${JSON.stringify(item)}`);
1283
+ return inner.length === 0 ? ` ${name}: {}` : ` ${name}: {\n${inner.join(",\n")}\n }`;
1284
+ }).join(",\n")}\n}`;
1285
+ }
1286
+ /**
1287
+ * The schema metadata as plain JavaScript plus a one-line declaration, so
1288
+ * TypeScript reads `SchemaMeta` instead of checking thousands of lines of
1289
+ * object literal in every program that imports the generated module.
1290
+ */
1291
+ function emitMeta(model, options = {}) {
1292
+ const runtime = options.runtimeImport ?? "better-supabase";
1293
+ return {
1294
+ js: [
1295
+ GENERATED_HEADER,
1296
+ `// @ts-self-types="${options.types ?? "./generated.meta.d.ts"}"`,
1297
+ "/* oxlint-disable */",
1298
+ "/* eslint-disable */",
1299
+ "",
1300
+ `export default ${compactJson({ ...model.meta })};`,
1301
+ ""
1302
+ ].join("\n"),
1303
+ dts: [
1304
+ GENERATED_HEADER,
1305
+ "/* oxlint-disable */",
1306
+ "/* eslint-disable */",
1307
+ "",
1308
+ `import type { SchemaMeta } from ${q(runtime)};`,
1309
+ "",
1310
+ "declare const meta: SchemaMeta;",
1311
+ "export default meta;",
1312
+ ""
1313
+ ].join("\n")
1314
+ };
1315
+ }
1316
+ /** Names the generated module declares or imports itself. */
1317
+ const RESERVED_EXPORTS = [
1318
+ "defineSchema",
1319
+ "Schema",
1320
+ "SchemaMeta",
1321
+ "EnrichDatabase",
1322
+ "MutableWhere",
1323
+ "OrderByArg",
1324
+ "OrderByInput",
1325
+ "StoragePath",
1326
+ "SupabaseDatabase",
1327
+ "meta",
1328
+ "Json",
1329
+ "Database",
1330
+ "Models",
1331
+ "Functions",
1332
+ "TableName",
1333
+ "UniqueConstraint",
1334
+ "CheckConstraint",
1335
+ "ForeignKeyConstraint",
1336
+ "RowOf",
1337
+ "InsertOf",
1338
+ "UpdateOf",
1339
+ "WhereOf",
1340
+ "OrderByOf",
1341
+ "OrderTermOf",
1342
+ "WritableColumnOf",
1343
+ "GeneratedColumnOf",
1344
+ "buckets",
1345
+ "topics",
1346
+ "subjectTypes",
1347
+ "SubjectType",
1348
+ "RecordRef",
1349
+ "schema",
1350
+ "extensions",
1351
+ "Extensions",
1352
+ "ExtensionsOf",
1353
+ "validation",
1354
+ "validators"
1355
+ ];
1356
+ function valueLists(model) {
1357
+ const lists = model.enums.map((entry) => ({
1358
+ constant: entry.constant,
1359
+ typeName: entry.typeName,
1360
+ values: entry.values,
1361
+ source: `enum ${entry.schema}.${entry.name}`
1362
+ }));
1363
+ for (const table of model.tables) for (const column of table.columns) if (column.values && !column.snapshot.isEnum) lists.push({
1364
+ constant: identifier(`${table.key}${pascal$2(column.app)}Values`.replace(/^[A-Z]/, (c) => c.toLowerCase())),
1365
+ typeName: identifier(`${pascal$2(table.key)}${pascal$2(column.app)}`),
1366
+ values: column.values,
1367
+ source: `the CHECK on ${table.snapshot.schema}.${table.snapshot.name}.${column.db}`
1368
+ });
1369
+ return lists;
1370
+ }
1371
+ /** The repository extension calls the schema carries, in install order. */
1372
+ function extensionCalls(options) {
1373
+ return [...(options.extensions ?? []).map((extension) => ({
1374
+ fn: extension.export,
1375
+ call: `${extension.export}(${extension.args})`
1376
+ })), ...options.validatorsImport === void 0 ? [] : [{
1377
+ fn: "validation",
1378
+ call: "validation({ schemas: validators })"
1379
+ }]];
1380
+ }
1381
+ function runtimeImports(options, runtime) {
1382
+ const { validatorsImport } = options;
1383
+ return [...(options.extensions ?? []).map((extension) => `import { ${extension.export} } from ${q(runtimeSubpath(runtime, extension.subpath))};`), ...validatorsImport === void 0 ? [] : [`import { validators } from ${q(validatorsImport)};`]];
1384
+ }
1385
+ /**
1386
+ * `database.types.ts` inside a type-only namespace, so its `Json` and
1387
+ * `Database` don't clash with the module's own. Its `Constants` value is left
1388
+ * out: a namespace holding a value is not erasable syntax.
1389
+ */
1390
+ function inlineDatabaseTypes(text) {
1391
+ const constants = text.search(/^export const Constants\b/m);
1392
+ return [
1393
+ "declare namespace SupabaseTypes {",
1394
+ ...indent([(constants === -1 ? text : text.slice(0, constants)).trimEnd()], 1),
1395
+ "}",
1396
+ "type SupabaseDatabase = SupabaseTypes.Database;"
1397
+ ];
1398
+ }
1399
+ /**
1400
+ * The runtime half of the generated module, for the content mapper: the values
1401
+ * (value lists, buckets, topics, extensions, subject types and `schema`), with
1402
+ * every type re-exported from the virtual module at `typesImport`, which holds
1403
+ * the full module.
1404
+ */
1405
+ function emitRuntime(model, options) {
1406
+ const runtime = options.runtimeImport ?? "better-supabase";
1407
+ const calls = extensionCalls(options);
1408
+ const subjects = Object.keys(model.config.subjects);
1409
+ const lines = [
1410
+ GENERATED_HEADER,
1411
+ "/* oxlint-disable */",
1412
+ "/* eslint-disable */",
1413
+ "",
1414
+ `import { defineSchema${options.validatorsImport === void 0 ? "" : ", validation"} } from ${q(runtime)};`,
1415
+ ...runtimeImports(options, runtime),
1416
+ `import type { schema as typedSchema } from ${q(options.typesImport)};`,
1417
+ `import meta from ${q(options.metaImport ?? "./generated.meta.js")};`,
1418
+ "",
1419
+ `export type * from ${q(options.typesImport)};`,
1420
+ "",
1421
+ ...valueLists(model).map((list) => `export const ${list.constant} = [${list.values.map(q).join(", ")}] as const;`)
1422
+ ];
1423
+ if (model.meta.buckets) lines.push(`export const buckets = ${JSON.stringify(model.meta.buckets, null, 2)} as const;`);
1424
+ if (model.meta.topics) lines.push(`export const topics = ${JSON.stringify(model.meta.topics, null, 2)} as const;`);
1425
+ if (subjects.length > 0) lines.push(`export const subjectTypes = [${subjects.map(q).join(", ")}] as const;`);
1426
+ lines.push("", `export const schema: typeof typedSchema = defineSchema(meta${calls.length > 0 ? `, [${calls.map(({ call }) => call).join(", ")}]` : ""});`, "");
1427
+ return lines.join("\n");
1428
+ }
1429
+ /** Renders the generated module. */
1430
+ function emitModule(model, options) {
1431
+ const runtime = options.runtimeImport ?? "better-supabase";
1432
+ const extensions = options.extensions ?? [];
1433
+ const { validatorsImport } = options;
1434
+ const extended = extensions.length > 0 || validatorsImport !== void 0;
1435
+ const declaresMeta = options.inlineMeta === true || options.declareMeta === true;
1436
+ const lines = [
1437
+ GENERATED_HEADER,
1438
+ "/* oxlint-disable */",
1439
+ "/* eslint-disable */",
1440
+ "",
1441
+ `import { defineSchema, ${validatorsImport === void 0 ? "" : "validation, "}${extended ? "type ExtensionsOf, " : ""}type Schema${declaresMeta ? ", type SchemaMeta" : ""} } from ${q(runtime)};`,
1442
+ ...runtimeImports(options, runtime)
1443
+ ];
1444
+ const storagePaths = model.tables.some((table) => table.columns.some((column) => column.storage !== void 0));
1445
+ lines.push(`import type { EnrichDatabase, GeneratedColumns, MutableWhere, OrderByArg, OrderByInput${storagePaths ? ", StoragePath" : ""}, WritableColumns } from ${q(runtime)};`);
1446
+ if (options.databaseTypes === void 0) lines.push(`import type { Database as SupabaseDatabase } from ${q(options.databaseTypesImport ?? "./database.types.ts")};`);
1447
+ const byFile = /* @__PURE__ */ new Map();
1448
+ for (const entry of model.jsonImports) {
1449
+ const list = byFile.get(entry.from) ?? [];
1450
+ list.push(entry.name);
1451
+ byFile.set(entry.from, list);
1452
+ }
1453
+ for (const [from, names] of [...byFile.entries()].toSorted(([a], [b]) => byCodePoint(a, b))) lines.push(`import type { ${names.toSorted().join(", ")} } from ${q(options.importPathFor(from))};`);
1454
+ lines.push(options.inlineMeta ? `\nconst meta: SchemaMeta = ${compactJson({ ...model.meta })};` : options.declareMeta ? "\ndeclare const meta: SchemaMeta;" : `import meta from ${q(options.metaImport ?? "./generated.meta.js")};`, ...options.databaseTypes === void 0 ? [] : ["", ...inlineDatabaseTypes(options.databaseTypes)], "", "export type Json = string | number | boolean | null | { [key: string]: Json | undefined } | Json[];", "", ...enrichedDatabase(model), "");
1455
+ const exported = new Map([
1456
+ ...RESERVED_EXPORTS,
1457
+ ...extensions.map((extension) => extension.export),
1458
+ ...model.jsonImports.map((entry) => entry.name)
1459
+ ].map((name) => [name, "the generated module"]));
1460
+ const claim = (name, source) => {
1461
+ const other = exported.get(name);
1462
+ if (other !== void 0) throw new TypeError(`${source} and ${other} both export "${name}" from the generated module. Rename one of them in the database.`);
1463
+ exported.set(name, source);
1464
+ return name;
1465
+ };
1466
+ for (const list of valueLists(model)) lines.push(`export const ${claim(list.constant, list.source)} = [${list.values.map(q).join(", ")}] as const;`, `export type ${claim(list.typeName, list.source)} = (typeof ${list.constant})[number];`);
1467
+ if (model.enums.length > 0) lines.push("");
1468
+ lines.push(...modelsType(model), "", ...functionsType(model), "", "export type TableName = keyof Models;", "/** Constraint names for `isConflict`, `isCheck` and `isForeignKey`. */", "export type UniqueConstraint = { [T in TableName]: Extract<keyof Models[T]['UniqueKeys'], string> }[TableName];", "export type CheckConstraint = Models[TableName]['Checks'];", "export type ForeignKeyConstraint = Models[TableName]['ForeignKeys'];", "export type RowOf<T extends TableName> = Models[T]['Row'];", "export type InsertOf<T extends TableName> = Models[T]['Insert'];", "export type UpdateOf<T extends TableName> = Models[T]['Update'];", "/** A `where` for `T` you can assign to one key at a time. */", "export type WhereOf<T extends TableName> = MutableWhere<Models, T>;", "/** An `orderBy` for `T`: one sort or a list, by column or to-one relation. */", "export type OrderByOf<T extends TableName> = OrderByArg<Models, T>;", "/** One sort term of `T`'s `orderBy`, by column or to-one relation. */", "export type OrderTermOf<T extends TableName> = OrderByInput<Models, T>;", "/** Columns of `T` that `Insert` and `Update` accept. */", "export type WritableColumnOf<T extends TableName> = WritableColumns<Models, T>;", "/** Columns of `T` the database fills (generated columns): in `Row`, never writable. */", "export type GeneratedColumnOf<T extends TableName> = GeneratedColumns<Models, T>;", "");
1469
+ if (model.meta.buckets) lines.push("/** Bucket configs for `defineBucket` from `better-supabase/storage`. */", `export const buckets = ${JSON.stringify(model.meta.buckets, null, 2)} as const;`, "");
1470
+ if (model.meta.topics) lines.push("/** Topic templates for `defineTopic` from `better-supabase/realtime`. */", `export const topics = ${JSON.stringify(model.meta.topics, null, 2)} as const;`, "");
1471
+ const subjects = Object.keys(model.config.subjects);
1472
+ const calls = extensionCalls(options);
1473
+ if (extended) lines.push("/** The installed blocks' repository extensions; `defineSupabase` installs them. */", `type Extensions = readonly [${calls.map(({ fn }) => `ReturnType<typeof ${fn}>`).join(", ")}];`, `const extensions: Extensions = [${calls.map(({ call }) => call).join(", ")}];`, "");
1474
+ const subjectType = subjects.length > 0 ? "SubjectType" : "string";
1475
+ const schemaLine = extended ? `export const schema: Schema<Models, Database, Functions, ${subjectType}, ExtensionsOf<Extensions>> = defineSchema(meta, extensions);` : `export const schema: Schema<Models, Database, Functions${subjects.length > 0 ? ", SubjectType" : ""}> = defineSchema(meta);`;
1476
+ if (subjects.length > 0) lines.push("/** The app's subject types, from `config.subjects`. */", `export const subjectTypes = [${subjects.map(q).join(", ")}] as const;`, "export type SubjectType = (typeof subjectTypes)[number];", "/** One subject: its type and its id as text. */", "export type RecordRef<T extends SubjectType = SubjectType> = { readonly type: T; readonly id: string };", "");
1477
+ lines.push(schemaLine, "");
1478
+ return lines.join("\n");
1479
+ }
1480
+ // src/cli/gen/blocks.ts
1481
+ /** `blocks.generated.ts`, next to the main generated module. */
1482
+ function blockConfigPath(config) {
1483
+ return posix.join(posix.dirname(config.output), "blocks.generated.ts");
1484
+ }
1485
+ function hasSchema(module) {
1486
+ return module in BLOCK_OPTION_SCHEMAS;
1487
+ }
1488
+ const DEFAULT_TENANT_COLUMN = "tenant_id";
1489
+ function tenantColumnOf(config, modules) {
1490
+ const names = /* @__PURE__ */ new Set();
1491
+ const others = /* @__PURE__ */ new Set();
1492
+ for (const module of modules) {
1493
+ const resolved = resolveBlock(config.blocks[module]);
1494
+ for (const [table, spec] of Object.entries(SQL_MODULES[module]?.names?.tables ?? {})) {
1495
+ if (resolved.tables[table] === null) continue;
1496
+ for (const [logical, name] of Object.entries(spec.columns)) {
1497
+ if (name !== DEFAULT_TENANT_COLUMN) {
1498
+ others.add(name);
1499
+ continue;
1500
+ }
1501
+ const mapped = resolved.columns[table]?.[logical];
1502
+ if (mapped !== null) names.add(mapped ?? config.sql.tenantColumn ?? name);
1503
+ }
1504
+ }
1505
+ }
1506
+ const [name] = names;
1507
+ return names.size === 1 && name !== void 0 && name !== DEFAULT_TENANT_COLUMN && !others.has(name) ? name : void 0;
1508
+ }
1509
+ /**
1510
+ * The tenant columns `blocks.<module>.columns` renames, as database name to
1511
+ * default name. A name another column of the block has by default is left out,
1512
+ * since mapping it back would rename that column too.
1513
+ */
1514
+ function tenantColumnsOf(config, modules) {
1515
+ const tables = modules.flatMap((module) => Object.entries(SQL_MODULES[module]?.names?.tables ?? {}).map(([table, spec]) => [spec, resolveBlock(config.blocks[module]).columns[table]]));
1516
+ const defaults = new Set(tables.flatMap(([spec]) => Object.entries(spec.columns).filter(([logical]) => logical !== "tenant").map(([, name]) => name)));
1517
+ return Object.fromEntries(tables.flatMap(([spec, columns]) => {
1518
+ const fallback = spec.columns["tenant"];
1519
+ const name = columns?.["tenant"];
1520
+ return fallback === void 0 || typeof name !== "string" || name === fallback || defaults.has(name) ? [] : [[name, fallback]];
1521
+ }));
1522
+ }
1523
+ /**
1524
+ * How the tenant rename, the modules' renamed entities and their
1525
+ * `blocks.<module>.functions` rename the block's functions and payload keys, or
1526
+ * undefined when nothing does. `blocks.permissions.functions` is the custom
1527
+ * model's templates, not renames.
1528
+ */
1529
+ function namingOf(config, modules, instanceFunctionNames = {}) {
1530
+ const functions = Object.fromEntries([...modules.flatMap((module) => module === "permissions" ? [] : Object.entries(resolveBlock(config.blocks[module]).functions)), ...Object.entries(instanceFunctionNames)]);
1531
+ const entities = modules.flatMap((module) => blockEntityRenames(module, config.blocks));
1532
+ const tenant = tenantNameOf(config.blocks);
1533
+ const renames = Object.keys(functions).length > 0;
1534
+ const tenantColumn = tenantColumnOf(config, modules);
1535
+ const columns = Object.fromEntries(Object.entries(tenantColumnsOf(config, modules)).filter(([name]) => name !== tenantColumn));
1536
+ const moved = Object.keys(columns).length > 0;
1537
+ if (tenant === void 0 && !renames && entities.length === 0 && tenantColumn === void 0 && !moved) return;
1538
+ return {
1539
+ ...tenant === void 0 ? {} : { tenant },
1540
+ ...tenantColumn === void 0 ? {} : { tenantColumn },
1541
+ ...renames ? { functions } : {},
1542
+ ...entities.length === 0 ? {} : { entities },
1543
+ ...moved ? { columns } : {}
1544
+ };
1545
+ }
1546
+ /**
1547
+ * The generated config of every installed block: its schema, its API schema,
1548
+ * and the options marked `client` with the configured value or the module's
1549
+ * default. Blocks without a creator get an entry too, since `block.using(...)`
1550
+ * builds them with these options.
1551
+ */
1552
+ function blockConfigEntries(config) {
1553
+ const installed = resolveBlocks(config.blockNames, {
1554
+ modules: config.blocks,
1555
+ ...config.sql.scope === void 0 ? {} : { scope: config.sql.scope }
1556
+ }).map((module) => module.name);
1557
+ const entries = [];
1558
+ for (const manifest of PRESET_CATALOG.manifests) {
1559
+ const modules = manifest.sql.filter((module) => installed.includes(module));
1560
+ const [main] = modules;
1561
+ const others = Object.values(config.instances).filter((instance) => instance.block === main);
1562
+ if (main !== void 0 && (others.length === 0 || others.some((each) => each.name === main))) entries.push([manifest.name, generatedEntry(config, modules)]);
1563
+ for (const instance of others) {
1564
+ if (main === void 0 || instance.name === main) continue;
1565
+ const layout = {
1566
+ modules: config.blocks,
1567
+ instances: config.instances,
1568
+ subjects: config.subjects,
1569
+ ...config.sql.scope === void 0 ? {} : { scope: config.sql.scope }
1570
+ };
1571
+ const entry = generatedEntry({
1572
+ ...config,
1573
+ blocks: {
1574
+ ...config.blocks,
1575
+ [main]: instance.config
1576
+ }
1577
+ }, modules, instanceFunctions(layout, installed, instance.name));
1578
+ entries.push([instance.name, {
1579
+ ...entry,
1580
+ block: manifest.name,
1581
+ ...Object.keys(instance.uses).length === 0 ? {} : { uses: instance.uses }
1582
+ }]);
1583
+ }
1584
+ }
1585
+ return Object.fromEntries(entries);
1586
+ }
1587
+ /**
1588
+ * One instance's generated config: the schema of its main module, the client
1589
+ * options of `modules` and its naming.
1590
+ */
1591
+ function generatedEntry(config, modules, instanceFunctionNames) {
1592
+ const resolved = resolveBlock(config.blocks[modules[0] ?? ""]);
1593
+ const options = {};
1594
+ for (const module of modules) {
1595
+ if (!hasSchema(module)) continue;
1596
+ const configured = resolveBlock(config.blocks[module]).options;
1597
+ for (const [key, spec] of Object.entries(BLOCK_OPTION_SCHEMAS[module].specs)) {
1598
+ if (!spec.client) continue;
1599
+ const value = configured[key] ?? spec.default;
1600
+ if (value !== void 0) options[key] = value;
1601
+ }
1602
+ }
1603
+ const names = namingOf(config, modules, instanceFunctionNames);
1604
+ return {
1605
+ schema: resolved.schema,
1606
+ ...resolved.api === void 0 ? {} : { api: resolved.api.schema },
1607
+ options,
1608
+ ...names === void 0 ? {} : { names }
1609
+ };
1610
+ }
1611
+ function literal(value, indent) {
1612
+ if (Array.isArray(value)) return `[${value.map((entry) => literal(entry, indent)).join(", ")}]`;
1613
+ if (typeof value === "object" && value !== null) {
1614
+ const entries = Object.entries(value);
1615
+ if (entries.length === 0) return "{}";
1616
+ const inner = `${indent} `;
1617
+ return `{\n${entries.map(([key, entry]) => `${inner}${prop(key)}: ${literal(entry, inner)},`).join("\n")}\n${indent}}`;
1618
+ }
1619
+ return JSON.stringify(value);
1620
+ }
1621
+ /** Every event type the app tables emit, in config order. */
1622
+ function appTableEvents(config) {
1623
+ return Object.entries(config.appTables).flatMap(([name, table]) => appTableEventTypes(name, table));
1624
+ }
1625
+ /**
1626
+ * `appTableEvents` and `appTableEventSchemas`, for app tables that set
1627
+ * `events`.
1628
+ */
1629
+ function appTableEventLines(types) {
1630
+ if (types.length === 0) return [];
1631
+ return [
1632
+ "",
1633
+ "/**",
1634
+ " * The events `tables.<table>.events` writes to the outbox, for `onBlockEvent` and the sinks.",
1635
+ " * @public",
1636
+ " */",
1637
+ "export const appTableEvents = defineEvents({",
1638
+ ...types.map((type) => ` ${prop(type)}: event<AppTableEventData>(),`),
1639
+ "});",
1640
+ "",
1641
+ "/**",
1642
+ " * The app table events with an open payload, for AsyncAPI's `cloudEvents.blocks`.",
1643
+ " * @public",
1644
+ " */",
1645
+ "export const appTableEventSchemas = {",
1646
+ ...types.map((type) => ` ${prop(type)}: true,`),
1647
+ "} as const;"
1648
+ ];
1649
+ }
1650
+ const CATALOG_BLOCKS = new Map(PRESET_CATALOG.blocks.map((block) => [block.name, block]));
1651
+ const MANIFESTS = new Map(PRESET_CATALOG.manifests.map((manifest) => [manifest.name, manifest]));
1652
+ /**
1653
+ * The repository extensions of the installed blocks, in block order. The
1654
+ * `memberships` one also stands for an app's own tenancy, when
1655
+ * `auth.tenant.column` turns it on without the block.
1656
+ */
1657
+ function schemaExtensions(config) {
1658
+ const tenant = config.extensions.tenant;
1659
+ const tenantOptions = Object.entries({
1660
+ onMissing: tenant?.onMissing,
1661
+ header: tenant?.header
1662
+ }).flatMap(([key, value]) => value === void 0 ? [] : [`${key}: ${q(value)}`]);
1663
+ const tenantArgs = tenantOptions.length === 0 ? "" : `{ ${tenantOptions.join(", ")} }`;
1664
+ const extensions = config.blockNames.flatMap((name) => {
1665
+ const manifest = MANIFESTS.get(CATALOG_BLOCKS.get(name)?.manifest ?? "");
1666
+ if (manifest?.extension === void 0) return [];
1667
+ return [{
1668
+ export: manifest.extension,
1669
+ subpath: `blocks/${manifest.name}`,
1670
+ args: manifest.name === "memberships" ? tenantArgs : STAMPED.has(manifest.name) ? stampArgs(name, config.blocks?.[name]?.options?.["stamp"]) : ""
1671
+ }];
1672
+ });
1673
+ if (tenant !== void 0 && !extensions.some((entry) => entry.subpath === "blocks/memberships")) extensions.push({
1674
+ export: "membershipsExtension",
1675
+ subpath: "blocks/memberships",
1676
+ args: tenantArgs
1677
+ });
1678
+ return extensions;
1679
+ }
1680
+ const STAMPED = /* @__PURE__ */ new Set(["created-by", "updated-at"]);
1681
+ function stampArgs(name, stamp) {
1682
+ if (stamp === void 0 || stamp === "client") return "";
1683
+ if (stamp === "trigger") return "{ stamp: \"trigger\" }";
1684
+ throw new TypeError(`blocks.${name}.options.stamp must be "client" or "trigger", got ${JSON.stringify(stamp)}`);
1685
+ }
1686
+ /** The installed blocks with their final names, for `GeneratorModel.blocks`. */
1687
+ function generatorBlocks(config) {
1688
+ return Object.entries(blockConfigEntries(config)).filter(([, entry]) => entry.block === void 0).map(([name, entry]) => {
1689
+ const manifest = MANIFESTS.get(CATALOG_BLOCKS.get(name)?.manifest ?? "");
1690
+ const owned = manifest?.name === name ? manifest : void 0;
1691
+ const client = owned?.client ?? void 0;
1692
+ const renames = entityNames(entry.names?.entities ?? []);
1693
+ return {
1694
+ name,
1695
+ schema: entry.schema,
1696
+ client: client === void 0 ? void 0 : {
1697
+ export: renames.rename(client.export),
1698
+ subpath: client.subpath
1699
+ },
1700
+ entities: blockEntities(name, config.blocks).map((entity) => ({
1701
+ key: entity.key,
1702
+ from: { ...entity.from },
1703
+ to: { ...entity.to },
1704
+ primary: entity.primary,
1705
+ table: entity.table,
1706
+ url: entity.url,
1707
+ schemas: owned?.entitySchemas?.[entity.key] ?? {}
1708
+ }))
1709
+ };
1710
+ });
1711
+ }
1712
+ /**
1713
+ * For each installed block whose entities `blocks.<name>.entities` renames: the
1714
+ * block under its renamed constant (`tasksBlock`) and an alias for each type
1715
+ * named after one of its entities (`Task<F>`, `TasksEvents`).
1716
+ */
1717
+ function renamedBlockLines(entries) {
1718
+ const imports = [];
1719
+ const lines = [];
1720
+ const exported = /* @__PURE__ */ new Set();
1721
+ const constants = /* @__PURE__ */ new Map();
1722
+ for (const manifest of PRESET_CATALOG.manifests) {
1723
+ const instances = Object.entries(entries).filter(([key, entry]) => (entry.block ?? key) === manifest.name && (entry.names?.entities ?? []).length > 0);
1724
+ if (manifest.client === null || instances.length === 0) continue;
1725
+ const aliasAll = instances.length > 1;
1726
+ const block = manifest.client.export;
1727
+ const entityTypes = (manifest.entityTypes ?? []).filter((type) => !(type.name.endsWith("Options") && manifest.entityTypes?.some((other) => `${other.name}Options` === type.name)));
1728
+ const eventsType = manifest.events?.type;
1729
+ const types = eventsType === void 0 || entityTypes.some((type) => type.name === eventsType) ? entityTypes : [...entityTypes, { name: eventsType }];
1730
+ const [first] = instances;
1731
+ const firstNames = entityNames(first?.[1].names?.entities ?? []);
1732
+ const localOf = (name) => aliasAll || firstNames.rename(name) === name ? `Default${name}` : name;
1733
+ const local = aliasAll || firstNames.rename(block) === block ? `default${pascal(block)}` : block;
1734
+ const specifiers = [...types.map((type) => localOf(type.name) === type.name ? ` type ${type.name},` : ` type ${type.name} as ${localOf(type.name)},`), ` ${local === block ? block : `${block} as ${local}`},`];
1735
+ imports.push([
1736
+ "import {",
1737
+ ...specifiers,
1738
+ `} from ${q(manifest.client.subpath)};`
1739
+ ].join("\n"));
1740
+ for (const [instance, entry] of instances) {
1741
+ const names = entityNames(entry.names?.entities ?? []);
1742
+ const alias = `${pascal(camelOf(instance))}Renames`;
1743
+ const key = q(instance);
1744
+ const wanted = instance === manifest.name ? names.rename(block) : `${camelOf(instance)}Block`;
1745
+ const renamed = exported.has(wanted) ? `${camelOf(instance)}Block` : wanted;
1746
+ exported.add(renamed);
1747
+ constants.set(instance, renamed);
1748
+ lines.push("", `type ${alias} = (typeof blockConfig)[${key}]["names"]["entities"];`, "", "/**", ` * The \`${manifest.name}\` block under the names \`blocks.${instance}.entities\` gives it.`, " * @public", " */", `export const ${renamed} = renameBlock(${local}, blockConfig[${key}].names);`, ...renamedTypeLines(types, names, localOf, alias, exported, {
1749
+ block: eventsType,
1750
+ instance: instance === manifest.name ? void 0 : `${pascal(camelOf(instance))}Events`
1751
+ }));
1752
+ }
1753
+ }
1754
+ return {
1755
+ specifiers: imports.length === 0 ? [] : [
1756
+ "renameBlock",
1757
+ "type RenamedEvents",
1758
+ "type RenamedType"
1759
+ ],
1760
+ imports,
1761
+ lines,
1762
+ constants
1763
+ };
1764
+ }
1765
+ /**
1766
+ * `blocks`: every installed instance with a client, under its key, for
1767
+ * `defineBlocks(blockConfig, blocks)`. A renamed instance uses its renamed
1768
+ * constant; the others import their block.
1769
+ */
1770
+ function instanceMapLines(entries, renamed, synced) {
1771
+ const imported = /* @__PURE__ */ new Map();
1772
+ const members = [];
1773
+ for (const [instance, entry] of Object.entries(entries)) {
1774
+ const manifest = MANIFESTS.get(entry.block ?? instance);
1775
+ const client = manifest?.client;
1776
+ if (manifest === void 0 || client === void 0 || client === null) continue;
1777
+ if (synced !== void 0 && !synced.has(instance)) members.push(" /** Needs the network on native. */");
1778
+ const constant = renamed.get(instance);
1779
+ if (constant !== void 0) {
1780
+ members.push(` ${prop(instance)}: ${constant},`);
1781
+ continue;
1782
+ }
1783
+ const local = `${camelOf(manifest.name)}BlockInstance`;
1784
+ imported.set(manifest.name, {
1785
+ local,
1786
+ subpath: client.subpath
1787
+ });
1788
+ members.push(` ${prop(instance)}: ${local},`);
1789
+ }
1790
+ if (members.length === 0) return {
1791
+ imports: [],
1792
+ lines: []
1793
+ };
1794
+ return {
1795
+ imports: [...imported].map(([name, { local, subpath }]) => {
1796
+ return `import { ${MANIFESTS.get(name)?.client?.export ?? local} as ${local} } from ${q(subpath)};`;
1797
+ }),
1798
+ lines: [
1799
+ "",
1800
+ "/**",
1801
+ " * Every installed block instance with a client, under its key, for",
1802
+ " * `defineBlocks(blockConfig, { ...blocks, ... })`. Override an entry to give",
1803
+ " * a block its ports (`notifications: notificationsBlock.using(...)`).",
1804
+ ...synced === void 0 ? [] : [" * Instances outside `gen.powersync.instances` call the Data API, so", " * their hooks need the network on native."],
1805
+ " * @public",
1806
+ " */",
1807
+ "export const blocks = {",
1808
+ ...members,
1809
+ "} as const;"
1810
+ ]
1811
+ };
1812
+ }
1813
+ /**
1814
+ * An alias for each of `types` under the name an instance's entity renames give
1815
+ * it, skipping a name another instance already exports. A renamed instance's
1816
+ * block-named events type takes the instance's name (`MaintenanceEvents`).
1817
+ */
1818
+ function renamedTypeLines(types, names, localOf, alias, exported, events) {
1819
+ return types.flatMap((type) => {
1820
+ const name = type.name === events.block && events.instance !== void 0 ? events.instance : names.rename(type.name);
1821
+ const source = localOf(type.name);
1822
+ if (exported.has(name)) return [];
1823
+ exported.add(name);
1824
+ if (type.name.endsWith("Events")) return [
1825
+ "",
1826
+ "/** @public */",
1827
+ `export type ${name} = RenamedEvents<${source}, ${alias}>;`
1828
+ ];
1829
+ return type.fields === true ? [
1830
+ "",
1831
+ "/** @public */",
1832
+ `export type ${name}<F extends object = Record<never, never>> = RenamedType<${source}<F>, ${alias}>;`
1833
+ ] : [
1834
+ "",
1835
+ "/** @public */",
1836
+ `export type ${name} = RenamedType<${source}, ${alias}>;`
1837
+ ];
1838
+ });
1839
+ }
1840
+ function camelOf(name) {
1841
+ return name.replaceAll(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
1842
+ }
1843
+ function pascal(name) {
1844
+ return name.charAt(0).toUpperCase() + name.slice(1);
1845
+ }
1846
+ /**
1847
+ * `blocks.generated.ts`: each installed block's schema, API schema and the
1848
+ * options its TypeScript side reads, for `defineBlocks(blockConfig, ...)`, and
1849
+ * the app table events. `undefined` when the config installs no blocks.
1850
+ */
1851
+ function emitBlockConfig(config, options = {}) {
1852
+ if (config.blockNames.length === 0) return;
1853
+ const entries = blockConfigEntries(config);
1854
+ const events = appTableEvents(config);
1855
+ const runtime = options.runtimeImport ?? "better-supabase";
1856
+ const renamed = renamedBlockLines(entries);
1857
+ const constants = nameConstantLines(config, entries);
1858
+ const synced = config.gen.powersync?.instances;
1859
+ const instances = instanceMapLines(entries, renamed.constants, synced === void 0 ? void 0 : new Set(synced));
1860
+ const specifiers = [
1861
+ ...events.length === 0 ? [] : [
1862
+ "type AppTableEventData",
1863
+ "defineEvents",
1864
+ "event"
1865
+ ],
1866
+ "type GeneratedBlocks",
1867
+ ...renamed.specifiers,
1868
+ ...constants.specifiers
1869
+ ].toSorted((a, b) => a.replace("type ", "").localeCompare(b.replace("type ", "")));
1870
+ const blocksImport = specifiers.length === 1 ? `import type { GeneratedBlocks } from ${q(runtimeSubpath(runtime, "blocks"))};` : `import {\n${specifiers.map((name) => ` ${name},`).join("\n")}\n} from ${q(runtimeSubpath(runtime, "blocks"))};`;
1871
+ return {
1872
+ path: blockConfigPath(config),
1873
+ contents: [
1874
+ GENERATED_HEADER,
1875
+ "",
1876
+ blocksImport,
1877
+ ...renamed.imports,
1878
+ ...constants.imports,
1879
+ ...instances.imports,
1880
+ "",
1881
+ "/**",
1882
+ " * The installed blocks' settings from the `blocks` config, for",
1883
+ " * `defineBlocks(blockConfig, { ... })`: each block's schema, API schema",
1884
+ " * and the options its SQL and TypeScript halves share.",
1885
+ " */",
1886
+ `export const blockConfig = ${literal(entries, "")} as const satisfies GeneratedBlocks;`,
1887
+ ...renamed.lines,
1888
+ ...instances.lines,
1889
+ ...appTableEventLines(events),
1890
+ ...constants.lines,
1891
+ ""
1892
+ ].join("\n")
1893
+ };
1894
+ }
1895
+ // src/cli/gen/hooks.ts
1896
+ const IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
1897
+ function access(property) {
1898
+ return IDENTIFIER.test(property) ? `db.${property}` : `db[${q(property)}]`;
1899
+ }
1900
+ /** `hooks.ts`, next to the main generated module. */
1901
+ function hooksPath(config) {
1902
+ return posix.join(posix.dirname(config.output), "hooks.ts");
1903
+ }
1904
+ /** The list and record hook names for a `db` property. */
1905
+ function hookNames(property) {
1906
+ const name = pascal$2(property);
1907
+ const one = pascal$2(singular(property));
1908
+ return one === name ? {
1909
+ list: `use${name}List`,
1910
+ one: `use${name}`
1911
+ } : {
1912
+ list: `use${name}`,
1913
+ one: `use${one}`
1914
+ };
1915
+ }
1916
+ /**
1917
+ * `hooks.ts`: `defineDataHooks` from the `gen.hooks` framework once per table,
1918
+ * typed by the app's definition in `./index`. Block instances keep their own
1919
+ * client methods on `db.<instance>`, which take their own arguments.
1920
+ * `undefined` with `hooks: false`.
1921
+ */
1922
+ function emitHooks(config, tables, options = {}) {
1923
+ if (config.hooks === false) return;
1924
+ const runtime = options.runtimeImport ?? "better-supabase";
1925
+ if (tables.length === 0) return;
1926
+ return {
1927
+ path: hooksPath(config),
1928
+ contents: [
1929
+ GENERATED_HEADER,
1930
+ ...config.hooks === "react" ? ["\"use client\";"] : [],
1931
+ "",
1932
+ `import type { DbOf } from ${q(runtime)};`,
1933
+ "",
1934
+ `import { defineDataHooks } from ${q(runtimeSubpath(runtime, config.hooks))};`,
1935
+ "",
1936
+ "import type { betterSupabase } from \"./index\";",
1937
+ "",
1938
+ "type AppDb = DbOf<typeof betterSupabase>;",
1939
+ ...tables.flatMap((property) => {
1940
+ const names = hookNames(property);
1941
+ return [
1942
+ "",
1943
+ `export const { useList: ${names.list}, useOne: ${names.one} } =`,
1944
+ ` defineDataHooks(${q(property)}, (db: AppDb) => ${access(property)});`
1945
+ ];
1946
+ }),
1947
+ ""
1948
+ ].join("\n")
1949
+ };
1950
+ }
1951
+ // src/cli/gen/records.ts
1952
+ /** `names` and every block they require, from the catalog. */
1953
+ function withRequired(names) {
1954
+ const requires = new Map(PRESET_CATALOG.blocks.map((block) => [block.name, block.requires]));
1955
+ const found = /* @__PURE__ */ new Set();
1956
+ const add = (name) => {
1957
+ if (!found.has(name)) {
1958
+ found.add(name);
1959
+ for (const required of requires.get(name) ?? []) add(required);
1960
+ }
1961
+ };
1962
+ for (const name of names) add(name);
1963
+ return [...found];
1964
+ }
1965
+ function camel(name) {
1966
+ return name.replaceAll(/[-_]([a-z0-9])/g, (_, c) => c.toUpperCase());
1967
+ }
1968
+ function kebab(name) {
1969
+ return name.replaceAll("_", "-");
1970
+ }
1971
+ /**
1972
+ * The record types a block's SQL serves, which is where its binding loads: the
1973
+ * types `blocks.<instance>.on` names, or every tenant-scoped registered subject
1974
+ * when it names none. Versions keep only the listed types and the subjects with
1975
+ * `versions` set.
1976
+ */
1977
+ function servedSubjects(config, block) {
1978
+ const listed = config.blocks[block]?.on;
1979
+ const registry = Object.entries(config.subjects);
1980
+ const named = listed === void 0 ? void 0 : Array.isArray(listed) ? listed : Object.keys(listed);
1981
+ if (block === "versions") {
1982
+ const versioned = registry.filter(([, entry]) => entry.versions !== void 0).map(([type]) => type);
1983
+ return /* @__PURE__ */ new Set([...named ?? [], ...versioned]);
1984
+ }
1985
+ if (named !== void 0) return new Set(named);
1986
+ return new Set(registry.filter(([, entry]) => entry.tenant !== false).map(([type]) => type));
1987
+ }
1988
+ function bindingBlocks(config) {
1989
+ const manifests = new Map(PRESET_CATALOG.manifests.map((manifest) => [manifest.name, manifest]));
1990
+ return generatorBlocks(config).flatMap((block) => {
1991
+ const manifest = manifests.get(block.name);
1992
+ if (manifest?.record === void 0 || manifest.client === null || block.client === void 0) return [];
1993
+ const renamed = block.client.export !== manifest.client.export;
1994
+ return [{
1995
+ name: block.name,
1996
+ key: camel(block.name),
1997
+ local: block.client.export,
1998
+ from: renamed ? void 0 : block.client.subpath
1999
+ }];
2000
+ });
2001
+ }
2002
+ function recordFile(config, path, type, blocks, extras) {
2003
+ const generated = importPath(path, blockConfigPath(config));
2004
+ const fromGenerated = [
2005
+ "blockConfig",
2006
+ ...extras.permissions ? ["permissions"] : [],
2007
+ ...blocks.filter((block) => block.from === void 0).map((b) => b.local)
2008
+ ].toSorted((a, b) => a.localeCompare(b));
2009
+ const imports = [
2010
+ "import { defineRecordType } from \"better-supabase/records\";",
2011
+ ...blocks.flatMap((block) => block.from === void 0 ? [] : [`import { ${block.local} } from ${q(block.from)};`]),
2012
+ ...extras.access === void 0 ? [] : [`import { permissionsBlock } from ${q(extras.access)};`]
2013
+ ].toSorted((a, b) => a.localeCompare(b));
2014
+ return {
2015
+ path,
2016
+ contents: [
2017
+ GENERATED_HEADER,
2018
+ "",
2019
+ ...imports,
2020
+ "",
2021
+ `import { ${fromGenerated.join(", ")} } from ${q(generated)};`,
2022
+ "",
2023
+ "/**",
2024
+ ` * The ${type} record type: each installed block that binds to it. Pass it`,
2025
+ " * to `bsb.record`, `recordQueries` or `createRecordProvider`.",
2026
+ " */",
2027
+ `export const ${camel(type)}Record = defineRecordType({`,
2028
+ ` type: ${q(type)},`,
2029
+ " blocks: {",
2030
+ ...blocks.map((block) => block.key === block.local ? ` ${block.key},` : ` ${block.key}: ${block.local},`),
2031
+ " },",
2032
+ " config: blockConfig,",
2033
+ ...extras.permissions ? [" permissions,"] : [],
2034
+ ...extras.access === void 0 ? [] : [" access: permissionsBlock,"],
2035
+ "});",
2036
+ ""
2037
+ ].join("\n")
2038
+ };
2039
+ }
2040
+ /**
2041
+ * `records/` next to the main module: one `records/<type>.ts` per record type
2042
+ * that an installed block binds to, and an index. Record types the binding
2043
+ * blocks and the blocks they require register themselves (a comment's message,
2044
+ * an attachment) get none. Empty with `recordTypes: false`.
2045
+ */
2046
+ function emitRecords(config) {
2047
+ if (!config.recordTypes || config.blockNames.length === 0) return [];
2048
+ const blocks = bindingBlocks(config);
2049
+ if (blocks.length === 0) return [];
2050
+ const served = new Map(blocks.map((block) => [block.name, servedSubjects(config, block.name)]));
2051
+ const access = PRESET_CATALOG.manifests.find((manifest) => manifest.name === "permissions")?.client;
2052
+ const extras = {
2053
+ access: new Set(generatorBlocks(config).map((block) => block.name)).has("permissions") ? access?.subpath : void 0,
2054
+ permissions: hasPermissionConstants(config)
2055
+ };
2056
+ const dir = posix.join(posix.dirname(config.output), "records");
2057
+ const files = [];
2058
+ const types = [];
2059
+ const inner = new Set(withRequired(blocks.map((block) => block.name)).flatMap((name) => blockSubjectTypes(name, config.blocks)));
2060
+ for (const type of Object.keys(config.subjects).toSorted()) {
2061
+ if (inner.has(type)) continue;
2062
+ const own = blocks.filter((block) => served.get(block.name)?.has(type));
2063
+ if (own.length === 0) continue;
2064
+ const path = posix.join(dir, `${kebab(type)}.ts`);
2065
+ files.push(recordFile(config, path, type, own, extras));
2066
+ types.push([type, path]);
2067
+ }
2068
+ if (types.length === 0) return [];
2069
+ const index = posix.join(dir, "index.ts");
2070
+ files.push({
2071
+ path: index,
2072
+ contents: [
2073
+ GENERATED_HEADER,
2074
+ "",
2075
+ ...types.map(([type, path]) => `export { ${camel(type)}Record } from ${q(importPath(index, path))};`),
2076
+ ""
2077
+ ].join("\n")
2078
+ });
2079
+ return files;
2080
+ }
2081
+ // src/cli/gen/render.ts
2082
+ /** The file the content mapper serves the schema types for. */
2083
+ const MAPPER_FILE = "schema.bsb";
2084
+ /** Where `schema.bsb` sits: next to the generated module. */
2085
+ function mapperFilePath(config) {
2086
+ return join(dirname(config.output), MAPPER_FILE);
2087
+ }
2088
+ const MAPPER_FILE_CONTENTS = `// The better-supabase content mapper serves the schema types for this file.
2089
+ // Its contents are ignored. Run \`better-supabase gen\` after a config change.
2090
+ `;
2091
+ /**
2092
+ * Renders every generated file for a snapshot, without touching disk:
2093
+ * `database.types.ts` (what `supabase gen types` prints), the main module,
2094
+ * `blocks.generated.ts` when the config installs blocks, the record features in
2095
+ * `features/`, then each configured generator's files.
2096
+ */
2097
+ async function renderFiles(config, snapshot, options = {}) {
2098
+ return (await render(config, snapshot, options)).files;
2099
+ }
2100
+ /**
2101
+ * The module the content mapper serves for `schema.bsb`: the full generated
2102
+ * module with `database.types.ts` inlined, from the cache when the CLI and
2103
+ * typegen versions, the config (and `configText`, its file) and the snapshot
2104
+ * match the last render.
2105
+ */
2106
+ async function renderTypesModule(config, snapshot, configText) {
2107
+ return cachedTypesModule(config.root, config.output, typesModuleKey(config, configText, snapshot), async () => (await render(config, snapshot, { typesModule: true })).typesModule ?? "");
2108
+ }
2109
+ async function render(declared, snapshot, options = {}) {
2110
+ const config = withTableTags(declared, snapshot.generator.tables);
2111
+ const model = buildModel(snapshot, config);
2112
+ const runtime = options.runtimeImport ? { runtimeImport: options.runtimeImport } : {};
2113
+ const output = resolve(config.root, config.output);
2114
+ const typegenOptions = {
2115
+ schemas: config.schemas,
2116
+ postgrestVersion: config.postgrestVersion
2117
+ };
2118
+ const databaseTypes = await cachedDatabaseTypes(config.root, [
2119
+ typegenOptions,
2120
+ await oxfmtInstalled(),
2121
+ snapshot.generator
2122
+ ], () => generateDatabaseTypes(snapshot.generator, typegenOptions));
2123
+ const metaFiles = metaPaths(config.output);
2124
+ const emitOptions = {
2125
+ databaseTypesImport: importPath(output, resolve(config.root, config.databaseTypesOutput)),
2126
+ importPathFor: (from) => importPath(output, resolve(config.root, from)),
2127
+ metaImport: `./${basename(metaFiles.js)}`,
2128
+ extensions: options.extensions === false ? [] : schemaExtensions(config),
2129
+ ...options.inlineMeta ? { inlineMeta: true } : {},
2130
+ ...runtime
2131
+ };
2132
+ const meta = emitMeta(model, {
2133
+ types: `./${basename(metaFiles.dts)}`,
2134
+ ...runtime
2135
+ });
2136
+ const mapper = config.gen.contentMapper === true;
2137
+ const files = [
2138
+ {
2139
+ path: config.output,
2140
+ contents: ""
2141
+ },
2142
+ {
2143
+ path: metaFiles.js,
2144
+ contents: meta.js
2145
+ },
2146
+ {
2147
+ path: metaFiles.dts,
2148
+ contents: meta.dts
2149
+ }
2150
+ ];
2151
+ files.splice(mapper ? 1 : 0, 0, mapper ? {
2152
+ path: mapperFilePath(config),
2153
+ contents: MAPPER_FILE_CONTENTS
2154
+ } : {
2155
+ path: config.databaseTypesOutput,
2156
+ contents: databaseTypes
2157
+ });
2158
+ const main = mapper ? 0 : 1;
2159
+ const blockConfig = emitBlockConfig(config, runtime);
2160
+ if (blockConfig) files.push(blockConfig);
2161
+ files.push(...emitRecords(config));
2162
+ const hooks = emitHooks(config, Object.keys(model.meta.tables), runtime);
2163
+ if (hooks) files.push(hooks);
2164
+ const owners = new Map(files.map((file) => [resolve(config.root, file.path), "gen"]));
2165
+ let view;
2166
+ for (const generator of config.generators) {
2167
+ let extra;
2168
+ try {
2169
+ extra = await generator.generate({
2170
+ meta: model.meta,
2171
+ introspection: model.introspection,
2172
+ extras: snapshot.extras,
2173
+ config,
2174
+ output,
2175
+ importPath: (from, to) => importPath(resolve(config.root, from), resolve(config.root, to)),
2176
+ model: view ??= generatorModel(model, generatorBlocks(config)),
2177
+ ...runtime
2178
+ });
2179
+ } catch (cause) {
2180
+ throw new CliError("generator_failed", `generator "${generator.name}" failed: ${errorText(cause)}`, { cause });
2181
+ }
2182
+ for (const file of extra) {
2183
+ const path = resolve(config.root, file.path);
2184
+ const inside = relative(config.root, path);
2185
+ if (inside === "" || inside.startsWith("..") || isAbsolute(inside)) throw new CliError("generator_failed", `generator "${generator.name}" wrote ${file.path}, which is outside the project root`);
2186
+ const owner = owners.get(path);
2187
+ if (owner !== void 0) throw new CliError("generator_failed", `generator "${generator.name}" wrote ${file.path}, which ${owner === "gen" ? "better-supabase gen writes" : `generator "${owner}" also writes`}`);
2188
+ owners.set(path, generator.name);
2189
+ files.push(file);
2190
+ }
2191
+ }
2192
+ const validators = options.extensions === false ? void 0 : files.find((file) => file.validators === true);
2193
+ const withValidators = {
2194
+ ...emitOptions,
2195
+ ...validators === void 0 ? {} : { validatorsImport: importPath(output, resolve(config.root, validators.path)) }
2196
+ };
2197
+ files[main] = {
2198
+ path: config.output,
2199
+ contents: mapper ? emitRuntime(model, {
2200
+ ...withValidators,
2201
+ typesImport: `./${MAPPER_FILE}`
2202
+ }) : emitModule(model, withValidators)
2203
+ };
2204
+ const typesModule = mapper || options.typesModule === true ? emitModule(model, {
2205
+ ...withValidators,
2206
+ databaseTypes,
2207
+ declareMeta: true
2208
+ }) : void 0;
2209
+ return {
2210
+ files,
2211
+ warnings: model.warnings,
2212
+ notices: model.notices,
2213
+ ...typesModule === void 0 ? {} : { typesModule }
2214
+ };
2215
+ }
2216
+ export { emitBlockConfig as a, metaPaths as c, configFor as d, renderTypesModule as i, buildModel as l, render as n, GENERATED_HEADER as o, renderFiles as r, emitModule as s, mapperFilePath as t, notNullTag as u };