better-supabase 0.10.0 → 0.12.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 (853) hide show
  1. package/README.md +1 -0
  2. package/dist/{access-sql-DUSSMaC3.js → access-sql-CTJPHjCL.js} +1 -1
  3. package/dist/{actor-KHDOKGb1.js → actor-CAL8mMih.js} +1 -1
  4. package/dist/{adapter-rmWaLNe3.js → adapter-CRNH2aX_.js} +390 -267
  5. package/dist/{agents-ByYUSZxT.d.ts → agents-CGP2AQge.d.ts} +7 -7
  6. package/dist/{ai-cache-CkxtAt4P.d.ts → ai-cache-BdeJKlrV.d.ts} +5 -5
  7. package/dist/{ai-cache-DPiuJ-zJ.js → ai-cache-CLninP-F.js} +2 -2
  8. package/dist/{ai-chat-al8b3spK.d.ts → ai-chat-D-2MH1sU.d.ts} +7 -7
  9. package/dist/{ai-files-BXtV3ygd.js → ai-files-ChFDkMLN.js} +18 -10
  10. package/dist/ai-sdk/agents/index.d.ts +6 -6
  11. package/dist/ai-sdk/agents/index.js +2 -2
  12. package/dist/ai-sdk/batches/index.d.ts +4 -4
  13. package/dist/ai-sdk/batches/index.js +4 -4
  14. package/dist/ai-sdk/cache/index.d.ts +2 -2
  15. package/dist/ai-sdk/cache/index.js +1 -1
  16. package/dist/ai-sdk/chat/index.d.ts +1 -1
  17. package/dist/ai-sdk/chat/index.js +5 -5
  18. package/dist/ai-sdk/embeddings/index.d.ts +2 -2
  19. package/dist/ai-sdk/files/index.d.ts +2 -2
  20. package/dist/ai-sdk/files/index.js +4 -4
  21. package/dist/ai-sdk/index.d.ts +6 -6
  22. package/dist/ai-sdk/index.js +2 -2
  23. package/dist/ai-sdk/mcp/index.d.ts +4 -4
  24. package/dist/ai-sdk/mcp/index.js +4 -4
  25. package/dist/ai-sdk/memory/index.d.ts +3 -3
  26. package/dist/ai-sdk/workflow/index.d.ts +4 -4
  27. package/dist/ai-sdk/workflow/index.js +6 -6
  28. package/dist/{ai-tasks-Di0gmJOX.d.ts → ai-tasks-ZvPnNudQ.d.ts} +8 -8
  29. package/dist/{announcements-HF7LuFw5.js → announcements-BNxTW5HJ.js} +4 -4
  30. package/dist/{api-CFjuYKFY.js → api-C43_FYDp.js} +1 -1
  31. package/dist/{api-XJcQON_7.d.ts → api-DoWK3dTw.d.ts} +6 -6
  32. package/dist/{api-keys-EdSNjGIZ.d.ts → api-keys-AgDXbcql.d.ts} +7 -7
  33. package/dist/{api-keys-C1IZF7p8.js → api-keys-BSXwI2jF.js} +6 -6
  34. package/dist/{app-tables-DVidEHOI.d.ts → app-tables-BrMBjyuq.d.ts} +1 -1
  35. package/dist/{approvals-DqlPHBHI.d.ts → approvals-CyX709B-.d.ts} +7 -7
  36. package/dist/arazzo/index.d.ts +2 -2
  37. package/dist/arazzo/index.js +2 -2
  38. package/dist/{assistant-BZyhQ8bd.d.ts → assistant-DZsHsYIx.d.ts} +4 -4
  39. package/dist/astro/index.d.ts +12 -12
  40. package/dist/astro/index.js +5 -5
  41. package/dist/asyncapi/index.d.ts +1 -1
  42. package/dist/asyncapi/index.js +2 -2
  43. package/dist/{attachments-C8FEBBKE.js → attachments-CK8D8bIV.js} +14 -8
  44. package/dist/{audit-log-CRgiHlRh.js → audit-log-ovUlF4Mk.js} +7 -7
  45. package/dist/auth-module-DbZv2WrR.js +10 -0
  46. package/dist/{auth-reply-B_dW4jHJ.js → auth-reply-Daq72lY4.js} +2 -2
  47. package/dist/{authorization-CdJRoZgV.d.ts → authorization-ClWBcXJi.d.ts} +23 -2
  48. package/dist/{authorization-hooks-Do5djkpz.d.ts → authorization-hooks-WDQMKIsc.d.ts} +2 -2
  49. package/dist/{authorizer-dVVN05Un.js → authorizer-B3yyCVUF.js} +2 -2
  50. package/dist/{base64-BmeCBgGo.js → base64-D4aqdnDR.js} +4 -4
  51. package/dist/better-result/index.d.ts +5 -5
  52. package/dist/better-result/index.js +1 -1
  53. package/dist/{bind-DkaP_0iS.d.ts → bind-Bfo40o63.d.ts} +4 -4
  54. package/dist/{block-fields-BANwJ9Y_.js → block-fields-Bv1hV855.js} +3 -3
  55. package/dist/{block-fields-5UA84ZUg.d.ts → block-fields-DnaDbgZS.d.ts} +2 -2
  56. package/dist/{block-helpers-7pMBVsE6.d.ts → block-helpers-CjcQM1yA.d.ts} +2 -2
  57. package/dist/{block-helpers-BfVCR5Fc.js → block-helpers-DkVZNDrj.js} +4 -4
  58. package/dist/{block-hooks-ByKlh8Qy.js → block-hooks-C22vuIUd.js} +3 -3
  59. package/dist/{block-hooks-C_WaodoA.d.ts → block-hooks-DcPJHztl.d.ts} +3 -3
  60. package/dist/{block-transport-NbUJygA7.d.ts → block-transport-DezJPPA0.d.ts} +2 -2
  61. package/dist/{block-transport-G4t1umrR.js → block-transport-J7ZepTq2.js} +1 -1
  62. package/dist/blocks/access-requests/index.d.ts +8 -8
  63. package/dist/blocks/access-requests/index.js +6 -6
  64. package/dist/blocks/agents/index.d.ts +4 -4
  65. package/dist/blocks/agents/index.js +5 -5
  66. package/dist/blocks/ai-cache/index.d.ts +3 -3
  67. package/dist/blocks/ai-cache/index.js +2 -2
  68. package/dist/blocks/ai-chat/index.d.ts +5 -5
  69. package/dist/blocks/ai-chat/index.js +2 -2
  70. package/dist/blocks/ai-chat/react/index.d.ts +2 -2
  71. package/dist/blocks/ai-chat/react/index.js +2 -2
  72. package/dist/blocks/ai-chat/solid/index.d.ts +2 -2
  73. package/dist/blocks/ai-chat/solid/index.js +1 -1
  74. package/dist/blocks/ai-chat/svelte/index.d.ts +2 -2
  75. package/dist/blocks/ai-chat/svelte/index.js +1 -1
  76. package/dist/blocks/ai-chat/vue/index.d.ts +2 -2
  77. package/dist/blocks/ai-chat/vue/index.js +1 -1
  78. package/dist/blocks/ai-files/index.d.ts +5 -5
  79. package/dist/blocks/ai-files/index.js +2 -2
  80. package/dist/blocks/ai-providers/index.d.ts +4 -4
  81. package/dist/blocks/ai-providers/index.js +7 -7
  82. package/dist/blocks/ai-tasks/index.d.ts +3 -3
  83. package/dist/blocks/ai-tasks/index.js +7 -7
  84. package/dist/blocks/announcements/index.d.ts +4 -4
  85. package/dist/blocks/announcements/index.js +2 -2
  86. package/dist/blocks/announcements/react/index.d.ts +1 -1
  87. package/dist/blocks/announcements/react/index.js +2 -2
  88. package/dist/blocks/announcements/solid/index.d.ts +2 -2
  89. package/dist/blocks/announcements/svelte/index.d.ts +2 -2
  90. package/dist/blocks/announcements/vue/index.d.ts +2 -2
  91. package/dist/blocks/api-keys/index.d.ts +7 -7
  92. package/dist/blocks/api-keys/index.js +5 -5
  93. package/dist/blocks/api-keys/react/index.d.ts +1 -1
  94. package/dist/blocks/api-keys/react/index.js +3 -3
  95. package/dist/blocks/api-keys/react/server.d.ts +1 -1
  96. package/dist/blocks/api-keys/solid/index.d.ts +2 -2
  97. package/dist/blocks/api-keys/solid/index.js +1 -1
  98. package/dist/blocks/api-keys/svelte/index.d.ts +2 -2
  99. package/dist/blocks/api-keys/svelte/index.js +1 -1
  100. package/dist/blocks/api-keys/vue/index.d.ts +2 -2
  101. package/dist/blocks/api-keys/vue/index.js +1 -1
  102. package/dist/blocks/approvals/index.d.ts +4 -4
  103. package/dist/blocks/approvals/index.js +6 -6
  104. package/dist/blocks/attachments/index.d.ts +4 -4
  105. package/dist/blocks/attachments/index.js +2 -2
  106. package/dist/blocks/audit/index.d.ts +6 -6
  107. package/dist/blocks/audit/index.js +6 -6
  108. package/dist/blocks/audit/react/index.d.ts +1 -1
  109. package/dist/blocks/audit/react/index.js +2 -2
  110. package/dist/blocks/audit/react/server.d.ts +1 -1
  111. package/dist/blocks/audit/solid/index.d.ts +2 -2
  112. package/dist/blocks/audit/svelte/index.d.ts +2 -2
  113. package/dist/blocks/audit/vue/index.d.ts +2 -2
  114. package/dist/blocks/billing/index.d.ts +26 -10
  115. package/dist/blocks/billing/index.js +43 -10
  116. package/dist/blocks/billing/react/index.d.ts +2 -2
  117. package/dist/blocks/billing/react/index.js +1 -1
  118. package/dist/blocks/billing/react/server.d.ts +1 -1
  119. package/dist/blocks/billing/solid/index.d.ts +2 -2
  120. package/dist/blocks/billing/solid/index.js +1 -1
  121. package/dist/blocks/billing/svelte/index.d.ts +2 -2
  122. package/dist/blocks/billing/svelte/index.js +1 -1
  123. package/dist/blocks/billing/vue/index.d.ts +2 -2
  124. package/dist/blocks/billing/vue/index.js +1 -1
  125. package/dist/blocks/bookings/index.d.ts +3 -3
  126. package/dist/blocks/bookings/index.js +2 -2
  127. package/dist/blocks/bookings/react/index.d.ts +1 -1
  128. package/dist/blocks/bookings/react/index.js +3 -3
  129. package/dist/blocks/bookings/solid/index.d.ts +2 -2
  130. package/dist/blocks/bookings/solid/index.js +1 -1
  131. package/dist/blocks/bookings/svelte/index.d.ts +2 -2
  132. package/dist/blocks/bookings/svelte/index.js +1 -1
  133. package/dist/blocks/bookings/vue/index.d.ts +2 -2
  134. package/dist/blocks/bookings/vue/index.js +1 -1
  135. package/dist/blocks/bulk/index.d.ts +5 -5
  136. package/dist/blocks/bulk/index.js +3 -3
  137. package/dist/blocks/calendar/index.d.ts +3 -3
  138. package/dist/blocks/calendar/index.js +2 -2
  139. package/dist/blocks/calendar/react/index.d.ts +1 -1
  140. package/dist/blocks/calendar/react/index.js +3 -3
  141. package/dist/blocks/calendar/solid/index.d.ts +2 -2
  142. package/dist/blocks/calendar/solid/index.js +1 -1
  143. package/dist/blocks/calendar/svelte/index.d.ts +2 -2
  144. package/dist/blocks/calendar/svelte/index.js +1 -1
  145. package/dist/blocks/calendar/vue/index.d.ts +2 -2
  146. package/dist/blocks/calendar/vue/index.js +1 -1
  147. package/dist/blocks/catalog/index.d.ts +10 -10
  148. package/dist/blocks/catalog/index.js +8 -8
  149. package/dist/blocks/collections/index.d.ts +10 -10
  150. package/dist/blocks/collections/index.js +6 -6
  151. package/dist/blocks/comments/index.d.ts +4 -4
  152. package/dist/blocks/comments/index.js +3 -3
  153. package/dist/blocks/comments/react/index.d.ts +1 -1
  154. package/dist/blocks/comments/react/index.js +3 -3
  155. package/dist/blocks/comments/react/server.d.ts +1 -1
  156. package/dist/blocks/comments/solid/index.d.ts +2 -2
  157. package/dist/blocks/comments/solid/index.js +1 -1
  158. package/dist/blocks/comments/svelte/index.d.ts +2 -2
  159. package/dist/blocks/comments/svelte/index.js +1 -1
  160. package/dist/blocks/comments/vue/index.d.ts +2 -2
  161. package/dist/blocks/comments/vue/index.js +1 -1
  162. package/dist/blocks/connectors/index.d.ts +4 -4
  163. package/dist/blocks/connectors/index.js +7 -7
  164. package/dist/blocks/custom-fields/index.d.ts +6 -6
  165. package/dist/blocks/custom-fields/index.js +4 -4
  166. package/dist/blocks/data-lifecycle/index.d.ts +9 -9
  167. package/dist/blocks/data-lifecycle/index.js +7 -7
  168. package/dist/blocks/deals/index.d.ts +9 -9
  169. package/dist/blocks/deals/index.js +9 -9
  170. package/dist/blocks/documents/index.d.ts +4 -4
  171. package/dist/blocks/documents/index.js +4 -4
  172. package/dist/blocks/domains/index.d.ts +7 -7
  173. package/dist/blocks/domains/index.js +6 -6
  174. package/dist/blocks/drive/index.d.ts +9 -10
  175. package/dist/blocks/drive/index.js +20 -11
  176. package/dist/blocks/employees/index.d.ts +9 -9
  177. package/dist/blocks/employees/index.js +8 -8
  178. package/dist/blocks/engagements/index.d.ts +9 -9
  179. package/dist/blocks/engagements/index.js +5 -5
  180. package/dist/blocks/entitlements/index.d.ts +7 -7
  181. package/dist/blocks/entitlements/index.js +2 -2
  182. package/dist/blocks/entitlements/react/index.d.ts +2 -2
  183. package/dist/blocks/entitlements/solid/index.d.ts +2 -2
  184. package/dist/blocks/entitlements/svelte/index.d.ts +2 -2
  185. package/dist/blocks/entitlements/vue/index.d.ts +2 -2
  186. package/dist/blocks/flags/index.d.ts +8 -8
  187. package/dist/blocks/flags/index.js +6 -6
  188. package/dist/blocks/forms/index.d.ts +9 -9
  189. package/dist/blocks/forms/index.js +5 -5
  190. package/dist/blocks/forms/react/index.d.ts +1 -1
  191. package/dist/blocks/forms/solid/index.d.ts +2 -2
  192. package/dist/blocks/forms/svelte/index.d.ts +2 -2
  193. package/dist/blocks/forms/vue/index.d.ts +2 -2
  194. package/dist/blocks/hiring/index.d.ts +9 -9
  195. package/dist/blocks/hiring/index.js +6 -6
  196. package/dist/blocks/identities/index.d.ts +6 -6
  197. package/dist/blocks/identities/index.js +3 -3
  198. package/dist/blocks/imports/index.d.ts +6 -6
  199. package/dist/blocks/imports/index.js +3 -3
  200. package/dist/blocks/inbox/index.d.ts +5 -5
  201. package/dist/blocks/inbox/index.js +3 -3
  202. package/dist/blocks/inbox/react/index.d.ts +2 -2
  203. package/dist/blocks/inbox/react/server.d.ts +2 -2
  204. package/dist/blocks/inbox/solid/index.d.ts +2 -2
  205. package/dist/blocks/inbox/svelte/index.d.ts +2 -2
  206. package/dist/blocks/inbox/vue/index.d.ts +2 -2
  207. package/dist/blocks/index.d.ts +8 -8
  208. package/dist/blocks/index.js +3 -3
  209. package/dist/blocks/inventory/index.d.ts +9 -9
  210. package/dist/blocks/inventory/index.js +6 -6
  211. package/dist/blocks/invoices/index.d.ts +9 -9
  212. package/dist/blocks/invoices/index.js +8 -8
  213. package/dist/blocks/jobs/index.d.ts +61 -11
  214. package/dist/blocks/jobs/index.js +126 -13
  215. package/dist/blocks/knowledge/index.d.ts +3 -3
  216. package/dist/blocks/knowledge/index.js +2 -2
  217. package/dist/blocks/leave/index.d.ts +8 -8
  218. package/dist/blocks/leave/index.js +5 -5
  219. package/dist/blocks/memory/index.d.ts +4 -4
  220. package/dist/blocks/memory/index.js +6 -6
  221. package/dist/blocks/metrics/index.d.ts +7 -7
  222. package/dist/blocks/metrics/index.js +5 -5
  223. package/dist/blocks/mfa/index.d.ts +2 -2
  224. package/dist/blocks/mfa/index.js +1 -1
  225. package/dist/blocks/mfa/react/index.d.ts +1 -1
  226. package/dist/blocks/mfa/react/index.js +1 -1
  227. package/dist/blocks/mfa/react/server.d.ts +1 -1
  228. package/dist/blocks/mfa/react/server.js +1 -1
  229. package/dist/blocks/mfa/solid/index.d.ts +2 -2
  230. package/dist/blocks/mfa/solid/index.js +1 -1
  231. package/dist/blocks/mfa/svelte/index.d.ts +2 -2
  232. package/dist/blocks/mfa/svelte/index.js +1 -1
  233. package/dist/blocks/mfa/vue/index.d.ts +2 -2
  234. package/dist/blocks/mfa/vue/index.js +1 -1
  235. package/dist/blocks/notifications/index.d.ts +13 -13
  236. package/dist/blocks/notifications/index.js +11 -11
  237. package/dist/blocks/notifications/react/index.d.ts +1 -1
  238. package/dist/blocks/notifications/react/server.d.ts +1 -1
  239. package/dist/blocks/notifications/solid/index.d.ts +2 -2
  240. package/dist/blocks/notifications/svelte/index.d.ts +2 -2
  241. package/dist/blocks/notifications/vue/index.d.ts +2 -2
  242. package/dist/blocks/number-sequences/index.d.ts +5 -5
  243. package/dist/blocks/number-sequences/index.js +2 -2
  244. package/dist/blocks/oauth-server/index.d.ts +28 -8
  245. package/dist/blocks/oauth-server/index.js +24 -15
  246. package/dist/blocks/onboarding/index.d.ts +3 -3
  247. package/dist/blocks/onboarding/index.js +2 -2
  248. package/dist/blocks/onboarding/react/index.d.ts +1 -1
  249. package/dist/blocks/onboarding/react/index.js +2 -2
  250. package/dist/blocks/onboarding/react/server.d.ts +1 -1
  251. package/dist/blocks/onboarding/solid/index.d.ts +2 -2
  252. package/dist/blocks/onboarding/svelte/index.d.ts +2 -2
  253. package/dist/blocks/onboarding/vue/index.d.ts +2 -2
  254. package/dist/blocks/orders/index.d.ts +12 -12
  255. package/dist/blocks/orders/index.js +10 -10
  256. package/dist/blocks/organizations/index.d.ts +5 -5
  257. package/dist/blocks/organizations/index.js +4 -4
  258. package/dist/blocks/organizations/react/index.d.ts +1 -1
  259. package/dist/blocks/organizations/react/index.js +3 -3
  260. package/dist/blocks/organizations/react/server.d.ts +1 -1
  261. package/dist/blocks/organizations/solid/index.d.ts +2 -2
  262. package/dist/blocks/organizations/solid/index.js +1 -1
  263. package/dist/blocks/organizations/svelte/index.d.ts +2 -2
  264. package/dist/blocks/organizations/svelte/index.js +1 -1
  265. package/dist/blocks/organizations/vue/index.d.ts +2 -2
  266. package/dist/blocks/organizations/vue/index.js +1 -1
  267. package/dist/blocks/outbox/index.d.ts +4 -4
  268. package/dist/blocks/outbox/index.js +5 -5
  269. package/dist/blocks/parties/index.d.ts +9 -9
  270. package/dist/blocks/parties/index.js +4 -4
  271. package/dist/blocks/pipelines/index.d.ts +10 -10
  272. package/dist/blocks/pipelines/index.js +7 -7
  273. package/dist/blocks/profiles/index.d.ts +7 -7
  274. package/dist/blocks/profiles/index.js +5 -5
  275. package/dist/blocks/promotions/index.d.ts +9 -9
  276. package/dist/blocks/promotions/index.js +7 -7
  277. package/dist/blocks/push/index.d.ts +9 -9
  278. package/dist/blocks/push/index.js +4 -4
  279. package/dist/blocks/quotes/index.d.ts +9 -9
  280. package/dist/blocks/quotes/index.js +8 -8
  281. package/dist/blocks/rank/index.d.ts +6 -6
  282. package/dist/blocks/rank/index.js +3 -3
  283. package/dist/blocks/reactions/index.d.ts +4 -4
  284. package/dist/blocks/reactions/index.js +2 -2
  285. package/dist/blocks/reactions/react/index.d.ts +1 -1
  286. package/dist/blocks/reactions/react/index.js +2 -2
  287. package/dist/blocks/reactions/solid/index.d.ts +2 -2
  288. package/dist/blocks/reactions/solid/index.js +1 -1
  289. package/dist/blocks/reactions/svelte/index.d.ts +2 -2
  290. package/dist/blocks/reactions/svelte/index.js +1 -1
  291. package/dist/blocks/reactions/vue/index.d.ts +2 -2
  292. package/dist/blocks/reactions/vue/index.js +1 -1
  293. package/dist/blocks/relations/index.d.ts +8 -8
  294. package/dist/blocks/relations/index.js +4 -4
  295. package/dist/blocks/reminders/index.d.ts +10 -10
  296. package/dist/blocks/reminders/index.js +8 -8
  297. package/dist/blocks/reviews/index.d.ts +8 -8
  298. package/dist/blocks/reviews/index.js +5 -5
  299. package/dist/blocks/rules/index.d.ts +9 -9
  300. package/dist/blocks/rules/index.js +5 -5
  301. package/dist/blocks/rules/react/index.d.ts +2 -2
  302. package/dist/blocks/rules/react/index.js +2 -2
  303. package/dist/blocks/rules/solid/index.d.ts +2 -2
  304. package/dist/blocks/rules/svelte/index.d.ts +2 -2
  305. package/dist/blocks/rules/vue/index.d.ts +2 -2
  306. package/dist/blocks/saved-views/index.d.ts +3 -3
  307. package/dist/blocks/saved-views/index.js +1 -1
  308. package/dist/blocks/saved-views/react/index.d.ts +1 -1
  309. package/dist/blocks/saved-views/react/index.js +1 -1
  310. package/dist/blocks/saved-views/react/server.d.ts +1 -1
  311. package/dist/blocks/saved-views/solid/index.d.ts +2 -2
  312. package/dist/blocks/saved-views/solid/index.js +1 -1
  313. package/dist/blocks/saved-views/svelte/index.d.ts +2 -2
  314. package/dist/blocks/saved-views/svelte/index.js +1 -1
  315. package/dist/blocks/saved-views/vue/index.d.ts +2 -2
  316. package/dist/blocks/saved-views/vue/index.js +1 -1
  317. package/dist/blocks/search/index.d.ts +4 -4
  318. package/dist/blocks/search/index.js +3 -3
  319. package/dist/blocks/search/react/index.d.ts +1 -1
  320. package/dist/blocks/search/react/index.js +2 -2
  321. package/dist/blocks/search/react/server.d.ts +1 -1
  322. package/dist/blocks/search/solid/index.d.ts +2 -2
  323. package/dist/blocks/search/svelte/index.d.ts +2 -2
  324. package/dist/blocks/search/vue/index.d.ts +2 -2
  325. package/dist/blocks/service-principals/index.d.ts +8 -8
  326. package/dist/blocks/service-principals/index.js +6 -6
  327. package/dist/blocks/sessions/index.d.ts +2 -2
  328. package/dist/blocks/sessions/index.js +1 -1
  329. package/dist/blocks/sessions/react/index.d.ts +1 -1
  330. package/dist/blocks/sessions/react/index.js +1 -1
  331. package/dist/blocks/sessions/react/server.d.ts +1 -1
  332. package/dist/blocks/sessions/solid/index.d.ts +2 -2
  333. package/dist/blocks/sessions/solid/index.js +1 -1
  334. package/dist/blocks/sessions/svelte/index.d.ts +2 -2
  335. package/dist/blocks/sessions/svelte/index.js +1 -1
  336. package/dist/blocks/sessions/vue/index.d.ts +2 -2
  337. package/dist/blocks/sessions/vue/index.js +1 -1
  338. package/dist/blocks/settings/index.d.ts +4 -4
  339. package/dist/blocks/settings/index.js +3 -3
  340. package/dist/blocks/settings/react/index.d.ts +1 -1
  341. package/dist/blocks/settings/react/index.js +3 -3
  342. package/dist/blocks/settings/react/server.d.ts +1 -1
  343. package/dist/blocks/settings/solid/index.d.ts +2 -2
  344. package/dist/blocks/settings/solid/index.js +1 -1
  345. package/dist/blocks/settings/svelte/index.d.ts +2 -2
  346. package/dist/blocks/settings/svelte/index.js +1 -1
  347. package/dist/blocks/settings/vue/index.d.ts +2 -2
  348. package/dist/blocks/settings/vue/index.js +1 -1
  349. package/dist/blocks/share-links/index.d.ts +7 -7
  350. package/dist/blocks/share-links/index.js +3 -3
  351. package/dist/blocks/shared-signals/index.d.ts +8 -8
  352. package/dist/blocks/shared-signals/index.js +7 -7
  353. package/dist/blocks/signing-keys/index.d.ts +5 -5
  354. package/dist/blocks/signing-keys/index.js +47 -21
  355. package/dist/blocks/sla/index.d.ts +9 -9
  356. package/dist/blocks/sla/index.js +5 -5
  357. package/dist/blocks/sso/index.d.ts +7 -7
  358. package/dist/blocks/sso/index.js +4 -4
  359. package/dist/blocks/state-machine/index.d.ts +5 -5
  360. package/dist/blocks/state-machine/index.js +2 -2
  361. package/dist/blocks/tags/index.d.ts +3 -3
  362. package/dist/blocks/tags/index.js +2 -2
  363. package/dist/blocks/tags/react/index.d.ts +1 -1
  364. package/dist/blocks/tags/react/index.js +3 -3
  365. package/dist/blocks/tags/react/server.d.ts +1 -1
  366. package/dist/blocks/tags/solid/index.d.ts +2 -2
  367. package/dist/blocks/tags/solid/index.js +1 -1
  368. package/dist/blocks/tags/svelte/index.d.ts +2 -2
  369. package/dist/blocks/tags/svelte/index.js +1 -1
  370. package/dist/blocks/tags/vue/index.d.ts +2 -2
  371. package/dist/blocks/tags/vue/index.js +1 -1
  372. package/dist/blocks/targets/index.d.ts +7 -7
  373. package/dist/blocks/targets/index.js +5 -5
  374. package/dist/blocks/teams/index.d.ts +7 -7
  375. package/dist/blocks/teams/index.js +3 -3
  376. package/dist/blocks/templates/index.d.ts +10 -10
  377. package/dist/blocks/templates/index.js +7 -7
  378. package/dist/blocks/time-tracking/index.d.ts +9 -9
  379. package/dist/blocks/time-tracking/index.js +7 -7
  380. package/dist/blocks/trash/index.d.ts +8 -8
  381. package/dist/blocks/trash/index.js +4 -4
  382. package/dist/blocks/undo/index.d.ts +4 -4
  383. package/dist/blocks/undo/index.js +2 -2
  384. package/dist/blocks/undo/react/index.d.ts +1 -1
  385. package/dist/blocks/undo/react/server.d.ts +1 -1
  386. package/dist/blocks/undo/solid/index.d.ts +2 -2
  387. package/dist/blocks/undo/svelte/index.d.ts +2 -2
  388. package/dist/blocks/undo/vue/index.d.ts +2 -2
  389. package/dist/blocks/usage/index.d.ts +4 -4
  390. package/dist/blocks/usage/index.js +2 -2
  391. package/dist/blocks/usage/react/index.d.ts +1 -1
  392. package/dist/blocks/usage/react/index.js +2 -2
  393. package/dist/blocks/usage/react/server.d.ts +1 -1
  394. package/dist/blocks/usage/solid/index.d.ts +2 -2
  395. package/dist/blocks/usage/svelte/index.d.ts +2 -2
  396. package/dist/blocks/usage/vue/index.d.ts +2 -2
  397. package/dist/blocks/vercel-marketplace/index.d.ts +193 -0
  398. package/dist/blocks/vercel-marketplace/index.js +300 -0
  399. package/dist/blocks/versions/index.d.ts +8 -8
  400. package/dist/blocks/versions/index.js +4 -4
  401. package/dist/blocks/waitlist/index.d.ts +9 -9
  402. package/dist/blocks/waitlist/index.js +5 -5
  403. package/dist/blocks/webhooks/index.d.ts +16 -16
  404. package/dist/blocks/webhooks/index.js +15 -15
  405. package/dist/blocks/work-items/index.d.ts +9 -9
  406. package/dist/blocks/work-items/index.js +6 -6
  407. package/dist/blocks/workflow-builder/index.d.ts +8 -8
  408. package/dist/blocks/workflow-builder/index.js +2 -2
  409. package/dist/blocks/workflow-builder/react/index.d.ts +2 -2
  410. package/dist/blocks/workflow-builder/react/index.js +3 -3
  411. package/dist/blocks/workflow-builder/solid/index.d.ts +2 -2
  412. package/dist/blocks/workflow-builder/svelte/index.d.ts +2 -2
  413. package/dist/blocks/workflow-builder/vue/index.d.ts +2 -2
  414. package/dist/blocks/workflows/index.d.ts +5 -5
  415. package/dist/blocks/workflows/index.js +2 -2
  416. package/dist/blocks/workflows/react/index.d.ts +2 -2
  417. package/dist/blocks/workflows/react/index.js +2 -2
  418. package/dist/blocks/workflows/solid/index.d.ts +2 -2
  419. package/dist/blocks/workflows/svelte/index.d.ts +2 -2
  420. package/dist/blocks/workflows/vue/index.d.ts +2 -2
  421. package/dist/{bookings-EJAVAuVz.js → bookings-DQ7P888X.js} +5 -5
  422. package/dist/{storage-api-B4Ib2Zpo.d.ts → bucket-BbePDVwc.d.ts} +235 -219
  423. package/dist/{build-6jmaPAgx.js → build-C-D_vn0U.js} +7 -2
  424. package/dist/{build-Cm0T5MVG.js → build-CT6SPZkI.js} +1 -1
  425. package/dist/{calendar-1J1E5dLq.js → calendar-eqyuQAoy.js} +7 -7
  426. package/dist/chat-sdk/index.d.ts +6 -6
  427. package/dist/chat-sdk/index.js +3 -3
  428. package/dist/chat-sdk/react/index.d.ts +2 -2
  429. package/dist/chat-sdk/react/server.d.ts +2 -2
  430. package/dist/cli/{add-BhI_nXAo.js → add-BcOHumvq.js} +2 -2
  431. package/dist/cli/add-DnAyR9w_.js +1 -0
  432. package/dist/cli/{add-CUS0AiBh.js → add-TT72pQk6.js} +5 -5
  433. package/dist/cli/adopt-BuS-DC7_.js +1 -0
  434. package/dist/cli/{adopt-DwcU6CJd.js → adopt-mbB1bcIG.js} +6 -6
  435. package/dist/cli/{apply-DBXC0Z5I.js → apply-CiBFOFGw.js} +16 -22
  436. package/dist/cli/bin.js +1 -1
  437. package/dist/cli/{blocks-B15ltTFn.js → blocks-5-JGzwXX.js} +1 -1
  438. package/dist/cli/{blocks-BXeqIzWN.js → blocks-DeLQOlUK.js} +1 -1
  439. package/dist/cli/{cache-CPBYJAkb.js → cache-DQwgb3rg.js} +8 -3
  440. package/dist/cli/{catalog-Di15TkM2.js → catalog-Cm6BtquM.js} +2 -1
  441. package/dist/cli/{codemod-CrI33UR2.js → codemod-BzAMX4el.js} +2 -2
  442. package/dist/cli/{command-D_HI1mp1.js → command-dfdVhU_2.js} +39 -1
  443. package/dist/cli/{completion-Vry-Wjw8.js → completion-4lLjtI49.js} +1 -1
  444. package/dist/cli/{completion-En43UcyJ.js → completion-D4InNrxw.js} +2 -2
  445. package/dist/cli/{completion-DzYo025z.js → completion-zsp5s0zI.js} +2 -2
  446. package/dist/cli/{config-DsqQr5z3.js → config-CCyweX7Y.js} +1 -1
  447. package/dist/cli/{config-DyJgo2d9.js → config-DI6ielsx.js} +1 -1
  448. package/dist/cli/{config-Bi_UBxXl.js → config-yZ55rsKZ.js} +17 -5
  449. package/dist/cli/db-TRymMyAW.js +90 -0
  450. package/dist/cli/{design-edit-B-WsnhUF.js → design-edit-0U9iCTiS.js} +29 -2
  451. package/dist/cli/{detect-BeLVeNpA.js → detect-DQsVeBHg.js} +1 -1
  452. package/dist/cli/{doctor-wACp5w6N.js → doctor-DOfy6kjt.js} +332 -108
  453. package/dist/cli/{emit-j0zZ6NE_.js → emit-56LAG_Px.js} +11 -5
  454. package/dist/cli/{env-Ch99nTQw.js → env-B7TWPEt0.js} +1 -1
  455. package/dist/cli/{env-Cf5OTqbK.js → env-C8R7Nf0a.js} +2 -1
  456. package/dist/cli/env-Cmu99uKR.js +1 -0
  457. package/dist/cli/{env-2v9JrxSr.js → env-Dh5K5t2U.js} +33 -32
  458. package/dist/cli/{gen-BhquLu7l.js → gen-D3sC5jDn.js} +11 -11
  459. package/dist/cli/index.d.ts +3 -1
  460. package/dist/cli/index.js +10 -9
  461. package/dist/cli/{init-BwLTO6XG.js → init-DNomoycJ.js} +16 -22
  462. package/dist/cli/{introspect-B-gXAIqs.js → introspect-kYX06Q2g.js} +3 -3
  463. package/dist/cli/{keys-hwtdwdkT.js → keys-B8dIJwwi.js} +2 -2
  464. package/dist/cli/{live-BFfYoE0_.js → live-CkV3d3yp.js} +2 -2
  465. package/dist/cli/{mcp-Bdm2oGmL.js → mcp-DrxB2Wuw.js} +4 -4
  466. package/dist/cli/{metadata-DikbSOE0.js → metadata-BGkle6WM.js} +2 -2
  467. package/dist/cli/{migration-safety-LaGVPPuD.js → migration-safety-DjVpz2D6.js} +1 -1
  468. package/dist/cli/{module-migration-CLkZ8jpw.js → module-migration-CPhuiY8C.js} +1 -1
  469. package/dist/cli/{moved-B7UFO_OM.js → moved-BMQu1YNY.js} +1 -1
  470. package/dist/cli/{parse-CwV5a6dA.js → parse-QzDvMpXH.js} +1 -1
  471. package/dist/cli/{preset-DQ1DxMtI.js → preset-CfIs24cc.js} +1 -1
  472. package/dist/cli/run-Bck-p0MI.js +63 -0
  473. package/dist/cli/{run-DliGNdjI.js → run-BhJKAanr.js} +26 -5
  474. package/dist/cli/{run-BLJj7SuM.js → run-DRZ10srj.js} +52 -43
  475. package/dist/cli/{scaffold-6bv24GSP.js → scaffold-DoURlDEI.js} +3 -3
  476. package/dist/cli/{scaffold-DUz5fa-k.js → scaffold-mzy3OsN5.js} +1 -1
  477. package/dist/cli/seed-C5q4UUIL.js +1 -0
  478. package/dist/cli/{seed-CIJaL1Ao.js → seed-CIdg6s7m.js} +6 -5
  479. package/dist/cli/{shared-CNcvDOLt.js → shared-DKLuA1Tp.js} +2 -2
  480. package/dist/cli/{skills-CaxIQhzW.js → skills-D3zwIlGA.js} +1 -1
  481. package/dist/cli/{snapshot-Dvcx0BSl.js → snapshot-BBKFojqM.js} +4 -4
  482. package/dist/cli/{source-args-BNhagtpw.js → source-args-Cwo7zwvq.js} +8 -2
  483. package/dist/cli/{spec-DRDaIq8f.js → spec-DOgQUZwM.js} +1 -1
  484. package/dist/cli/{spec-BewE6r6J.js → spec-DZeIP9ta.js} +3 -3
  485. package/dist/cli/{sql-BCQt5TDs.js → sql-CL_Lbhwl.js} +2 -2
  486. package/dist/cli/{sql-BBkchli4.js → sql-DLOvvnBV.js} +5 -5
  487. package/dist/cli/stack-env-_uWWNHWq.js +87 -0
  488. package/dist/cli/{stack-status-LeEoCtV1.js → stack-status-_NUgd-g5.js} +43 -3
  489. package/dist/cli/{supabase-toml-DjLgBYEo.js → supabase-toml-BC5sNVKU.js} +1 -1
  490. package/dist/cli/{sync-CJ-ft-tl.js → sync-DBvknfOK.js} +2 -2
  491. package/dist/cli/{version-D1wM9DNb.js → version-B7akdvDv.js} +1 -1
  492. package/dist/cli/{write-Dp1XlAVM.js → write-VZljwoTB.js} +2 -2
  493. package/dist/client/index.d.ts +6 -6
  494. package/dist/client/index.js +4 -4
  495. package/dist/client/native/index.d.ts +6 -6
  496. package/dist/client/native/index.js +4 -4
  497. package/dist/{client-ByGlM0YF.d.ts → client-BAOZuBhz.d.ts} +4 -4
  498. package/dist/{client-fpvgtQKE.js → client-BDO6i2Oe.js} +2 -2
  499. package/dist/{client-Dk8gY9hi.d.ts → client-BJN0IMEp.d.ts} +2 -2
  500. package/dist/{client-Fi8CoJcs.d.ts → client-BMcjLG0V.d.ts} +13 -13
  501. package/dist/{client-B5nnqDmz.d.ts → client-BN_fXOs7.d.ts} +2 -2
  502. package/dist/{client-CpMv4-v5.d.ts → client-BONsuFYf.d.ts} +4 -4
  503. package/dist/{client-Diu2lPbg.d.ts → client-BPn9XhAM.d.ts} +7 -7
  504. package/dist/{client-B0rvMvA8.d.ts → client-BtC-r4hE.d.ts} +3 -3
  505. package/dist/{client-Cgxj38RS.d.ts → client-BuneNd-C.d.ts} +9 -9
  506. package/dist/{client-D0502FgY.js → client-CFKONrrU.js} +4 -4
  507. package/dist/{client-CvITjt-9.js → client-CHR8IBNG.js} +10 -2
  508. package/dist/{client-B9H4BZJh.d.ts → client-CHwNV8Kz.d.ts} +12 -12
  509. package/dist/{client-kKdkLGPB.d.ts → client-CLQHsa-2.d.ts} +2 -2
  510. package/dist/{client-C3dLIsJv.d.ts → client-CMxxwT3N.d.ts} +9 -9
  511. package/dist/{client-C597NIlL.d.ts → client-CU7aNN_B.d.ts} +8 -8
  512. package/dist/{client-DZXFDaQE.d.ts → client-CYEdJKjk.d.ts} +6 -6
  513. package/dist/{client-LVa6yC9u.d.ts → client-CYhSGlCN.d.ts} +5 -5
  514. package/dist/{client-CWs3X4g1.js → client-C_-NZRrg.js} +1 -1
  515. package/dist/{client-kI6vCKVI.js → client-CcPxbHeT.js} +2 -2
  516. package/dist/{client-AxwF58Eo.js → client-CosiUrUb.js} +1 -1
  517. package/dist/{client-CsRpAyIv.d.ts → client-D3gRTNSi.d.ts} +2 -2
  518. package/dist/{client-D727oIVC.js → client-D7T7OLiw.js} +4 -4
  519. package/dist/{client-9zIKhf5D.d.ts → client-DB34f_7i.d.ts} +3 -3
  520. package/dist/{client-CjyTNdt1.d.ts → client-DCawyopp.d.ts} +5 -5
  521. package/dist/{client-BtBkVSk2.d.ts → client-Dqa4XyJ5.d.ts} +7 -7
  522. package/dist/{client-BLKpcAs0.d.ts → client-Dr5h2r9r.d.ts} +3 -3
  523. package/dist/{client-BO9fQgBB.d.ts → client-DrTqKgvy.d.ts} +4 -4
  524. package/dist/{client-13Ii0c0P.js → client-DyfWYU8S.js} +2 -2
  525. package/dist/{client-iB5axfa0.js → client-Dz1jWDA2.js} +3 -3
  526. package/dist/{client-jvtwGFy4.js → client-DzTtOVRR.js} +2 -2
  527. package/dist/{client-B_r4denm.d.ts → client-GCCRI9ge.d.ts} +3 -3
  528. package/dist/{client-DR_YEGnc.d.ts → client-P6v3h7vh.d.ts} +2 -2
  529. package/dist/{client-D9zBl9PT.d.ts → client-P8l8ncxV.d.ts} +7 -7
  530. package/dist/{client-CFeWXNXy.js → client-UnM3e32l.js} +2 -2
  531. package/dist/{client-DG7FwgZD.js → client-arq4daO_.js} +1 -1
  532. package/dist/{client-CmHsfDHU.js → client-eCDPjOMo.js} +6 -6
  533. package/dist/{client-rp7YfOg1.js → client-iaFm0aVf.js} +1 -1
  534. package/dist/{client-WXJwUhr1.d.ts → client-kWg4OqIr.d.ts} +5 -5
  535. package/dist/{client-B7LCXnnY.d.ts → client-tvG258_1.d.ts} +6 -6
  536. package/dist/{client-BaynD5V-.d.ts → client-wKmX-f3r.d.ts} +7 -7
  537. package/dist/{cloud-event-bwsBwVNG.d.ts → cloud-event-DXkNoI6v.d.ts} +1 -1
  538. package/dist/{codecs-C7E_OoiC.js → codecs-D-rpDifG.js} +3 -3
  539. package/dist/{codecs-Bm46sVxr.d.ts → codecs-RwFNK8Jh.d.ts} +2 -2
  540. package/dist/{codegen-2m4SKVdi.d.ts → codegen-C64C0NZG.d.ts} +13 -2
  541. package/dist/{comments-N7Bi-oTW.js → comments-CV5O8q50.js} +5 -5
  542. package/dist/commerce/index.d.ts +2 -2
  543. package/dist/commerce/index.js +6 -6
  544. package/dist/{compiler-C6E3WwIi.d.ts → compiler-D_Gjpw_O.d.ts} +2 -2
  545. package/dist/{compose-CO_cljl3.js → compose-CP0ss-cQ.js} +3 -3
  546. package/dist/{composite-CPV0thLs.js → composite-1kPAxXto.js} +3 -3
  547. package/dist/{composite-DMMA_Whg.d.ts → composite-DzvBL5nb.d.ts} +13 -13
  548. package/dist/config/index.d.ts +4 -4
  549. package/dist/config/index.js +2 -2
  550. package/dist/{config-C4RQDF6t.js → config-DHhQmmuD.js} +22 -1
  551. package/dist/{config-CkyahUjo.js → config-NQmw_wsk.js} +1 -1
  552. package/dist/{connector-Cp8CqssJ.d.ts → connector-D9NMNkv0.d.ts} +1 -1
  553. package/dist/{connectors-CZdfZcIg.d.ts → connectors-BwPNt-ZG.d.ts} +7 -7
  554. package/dist/{context-BDDgjoxz.js → context-BiwgsycK.js} +1 -1
  555. package/dist/{context-CCfX2szU.d.ts → context-Cv3KlxWY.d.ts} +2 -2
  556. package/dist/{controller-CCb9tHw_.d.ts → controller-BZhiIb-N.d.ts} +1 -1
  557. package/dist/cors-h_v7TPxl.js +24 -0
  558. package/dist/cors-kLq6VM06.d.ts +15 -0
  559. package/dist/create/index.d.ts +25 -3
  560. package/dist/create/index.js +1002 -915
  561. package/dist/create/supabase/index.d.ts +1 -1
  562. package/dist/credentials/index.d.ts +5 -5
  563. package/dist/credentials/index.js +8 -8
  564. package/dist/{cron-CUaKTjWC.js → cron-BHdXZFsJ.js} +1 -1
  565. package/dist/{cron-route-BsgbJ-g4.js → cron-route-mTvWhork.js} +3 -3
  566. package/dist/{define-CMcokcZz.js → define-Bu1v781m.js} +82 -16
  567. package/dist/{define-DXTC706J.d.ts → define-DYZnvAbs.d.ts} +96 -43
  568. package/dist/{define-block-BlHQxDIQ.d.ts → define-block-BHxLHLys.d.ts} +7 -7
  569. package/dist/{delegation-Dt8hMJWu.js → delegation-B7uNnz6z.js} +2 -2
  570. package/dist/{documents-BYM2viS0.d.ts → documents-CqtVr2fg.d.ts} +4 -4
  571. package/dist/edge/index.d.ts +27 -38
  572. package/dist/edge/index.js +12 -32
  573. package/dist/elysia/index.d.ts +1 -1
  574. package/dist/elysia/index.js +1 -1
  575. package/dist/{embeddings-Da0w4A_0.d.ts → embeddings-CKhygw4C.d.ts} +1 -1
  576. package/dist/{ended-EcTtzzQJ.d.ts → ended-De6H52nX.d.ts} +2 -2
  577. package/dist/{entitlements-AmYp2KHX.js → entitlements-C8UvF1Rz.js} +3 -3
  578. package/dist/{entitlements-Bn7BTnbg.d.ts → entitlements-CtBGXb3B.d.ts} +2 -2
  579. package/dist/{envelope--7d0Q3Se.js → envelope-C4Z55LKW.js} +4 -4
  580. package/dist/{errors-8i6tSICm.js → errors-BV1SKTVs.js} +15 -1
  581. package/dist/{errors-7MqM7bbV.js → errors-D3BR8iUk.js} +2 -2
  582. package/dist/{escape-like-AUEPn-C5.d.ts → escape-like-B339PlP-.d.ts} +1 -1
  583. package/dist/eve/index.d.ts +5 -5
  584. package/dist/eve/index.js +2 -2
  585. package/dist/{eve-BcEr_hPo.d.ts → eve-B6ru2Bt4.d.ts} +2 -2
  586. package/dist/events/index.d.ts +3 -3
  587. package/dist/{events-CtAHxPal.d.ts → events-P3raDX2E.d.ts} +3 -3
  588. package/dist/{executor-CHRwEYqt.d.ts → executor-BWgJNbGh.d.ts} +1 -1
  589. package/dist/{executor-Cex-1PFp.js → executor-BiB0wMBA.js} +4 -4
  590. package/dist/{executor-BicyP8Nl.d.ts → executor-BnMC0lj3.d.ts} +2 -2
  591. package/dist/{executor-CIxyatuB.d.ts → executor-CvsNcQsa.d.ts} +3 -3
  592. package/dist/{executor-aKUo_Xyb.js → executor-CxGQiQN_.js} +3 -3
  593. package/dist/{executor-DzJQVTE2.d.ts → executor-D1hECPGG.d.ts} +1 -1
  594. package/dist/expo/index.d.ts +11 -9
  595. package/dist/expo/index.js +42 -7
  596. package/dist/expo-sqlite/index.d.ts +3 -3
  597. package/dist/expo-sqlite/index.js +2 -2
  598. package/dist/{field-errors-nFnYWvB0.d.ts → field-errors-Z-sgsdoN.d.ts} +7 -7
  599. package/dist/{filter-evaluate-CEm52E5s.d.ts → filter-evaluate-BJcaL3o1.d.ts} +1 -1
  600. package/dist/{filter-query-D3wOD1P_.d.ts → filter-query-Bc_Qa8V_.d.ts} +1 -1
  601. package/dist/{flags-Dz5PIzFU.d.ts → flags-6KK6Vqkr.d.ts} +3 -3
  602. package/dist/{flags-CtSrkVuW.js → flags-aUR7Rod6.js} +1 -1
  603. package/dist/flags-sdk/index.d.ts +1 -1
  604. package/dist/flags-sdk/index.js +2 -2
  605. package/dist/{framework-C2oL4OaO.d.ts → framework-BQhTsLX-.d.ts} +7 -7
  606. package/dist/{framework-Cfm0IspZ.js → framework-C6PKBgme.js} +2 -2
  607. package/dist/{function-contract-B4c0XuTU.d.ts → function-contract-DWqFl_QO.d.ts} +1 -1
  608. package/dist/{gateway-CJL6ZG17.d.ts → gateway-Bq_tWwxE.d.ts} +4 -4
  609. package/dist/h3/index.d.ts +1 -1
  610. package/dist/h3/index.js +1 -1
  611. package/dist/h3/v1/index.d.ts +1 -1
  612. package/dist/h3/v1/index.js +1 -1
  613. package/dist/{hmac-DCud0myt.js → hmac-BgpThYQW.js} +2 -1
  614. package/dist/hono/index.d.ts +34 -25
  615. package/dist/hono/index.js +18 -12
  616. package/dist/{http-BF-V0CUF.js → http-C7trc6uN.js} +2 -2
  617. package/dist/{impersonation-CDeCzZP6.js → impersonation-DxU6yHJV.js} +1 -1
  618. package/dist/{inbox-BaUJgHOF.d.ts → inbox-Du5aPwKB.d.ts} +4 -4
  619. package/dist/{index-DTQbC3CW.d.ts → index-1Vsg-7YV.d.ts} +1 -1
  620. package/dist/{index-8xwnaWHY.d.ts → index-BJLPQr2s.d.ts} +38 -5
  621. package/dist/{index-DL8z_oDo.d.ts → index-BpyBH5O2.d.ts} +4 -4
  622. package/dist/{index-Ck4oK5vV.d.ts → index-C-_fs7EI.d.ts} +8 -8
  623. package/dist/{index-BurdFUXr.d.ts → index-CXFf-c-j.d.ts} +7 -7
  624. package/dist/{index-MCXVzkXs.d.ts → index-Cm2-g_4H.d.ts} +5 -5
  625. package/dist/{index-DcijDfh1.d.ts → index-DTQSeHx2.d.ts} +4 -4
  626. package/dist/{index-D1kMyNc7.d.ts → index-Hc4tetmB.d.ts} +2 -2
  627. package/dist/{index-gXy3R1Uq.d.ts → index-QWTq2o31.d.ts} +1 -1
  628. package/dist/{index-Cckxs8IE.d.ts → index-XcTBR4Gb.d.ts} +3 -3
  629. package/dist/{index-DMONTkSf.d.ts → index-k-rrfG1g.d.ts} +2 -2
  630. package/dist/{index-Co0YsJTk.d.ts → index-wTnPJUhv.d.ts} +2 -2
  631. package/dist/index.d.ts +13 -13
  632. package/dist/index.js +10 -10
  633. package/dist/jwks-cache-C4rA69hD.js +49 -0
  634. package/dist/{jws-milwSg7E.js → jws-CwBB5QAT.js} +5 -3
  635. package/dist/{kit-BlcEFQql.d.ts → kit-De-EVRhw.d.ts} +4 -4
  636. package/dist/{kit-gqwkVhGU.js → kit-LTbHrWWD.js} +6 -6
  637. package/dist/{knowledge-BYtgA52P.d.ts → knowledge-B5zdpDD-.d.ts} +6 -6
  638. package/dist/{knowledge-CSNKLX-s.js → knowledge-BbdXOJvY.js} +4 -4
  639. package/dist/lint/index.d.ts +1 -1
  640. package/dist/lint/index.js +47 -2
  641. package/dist/list/index.d.ts +3 -3
  642. package/dist/{list-query-DWJIiVz_.d.ts → list-query-aXr2WkGA.d.ts} +5 -5
  643. package/dist/mcp/index.d.ts +21 -21
  644. package/dist/mcp/index.js +10 -10
  645. package/dist/mcp/sdk/index.d.ts +17 -17
  646. package/dist/mcp/sdk/index.js +5 -5
  647. package/dist/{messages-Cx4ttLJJ.js → messages-D5nIfCCf.js} +2 -2
  648. package/dist/{mfa-DtflCXEt.d.ts → mfa-YzkRjNad.d.ts} +1 -1
  649. package/dist/{model-messages-CTu-6kBu.js → model-messages-CIdqdUtk.js} +1 -1
  650. package/dist/{money-codec-DCGgzO26.js → money-codec-C21MWw50.js} +2 -2
  651. package/dist/nestjs/index.d.ts +2 -2
  652. package/dist/nestjs/index.js +1 -1
  653. package/dist/next/index.d.ts +34 -29
  654. package/dist/next/index.js +14 -14
  655. package/dist/node/index.d.ts +2 -2
  656. package/dist/node/index.js +1 -1
  657. package/dist/{onboarding-viTTNWUp.js → onboarding-Du6kCmhF.js} +2 -2
  658. package/dist/openapi/index.d.ts +2 -2
  659. package/dist/openapi/index.js +2 -2
  660. package/dist/{operations-BtuQRwTJ.d.ts → operations-DQCWqkt3.d.ts} +1 -1
  661. package/dist/{options-CZk_fbbg.js → options-BCrqe3HH.js} +2 -1
  662. package/dist/options-CEMawFrr.js +5 -0
  663. package/dist/options-RKYdmIdV.js +5 -0
  664. package/dist/{options-CbSOj53r.d.ts → options-ZQzNKKBS.d.ts} +1 -1
  665. package/dist/{organizations-Bxrm32IG.js → organizations-CO2qg44D.js} +6 -6
  666. package/dist/orpc/index.d.ts +18 -18
  667. package/dist/orpc/index.js +7 -7
  668. package/dist/otel/index.d.ts +2 -2
  669. package/dist/otel/index.js +5 -5
  670. package/dist/{outbox-BCGHl9X6.d.ts → outbox-B1hZ7PPY.d.ts} +6 -6
  671. package/dist/{payments-h45bswA-.js → payments-CzjCdIcz.js} +1 -1
  672. package/dist/{plugin-D5OIaP93.d.ts → plugin-D-95Q0w0.d.ts} +3 -3
  673. package/dist/plugins/actor/index.d.ts +1 -1
  674. package/dist/plugins/actor/index.js +1 -1
  675. package/dist/plugins/rules/index.d.ts +2 -2
  676. package/dist/plugins/rules/index.js +1 -1
  677. package/dist/plugins/soft-delete/index.d.ts +3 -3
  678. package/dist/plugins/soft-delete/index.js +2 -2
  679. package/dist/plugins/tenant/index.d.ts +2 -2
  680. package/dist/plugins/tenant/index.js +2 -2
  681. package/dist/plugins/timestamps/index.d.ts +1 -1
  682. package/dist/plugins/timestamps/index.js +1 -1
  683. package/dist/plugins/validation/index.d.ts +2 -2
  684. package/dist/plugins/validation/index.js +3 -3
  685. package/dist/{pool-BBi4mot3.d.ts → pool-cM3rpOQr.d.ts} +3 -3
  686. package/dist/{pool-errors-C94tPR_G.js → pool-errors-CGqvTQOC.js} +2 -2
  687. package/dist/{ports-Dcnuo3HT.d.ts → ports-BCDIbC_U.d.ts} +2 -2
  688. package/dist/{ports-B53rB7zg.d.ts → ports-P0A5wo_-.d.ts} +11 -11
  689. package/dist/{ports-Bcdppx0G.js → ports-aALjot-D.js} +11 -7
  690. package/dist/postgres/index.d.ts +5 -5
  691. package/dist/postgres/index.js +3 -3
  692. package/dist/{postgrest-D6fEMsp4.d.ts → postgrest-CjnO1hbr.d.ts} +1 -1
  693. package/dist/powersync/index.d.ts +4 -4
  694. package/dist/powersync/index.js +4 -4
  695. package/dist/powersync/react/index.d.ts +3 -3
  696. package/dist/powersync/react/index.js +1 -1
  697. package/dist/preset/index.d.ts +4 -4
  698. package/dist/preset/index.js +3 -3
  699. package/dist/{preset-BBrL6_Ln.js → preset-Cf0T9GRt.js} +49 -6
  700. package/dist/{problem-CEjyhV5T.d.ts → problem-DCDIQiTA.d.ts} +1 -1
  701. package/dist/{problem-pIiL3WbE.js → problem-JRCohp1j.js} +1 -1
  702. package/dist/{provider-DKh2xFZb.js → provider-C-Ti38J6.js} +1 -1
  703. package/dist/{provider-CQ1SrhLa.d.ts → provider-DXgx5oSA.d.ts} +2 -2
  704. package/dist/{push-token-CDMgWT13.d.ts → push-token-y1Gnz5bQ.d.ts} +1 -1
  705. package/dist/query/index.d.ts +2 -2
  706. package/dist/{rank-result-Dngpt2n5.d.ts → rank-result-BcYfDA0x.d.ts} +1 -1
  707. package/dist/{rank-result-oUF1DYBm.js → rank-result-DtQuIvob.js} +2 -2
  708. package/dist/{rate-limit-BtbddDnE.js → rate-limit-DVZ7qIzW.js} +1 -1
  709. package/dist/{rate-limit-ByfWNX9N.js → rate-limit-I3AncmM8.js} +8 -8
  710. package/dist/{rate-limit-C88MEAOm.d.ts → rate-limit-c6c1mB6R.d.ts} +2 -2
  711. package/dist/react/index.d.ts +8 -8
  712. package/dist/react/index.js +2 -2
  713. package/dist/react/native/index.d.ts +1 -1
  714. package/dist/react/native/index.js +1 -1
  715. package/dist/react/server.d.ts +9 -9
  716. package/dist/react/server.js +2 -2
  717. package/dist/react/session.d.ts +2 -2
  718. package/dist/{react-BcKACxsj.js → react-DzukE6Wp.js} +3 -3
  719. package/dist/react-router/index.d.ts +11 -11
  720. package/dist/react-router/index.js +6 -6
  721. package/dist/{read-set-PWiJfv6S.js → read-set-DeesfeL_.js} +2 -2
  722. package/dist/realtime/index.d.ts +6 -6
  723. package/dist/realtime/index.js +2 -2
  724. package/dist/{refusal-Bdr1k47u.d.ts → refusal-C7geIBRl.d.ts} +1 -1
  725. package/dist/{refusal-Ch-u9dVd.js → refusal-CFpfmjcS.js} +4 -4
  726. package/dist/{resolve-CAR9oaKW.js → resolve-AtncaPTU.js} +17 -9
  727. package/dist/{resolve-7atr-wWr.d.ts → resolve-Ceft-18-.d.ts} +9 -5
  728. package/dist/{resource-CHGOmg1O.js → resource-Bdkqi8jo.js} +6 -6
  729. package/dist/{resource-DxcgtHq6.d.ts → resource-DYEtc-KN.d.ts} +1 -1
  730. package/dist/{resource-execute-C45ICrN9.d.ts → resource-execute-Bxvgmx-n.d.ts} +2 -2
  731. package/dist/{resource-types-CC59gMHE.d.ts → resource-types-LW1i5-h3.d.ts} +6 -6
  732. package/dist/{resources-B7htXQeg.js → resources-Ck7itNeX.js} +3 -3
  733. package/dist/{resources-B71O7EVQ.d.ts → resources-D3_FAz_H.d.ts} +2 -2
  734. package/dist/{respond-Cdg5ibH5.d.ts → respond-BSL36dQp.d.ts} +3 -3
  735. package/dist/{respond-Dpx48ATq.js → respond-Bhp3G__q.js} +5 -5
  736. package/dist/{result-Cj3yWhjH.d.ts → result-BREt7qOh.d.ts} +15 -1
  737. package/dist/{result-COkvI9t5.js → result-DIeYscA3.js} +1 -1
  738. package/dist/{rrule-zBh3CA1r.js → rrule-Cw4x4Pf_.js} +1 -1
  739. package/dist/{rules-4of_Fq-6.js → rules-BiQgmZ_U.js} +4 -4
  740. package/dist/{sales-lines-CymdiwYd.js → sales-lines-CQ1iC6QM.js} +3 -3
  741. package/dist/{sales-shared-DjCuN8xG.js → sales-shared-CDSytDEn.js} +2 -2
  742. package/dist/{search-LbjCylX5.js → search-ZP13UTT4.js} +3 -3
  743. package/dist/server/index.d.ts +38 -30
  744. package/dist/server/index.js +19 -64
  745. package/dist/{server-types-fXwJoFjt.d.ts → server-types-fLdep4gb.d.ts} +50 -30
  746. package/dist/{session-Djo5t4KQ.d.ts → session-DObioXpX.d.ts} +11 -11
  747. package/dist/{settings-DxXfDUmh.js → settings-BiHDFglz.js} +5 -5
  748. package/dist/{shared-9B02lczf.js → shared-C9zvURqC.js} +1 -1
  749. package/dist/{shared-as0EG51f.js → shared-D5Djh43x.js} +1 -1
  750. package/dist/{sign-in-D0xN6E_l.js → sign-in-z2BaBdps.js} +10 -3
  751. package/dist/{signatures-BMdJ7neI.d.ts → signatures-BXlDXV3D.d.ts} +1 -1
  752. package/dist/{signatures-C9CGYZS1.js → signatures-CeIoAelK.js} +5 -5
  753. package/dist/{signers-BjSgNAXP.d.ts → signers-BwKV-9S6.d.ts} +6 -6
  754. package/dist/{signing-keys-Ccr86Y2C.d.ts → signing-keys-v2MRYkDF.d.ts} +20 -5
  755. package/dist/solid/index.d.ts +8 -8
  756. package/dist/solid/index.js +1 -1
  757. package/dist/{solid-controller-CZrt1Tg6.d.ts → solid-controller-CWotGxcG.d.ts} +1 -1
  758. package/dist/solid-start/index.d.ts +11 -11
  759. package/dist/solid-start/index.js +5 -5
  760. package/dist/spec/index.d.ts +3 -3
  761. package/dist/spec/index.js +3 -3
  762. package/dist/sql/index.d.ts +4 -4
  763. package/dist/sql/index.js +2 -2
  764. package/dist/{sql-BQshMgmB.js → sql-BPKRNutj.js} +3 -3
  765. package/dist/{sql-CgTZOQZ7.js → sql-CT1Jnwp8.js} +1919 -698
  766. package/dist/{sso-CwAnve68.js → sso-BaU_6ePE.js} +4 -4
  767. package/dist/{sso-B5ZoEsXE.d.ts → sso-Bu0mVh0V.d.ts} +4 -4
  768. package/dist/ssr/index.d.ts +4 -4
  769. package/dist/ssr/index.js +3 -3
  770. package/dist/{standard-DZmwmIhV.js → standard-B1BigegP.js} +2 -2
  771. package/dist/{standard-C3_AAF3g.d.ts → standard-BcUQuUgu.d.ts} +1 -1
  772. package/dist/{stats-CUhqw6Ev.js → stats-Di5VAsYU.js} +4 -4
  773. package/dist/storage/index.d.ts +3 -3
  774. package/dist/storage/index.js +17 -6
  775. package/dist/{store-B5qYKsTh.d.ts → store-B18bIvKc.d.ts} +1 -1
  776. package/dist/streams/index.d.ts +3 -3
  777. package/dist/streams/index.js +3 -3
  778. package/dist/streams/redis/index.d.ts +1 -1
  779. package/dist/streams/redis/index.js +2 -2
  780. package/dist/{subject-readers-81xiWh4M.d.ts → subject-readers-BUChuOxL.d.ts} +2 -2
  781. package/dist/{subject-readers-DDyPTIOr.js → subject-readers-BpwUFJtp.js} +1 -1
  782. package/dist/{support-BsqhV6jP.js → support-C2wPYwD7.js} +8 -8
  783. package/dist/{support-view-CznLe4jq.d.ts → support-view-Bj_lZ8Wr.d.ts} +1 -1
  784. package/dist/svelte/index.d.ts +7 -7
  785. package/dist/svelte/index.js +1 -1
  786. package/dist/{svelte-controller-DDbju9CW.d.ts → svelte-controller-sS4X66yL.d.ts} +1 -1
  787. package/dist/sveltekit/index.d.ts +13 -13
  788. package/dist/sveltekit/index.js +7 -7
  789. package/dist/{tags-DGldvcA4.js → tags-BqgaxCnv.js} +5 -5
  790. package/dist/{tags-7NHyD1P8.d.ts → tags-BrGopDVG.d.ts} +1 -1
  791. package/dist/tanstack-db/index.d.ts +2 -2
  792. package/dist/tanstack-db/supabase/index.d.ts +2 -2
  793. package/dist/tanstack-start/index.d.ts +11 -11
  794. package/dist/tanstack-start/index.js +5 -5
  795. package/dist/{tax-DDZUB_oc.d.ts → tax-DMWDUzKt.d.ts} +2 -2
  796. package/dist/{tax-DZDpMMRw.js → tax-wm9g2mD2.js} +2 -2
  797. package/dist/{tee-CdRV1tcj.js → tee-Cw-iJAWL.js} +1 -1
  798. package/dist/{template-DdgYjIZ5.js → template-Dw3dTmKe.js} +1 -1
  799. package/dist/{temporal-required-DqRzr7i0.js → temporal-required-nfZ87U-0.js} +1 -1
  800. package/dist/{tenant-DW_GmsW4.d.ts → tenant-DZMLVuyQ.d.ts} +2 -2
  801. package/dist/testing/index.d.ts +134 -60
  802. package/dist/testing/index.js +251 -120
  803. package/dist/{topic-Dgs-eSYQ.d.ts → topic-DAY_HOX2.d.ts} +20 -6
  804. package/dist/{topic-DB-1YTMj.js → topic-mee21pux.js} +85 -17
  805. package/dist/{types-C_GN-4ed.d.ts → types-BA1eTvy4.d.ts} +5 -5
  806. package/dist/{types-P1S1cj6N.d.ts → types-BEEFkNFY.d.ts} +7 -7
  807. package/dist/{types-DZj8CZMH.d.ts → types-Bels39_u.d.ts} +10 -10
  808. package/dist/{types-BO8lVTun.d.ts → types-BrpW5ixT.d.ts} +8 -1
  809. package/dist/{types-DM8q3IOr.d.ts → types-DOC7wnh6.d.ts} +17 -8
  810. package/dist/{types-DOaUIJxW.d.ts → types-D_2rClz-.d.ts} +5 -5
  811. package/dist/{undo-0qM13zul.js → undo-B5LgpGLy.js} +4 -4
  812. package/dist/{undo-D42sPjCf.d.ts → undo-BsdYRox7.d.ts} +3 -3
  813. package/dist/upload-claim-BBFCZbBF.js +33 -0
  814. package/dist/{usage-CnQHSM_r.d.ts → usage-C504GF55.d.ts} +23 -5
  815. package/dist/{usage-BrJGPvCq.js → usage-DdqT13_X.js} +14 -3
  816. package/dist/{vault-EnOQJWjn.d.ts → vault-ClkzMGTP.d.ts} +3 -3
  817. package/dist/vercel-connect/index.d.ts +1 -1
  818. package/dist/vercel-connect/index.js +2 -2
  819. package/dist/{verify-3NLjUIER.d.ts → verify-DU4p9-Ve.d.ts} +4 -4
  820. package/dist/{verify-C9D_jjsQ.js → verify-DnU-uWU2.js} +5 -5
  821. package/dist/{version-Bxj_xcUY.js → version-DSWxci83.js} +1 -1
  822. package/dist/{view-DZ63nqwt.js → view-CYX1wsgp.js} +3 -3
  823. package/dist/{view-SuASaomx.d.ts → view-KQhe6eNc.d.ts} +3 -3
  824. package/dist/vue/index.d.ts +8 -8
  825. package/dist/vue/index.js +1 -1
  826. package/dist/{vue-controller-D_ohttBZ.d.ts → vue-controller-BUo1oove.d.ts} +1 -1
  827. package/dist/{watch-D1wwzZ04.d.ts → watch-5btote1y.d.ts} +6 -6
  828. package/dist/{watch-Blj1mQ9n.js → watch-BAuIzC2r.js} +1 -1
  829. package/dist/{watch-topic-D-rpUg5n.d.ts → watch-topic-C79ZW5-R.d.ts} +1 -1
  830. package/dist/{wire-DEY0ajW9.js → wire-BCJxCtHS.js} +2 -2
  831. package/dist/{workflow-builder-C5DBN7yq.js → workflow-builder-CynLqc6H.js} +7 -7
  832. package/dist/workflow-sdk/builder/index.d.ts +3 -3
  833. package/dist/workflow-sdk/builder/index.js +1 -1
  834. package/dist/workflow-sdk/index.d.ts +1 -1
  835. package/dist/workflow-sdk/index.js +1 -1
  836. package/dist/workflow-sdk/world/index.d.ts +1 -1
  837. package/dist/workflow-sdk/world/index.js +6 -6
  838. package/dist/{workflow-sdk-Di5pmCAu.d.ts → workflow-sdk-CWdCWj7M.d.ts} +3 -3
  839. package/dist/{workflow-sdk-vjDWlnfX.js → workflow-sdk-QnnzIQRc.js} +2 -2
  840. package/dist/{workflow-sdk-world-DPMdBfzn.js → workflow-sdk-world-QzcxaaCD.js} +1 -1
  841. package/dist/{workflows-DJXoxDZH.d.ts → workflows-DQBCzrHC.d.ts} +4 -4
  842. package/dist/{workflows-DzdX28KN.js → workflows-H9qJge3f.js} +5 -5
  843. package/dist/yjs/index.d.ts +3 -3
  844. package/dist/yjs/index.js +3 -3
  845. package/package.json +10 -1
  846. package/schemas/cli-commands-v1.json +15 -0
  847. package/schemas/config-v1.json +47 -3
  848. package/schemas/doctor-report-v1.json +4 -0
  849. package/schemas/snapshot-v2.json +4 -0
  850. package/dist/cli/add-ojbcMxyp.js +0 -1
  851. package/dist/cli/adopt-D0ASVx2G.js +0 -1
  852. package/dist/cli/env-DkBe35Rv.js +0 -1
  853. package/dist/cli/seed-ClGWseBT.js +0 -1
@@ -1,8 +1,8 @@
1
- import { c as PRESET_CATALOG, i as presetOf, s as resolvePreset } from "../config-C4RQDF6t.js";
1
+ import { c as PRESET_CATALOG, h as encodePreset, i as presetOf, s as resolvePreset } from "../config-DHhQmmuD.js";
2
2
  import { a as appDefaultError, c as appReservedColumns, o as appIdentifierError, p as isAppDefault, s as appNameLengthError, x as APP_ON_DELETE_ACTIONS } from "../app-tables-BRjMcWhW.js";
3
- import { o as resolveConfig } from "../config-CkyahUjo.js";
4
- import { c as designConfig, n as diffDesigns } from "../preset-BBrL6_Ln.js";
5
- import { E as SQL_MODULES, i as moduleLayout, m as renderModules } from "../sql-CgTZOQZ7.js";
3
+ import { o as resolveConfig } from "../config-NQmw_wsk.js";
4
+ import { _ as parseDesign, a as DesignTooLongError, h as encodeDesign, l as designConfig, m as designOf, n as diffDesigns } from "../preset-Cf0T9GRt.js";
5
+ import { E as SQL_MODULES, i as moduleLayout, m as renderModules } from "../sql-CT1Jnwp8.js";
6
6
  //#region src/create/column-keys.ts
7
7
  /** The most options a select takes, and the longest option. */
8
8
  const MAX_OPTIONS = 100;
@@ -993,418 +993,6 @@ function withDesign(data, design, preset) {
993
993
  };
994
994
  }
995
995
  //#endregion
996
- //#region src/create/column-kinds.ts
997
- /** The groups of the column type picker, in the order it shows them. */
998
- const KIND_GROUPS = [
999
- "Text",
1000
- "Number",
1001
- "Date and time",
1002
- "Choice",
1003
- "Relation",
1004
- "Other"
1005
- ];
1006
- const USERS$1 = "auth.users";
1007
- /** The first options a new select gets, for the user to rename. */
1008
- const STARTER_OPTIONS = ["Option A", "Option B"];
1009
- const COLUMN_KINDS = [
1010
- {
1011
- id: "text",
1012
- label: "Text",
1013
- group: "Text",
1014
- short: "text",
1015
- column: { type: "text" }
1016
- },
1017
- {
1018
- id: "long_text",
1019
- label: "Long text",
1020
- group: "Text",
1021
- short: "long text",
1022
- column: {
1023
- type: "text",
1024
- format: "long_text"
1025
- }
1026
- },
1027
- {
1028
- id: "email",
1029
- label: "Email",
1030
- group: "Text",
1031
- short: "email",
1032
- column: {
1033
- type: "text",
1034
- format: "email"
1035
- }
1036
- },
1037
- {
1038
- id: "url",
1039
- label: "URL",
1040
- group: "Text",
1041
- short: "url",
1042
- column: {
1043
- type: "text",
1044
- format: "url"
1045
- }
1046
- },
1047
- {
1048
- id: "phone",
1049
- label: "Phone",
1050
- group: "Text",
1051
- short: "phone",
1052
- column: {
1053
- type: "text",
1054
- format: "phone"
1055
- }
1056
- },
1057
- {
1058
- id: "color",
1059
- label: "Color",
1060
- group: "Text",
1061
- short: "color",
1062
- column: {
1063
- type: "text",
1064
- format: "color"
1065
- }
1066
- },
1067
- {
1068
- id: "integer",
1069
- label: "Whole number",
1070
- group: "Number",
1071
- short: "integer",
1072
- column: { type: "integer" }
1073
- },
1074
- {
1075
- id: "bigint",
1076
- label: "Large whole number",
1077
- group: "Number",
1078
- short: "bigint",
1079
- column: { type: "bigint" }
1080
- },
1081
- {
1082
- id: "numeric",
1083
- label: "Decimal",
1084
- group: "Number",
1085
- short: "numeric",
1086
- column: { type: "numeric" }
1087
- },
1088
- {
1089
- id: "rating",
1090
- label: "Rating",
1091
- group: "Number",
1092
- short: "rating",
1093
- column: {
1094
- type: "integer",
1095
- format: "rating"
1096
- }
1097
- },
1098
- {
1099
- id: "percent",
1100
- label: "Percent",
1101
- group: "Number",
1102
- short: "percent",
1103
- column: {
1104
- type: "numeric",
1105
- format: "percent"
1106
- }
1107
- },
1108
- {
1109
- id: "currency",
1110
- label: "Currency",
1111
- group: "Number",
1112
- short: "money",
1113
- column: {
1114
- type: "bigint",
1115
- format: "currency"
1116
- }
1117
- },
1118
- {
1119
- id: "autonumber",
1120
- label: "Autonumber",
1121
- group: "Number",
1122
- short: "autonumber",
1123
- column: {
1124
- type: "bigint",
1125
- identity: true
1126
- }
1127
- },
1128
- {
1129
- id: "date",
1130
- label: "Date",
1131
- group: "Date and time",
1132
- short: "date",
1133
- column: { type: "date" }
1134
- },
1135
- {
1136
- id: "timestamptz",
1137
- label: "Date and time",
1138
- group: "Date and time",
1139
- short: "timestamptz",
1140
- column: { type: "timestamptz" }
1141
- },
1142
- {
1143
- id: "boolean",
1144
- label: "Yes or no",
1145
- group: "Choice",
1146
- short: "boolean",
1147
- column: { type: "boolean" }
1148
- },
1149
- {
1150
- id: "single_select",
1151
- label: "Single select",
1152
- group: "Choice",
1153
- short: "select",
1154
- column: {
1155
- type: "text",
1156
- options: STARTER_OPTIONS
1157
- }
1158
- },
1159
- {
1160
- id: "multi_select",
1161
- label: "Multi-select",
1162
- group: "Choice",
1163
- short: "multi-select",
1164
- column: {
1165
- type: "text[]",
1166
- options: STARTER_OPTIONS
1167
- }
1168
- },
1169
- {
1170
- id: "person",
1171
- label: "Person",
1172
- group: "Relation",
1173
- short: "person",
1174
- column: {
1175
- type: "uuid",
1176
- nullable: true,
1177
- references: {
1178
- table: USERS$1,
1179
- onDelete: "set null"
1180
- }
1181
- }
1182
- },
1183
- {
1184
- id: "reference",
1185
- label: "Link to a table",
1186
- group: "Relation",
1187
- short: "link",
1188
- column: { type: "uuid" },
1189
- drawn: true
1190
- },
1191
- {
1192
- id: "uuid",
1193
- label: "UUID",
1194
- group: "Other",
1195
- short: "uuid",
1196
- column: { type: "uuid" }
1197
- },
1198
- {
1199
- id: "jsonb",
1200
- label: "JSON",
1201
- group: "Other",
1202
- short: "jsonb",
1203
- column: { type: "jsonb" }
1204
- },
1205
- {
1206
- id: "text_list",
1207
- label: "List of text",
1208
- group: "Other",
1209
- short: "text[]",
1210
- column: { type: "text[]" }
1211
- }
1212
- ];
1213
- const BY_ID = new Map(COLUMN_KINDS.map((kind) => [kind.id, kind]));
1214
- const BY_FORMAT = new Map(COLUMN_KINDS.filter((kind) => kind.column.format !== void 0).map((kind) => [kind.column.format, kind]));
1215
- const PLAIN = {
1216
- text: "text",
1217
- uuid: "uuid",
1218
- integer: "integer",
1219
- bigint: "bigint",
1220
- numeric: "numeric",
1221
- boolean: "boolean",
1222
- timestamptz: "timestamptz",
1223
- date: "date",
1224
- jsonb: "jsonb",
1225
- "text[]": "text_list"
1226
- };
1227
- function kindById(id) {
1228
- return BY_ID.get(id);
1229
- }
1230
- /** The kind a column's identity, reference or options make it, before its format and type. */
1231
- function structuralKind(column) {
1232
- if (column.identity === true) return "autonumber";
1233
- if (column.references !== void 0) return column.references.block === void 0 && column.references.table === USERS$1 ? "person" : "reference";
1234
- if (column.options === void 0) return;
1235
- return column.type === "text[]" ? "multi_select" : "single_select";
1236
- }
1237
- /** The picker choice a column reads as. */
1238
- function kindOf(column) {
1239
- const id = structuralKind(column);
1240
- return (id === void 0 ? void 0 : BY_ID.get(id)) ?? (column.format === void 0 ? void 0 : BY_FORMAT.get(column.format)) ?? BY_ID.get(PLAIN[column.type]);
1241
- }
1242
- /**
1243
- * `column` as `kind`: the kind's keys, with the column's name-independent
1244
- * settings (required, unique, comment, a default and bounds that still fit)
1245
- * kept, and a select's options kept when it turns into the other select.
1246
- */
1247
- function withKind(column, kind) {
1248
- const { format: _format, options, identity: _identity, references: _references, min, max, ...rest } = column;
1249
- const kept = kind.column.options === void 0 || options === void 0 ? kind.column : {
1250
- ...kind.column,
1251
- options
1252
- };
1253
- return fitted(withBounds({
1254
- ...rest,
1255
- ...kept
1256
- }, column.type === kind.column.type ? {
1257
- min,
1258
- max
1259
- } : {}));
1260
- }
1261
- /** The money columns of `name`: `<stem>_minor` and `<stem>_currency`. */
1262
- function moneyColumns(name) {
1263
- const stem = name.replace(/_minor$/u, "");
1264
- return {
1265
- minor: `${stem}_minor`,
1266
- currency: `${stem}_currency`
1267
- };
1268
- }
1269
- /**
1270
- * Sets an app table column to `kind`. Currency keeps money as two columns:
1271
- * the column becomes `<name>_minor` (unless the name is taken) and a
1272
- * `<name>_currency` text column of 3 characters joins it. Returns the
1273
- * column's name after the change.
1274
- */
1275
- function setColumnKind(design, table, name, kind) {
1276
- const columns = design.appTables?.[table]?.columns ?? {};
1277
- const column = columns[name];
1278
- if (column === void 0) return {
1279
- design,
1280
- name
1281
- };
1282
- const next = withKind(column, kind);
1283
- if (kind.id !== "currency") return {
1284
- design: setColumn(design, table, name, next),
1285
- name
1286
- };
1287
- const { minor, currency } = moneyColumns(name);
1288
- const renamed = minor === name || columns[minor] === void 0 ? minor : name;
1289
- const moved = setColumn(renameColumn(design, table, name, renamed), table, renamed, next);
1290
- if (columns[currency] !== void 0) return {
1291
- design: moved,
1292
- name: renamed
1293
- };
1294
- return {
1295
- design: setColumn(moved, table, currency, next.nullable === false ? {
1296
- type: "text",
1297
- nullable: false,
1298
- min: 3,
1299
- max: 3
1300
- } : {
1301
- type: "text",
1302
- min: 3,
1303
- max: 3
1304
- }),
1305
- name: renamed
1306
- };
1307
- }
1308
- //#endregion
1309
- //#region src/create/deploy.ts
1310
- /** The name the deploy gives its migration in `supabase_migrations`. */
1311
- const MIGRATION_NAME = "better_supabase_blocks";
1312
- /**
1313
- * Why this preset can't be deployed, or `undefined` when it can. With
1314
- * `access: "provider"` the preview renders a stand-in provider whose
1315
- * functions no real project has.
1316
- */
1317
- function deployBlocker(preset) {
1318
- return preset.access === "provider" ? "Bring your own authorization provider: its SQL comes from the provider, so deploy it with the CLI." : void 0;
1319
- }
1320
- /**
1321
- * The SQL of one migration for the rendered files: every schema file, then
1322
- * every data file, each in render order, which is the order `sql sync` and
1323
- * `sql data` apply them. pgTAP tests stay out.
1324
- */
1325
- function deployQuery(files) {
1326
- const schema = files.filter((file) => file.path.includes("/schemas/"));
1327
- const data = files.filter((file) => file.path.includes("/better-supabase-data/"));
1328
- return [...schema, ...data].map((file) => `-- ${file.path}\n${file.contents.trim()}\n`).join("\n");
1329
- }
1330
- /** A database password for a new project: 32 base64url characters. */
1331
- function generatePassword() {
1332
- const bytes = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(24));
1333
- let binary = "";
1334
- for (const byte of bytes) binary += String.fromCodePoint(byte);
1335
- return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/u, "");
1336
- }
1337
- /** The project name the dialog suggests: the preset's name, or `my-app`. */
1338
- function suggestedProjectName(named) {
1339
- return named === void 0 ? "my-app" : `my-${named}-app`;
1340
- }
1341
- const DASHBOARD = "https://supabase.com/dashboard";
1342
- function dashboardUrl(ref, page = "") {
1343
- return `${DASHBOARD}/project/${encodeURIComponent(ref)}${page}`;
1344
- }
1345
- //#endregion
1346
- //#region src/create/design-history.ts
1347
- /** How many steps Undo can go back. */
1348
- const HISTORY_LIMIT = 50;
1349
- function initialHistory(value) {
1350
- return {
1351
- past: [],
1352
- present: value,
1353
- future: [],
1354
- dragStart: null
1355
- };
1356
- }
1357
- function record(history, previous, next) {
1358
- return {
1359
- past: [...history.past, previous].slice(-50),
1360
- present: next,
1361
- future: [],
1362
- dragStart: null
1363
- };
1364
- }
1365
- /**
1366
- * An undo history. `drag` updates the value without a step while the
1367
- * pointer moves; `commitDrag` records the whole drag as one step. `amend`
1368
- * replaces the value in the current step, so a follow-up such as placing a
1369
- * dropped block stays part of the step that added it. `reset` replaces the
1370
- * value and clears the history, as loading a link does.
1371
- */
1372
- function undoHistory(current, action) {
1373
- switch (action.type) {
1374
- case "apply": return action.value === current.present ? current : record(current, current.dragStart ?? current.present, action.value);
1375
- case "drag": return {
1376
- ...current,
1377
- present: action.value,
1378
- dragStart: current.dragStart ?? current.present
1379
- };
1380
- case "commitDrag": return current.dragStart === null ? current : record(current, current.dragStart, current.present);
1381
- case "amend": return {
1382
- ...current,
1383
- present: action.value
1384
- };
1385
- case "undo": {
1386
- const previous = current.past.at(-1);
1387
- return previous === void 0 ? current : {
1388
- past: current.past.slice(0, -1),
1389
- present: previous,
1390
- future: [current.present, ...current.future],
1391
- dragStart: null
1392
- };
1393
- }
1394
- case "redo": {
1395
- const [next, ...future] = current.future;
1396
- return next === void 0 ? current : {
1397
- past: [...current.past, current.present].slice(-50),
1398
- present: next,
1399
- future,
1400
- dragStart: null
1401
- };
1402
- }
1403
- case "reset": return initialHistory(action.value);
1404
- default: return action;
1405
- }
1406
- }
1407
- //#endregion
1408
996
  //#region src/create/preview-provider.ts
1409
997
  /**
1410
998
  * A stand-in for the app's authorization provider, so `/create` can render
@@ -1444,567 +1032,1066 @@ function previewFiles(code, design = {}) {
1444
1032
  }));
1445
1033
  }
1446
1034
  //#endregion
1447
- //#region src/create/sample-rows.ts
1448
- const SAMPLE_ROW_COUNT = 8;
1449
- /** The columns of `table` a `viewer` can't select: `access: "server"` ones for a member. */
1450
- function hiddenColumns(table, viewer) {
1451
- if (viewer === "server") return [];
1452
- return Object.entries(table?.columns ?? {}).filter(([, column]) => column.access === "server").map(([key]) => key);
1035
+ //#region src/create/schema-meta.ts
1036
+ const AUTH_USERS = "auth.users";
1037
+ /** The tenant name the module defaults use, which a preset's tenant name replaces. */
1038
+ const DEFAULT_TENANT = "organization";
1039
+ /**
1040
+ * Finds the parsed table for a module's logical table by its default name,
1041
+ * or by that name with the tenant renamed (`organizations` is `workspaces`
1042
+ * for the `workspace` tenant).
1043
+ */
1044
+ function indexTables(tables, tenantName) {
1045
+ const byName = new Map(tables.map((table) => [`${table.module}:${table.name}`, table]));
1046
+ return (module, name) => byName.get(`${module}:${name}`) ?? byName.get(`${module}:${name.replaceAll(DEFAULT_TENANT, tenantName)}`);
1453
1047
  }
1454
- const USERS = "auth.users";
1455
- const PEOPLE = [
1456
- "Ada Lovelace",
1457
- "Grace Hopper",
1458
- "Alan Turing",
1459
- "Katherine Johnson",
1460
- "Edsger Dijkstra",
1461
- "Barbara Liskov",
1462
- "Donald Knuth",
1463
- "Frances Allen"
1464
- ];
1465
- const SENTENCES = [
1466
- "A short note that explains the row.",
1467
- "Longer text, such as a description or the body of a post.",
1468
- "Written by the team and edited later.",
1469
- "Kept for reference."
1470
- ];
1471
- const COLORS = [
1472
- "#2563eb",
1473
- "#16a34a",
1474
- "#d97706",
1475
- "#dc2626",
1476
- "#7c3aed"
1477
- ];
1478
- const TITLE_COLUMNS = [
1479
- "name",
1480
- "title",
1481
- "label",
1482
- "subject"
1483
- ];
1484
- function capitalized(value) {
1485
- return `${value.charAt(0).toUpperCase()}${value.slice(1)}`.replaceAll("_", " ");
1048
+ function moduleTables(module) {
1049
+ return Object.entries(SQL_MODULES[module]?.names?.tables ?? {});
1050
+ }
1051
+ /**
1052
+ * The table the tenant columns point at: the target most foreign keys on a
1053
+ * tenant column share. `null` when no table has a tenant foreign key.
1054
+ */
1055
+ function tenantTable(tables) {
1056
+ const counts = /* @__PURE__ */ new Map();
1057
+ for (const table of tables) for (const key of table.foreignKeys) if (table.tenantColumn !== null && key.columns.length === 1 && key.columns[0] === table.tenantColumn) {
1058
+ const to = `${key.target.schema}.${key.target.table}`;
1059
+ counts.set(to, (counts.get(to) ?? 0) + 1);
1060
+ }
1061
+ let best = null;
1062
+ let most = 0;
1063
+ for (const [id, count] of counts) if (count > most) {
1064
+ best = id;
1065
+ most = count;
1066
+ }
1067
+ return best;
1068
+ }
1069
+ /**
1070
+ * The physical column a logical lifecycle column maps to. A tenant name
1071
+ * renames `organization_id`, so a default name the table lacks falls back to
1072
+ * the table's tenant column.
1073
+ */
1074
+ function physicalColumn(table, name, tenant) {
1075
+ if (name === void 0) return;
1076
+ if (table.columns.some((column) => column.name === name)) return name;
1077
+ return tenant && table.tenantColumn !== null ? table.tenantColumn : void 0;
1078
+ }
1079
+ function hasForeignKey(table, column) {
1080
+ return table.foreignKeys.some((key) => key.columns.length === 1 && key.columns[0] === column);
1081
+ }
1082
+ /**
1083
+ * The soft references in the tables: lifecycle tenant and user columns
1084
+ * without a foreign key, and `regclass` columns, which name any table.
1085
+ */
1086
+ function softReferences(tables, tenantName = DEFAULT_TENANT) {
1087
+ const lookup = indexTables(tables, tenantName);
1088
+ const tenantTo = tenantTable(tables);
1089
+ const refs = [];
1090
+ const seen = /* @__PURE__ */ new Set();
1091
+ const add = (ref) => {
1092
+ const key = `${ref.from}.${ref.column}`;
1093
+ if (!seen.has(key)) {
1094
+ seen.add(key);
1095
+ refs.push(ref);
1096
+ }
1097
+ };
1098
+ for (const block of new Set(tables.map((table) => table.module))) for (const [, spec] of moduleTables(block)) {
1099
+ const table = lookup(block, spec.name);
1100
+ const lifecycle = spec.lifecycle;
1101
+ if (table === void 0 || lifecycle === void 0) continue;
1102
+ const tenant = physicalColumn(table, lifecycle.tenant === void 0 ? void 0 : spec.columns[lifecycle.tenant], true);
1103
+ if (tenant !== void 0 && tenantTo !== null && tenantTo !== table.id && !hasForeignKey(table, tenant)) add({
1104
+ from: table.id,
1105
+ column: tenant,
1106
+ to: tenantTo,
1107
+ kind: "tenant"
1108
+ });
1109
+ const user = physicalColumn(table, lifecycle.user === void 0 ? void 0 : spec.columns[lifecycle.user], false);
1110
+ if (user !== void 0 && !hasForeignKey(table, user)) add({
1111
+ from: table.id,
1112
+ column: user,
1113
+ to: AUTH_USERS,
1114
+ kind: "user"
1115
+ });
1116
+ }
1117
+ for (const table of tables) for (const column of table.columns) if (column.type.toLowerCase() === "regclass") add({
1118
+ from: table.id,
1119
+ column: column.name,
1120
+ to: null,
1121
+ kind: "any"
1122
+ });
1123
+ return refs;
1124
+ }
1125
+ const MANIFEST_BY_MODULE = new Map(PRESET_CATALOG.blocks.map((block) => [block.name, block.manifest]));
1126
+ const EXTRA_TABLE_BY_MODULE = new Map(PRESET_CATALOG.blocks.flatMap((block) => block.extraColumns === void 0 ? [] : [[block.name, block.extraColumns]]));
1127
+ /** Each table's module and logical table name. */
1128
+ function blockTables(tables, lookup) {
1129
+ return Object.fromEntries(tables.flatMap((table) => {
1130
+ const logical = moduleTables(table.module).find(([, spec]) => lookup(table.module, spec.name) === table)?.[0];
1131
+ return logical === void 0 ? [] : [[table.id, {
1132
+ block: table.module,
1133
+ table: logical
1134
+ }]];
1135
+ }));
1136
+ }
1137
+ /** The table ids `blocks.<module>.options.extraColumns` adds columns to. */
1138
+ function extraColumnTables(tables, lookup) {
1139
+ const installed = new Set(tables.map((table) => table.module));
1140
+ return [...EXTRA_TABLE_BY_MODULE].flatMap(([module, logical]) => {
1141
+ const spec = SQL_MODULES[module]?.names?.tables[logical];
1142
+ const table = !installed.has(module) || spec === void 0 ? void 0 : lookup(module, spec.name);
1143
+ return table === void 0 ? [] : [table.id];
1144
+ });
1145
+ }
1146
+ /** The tables plus the soft references, manifests and extra-column tables the canvas draws. */
1147
+ function schemaData(tables, tenantName = DEFAULT_TENANT) {
1148
+ const lookup = indexTables(tables, tenantName);
1149
+ return {
1150
+ tables,
1151
+ softRefs: softReferences(tables, tenantName),
1152
+ manifests: Object.fromEntries(tables.map((table) => [table.id, MANIFEST_BY_MODULE.get(table.module) ?? table.module])),
1153
+ extraColumns: extraColumnTables(tables, lookup),
1154
+ blockTables: blockTables(tables, lookup),
1155
+ tenantTable: tenantTable(tables)
1156
+ };
1486
1157
  }
1487
- /** The column a table's rows are named by: its subject title, then a likely name column. */
1488
- function titleColumnOf(table) {
1489
- const text = new Set(Object.entries(table.columns ?? {}).filter(([, column]) => column.type === "text" && column.format === void 0).map(([key]) => key));
1490
- return table.subject?.title ?? TITLE_COLUMNS.find((key) => text.has(key));
1158
+ //#endregion
1159
+ //#region src/create/schema.ts
1160
+ /** The columns a diagram shows before a table is expanded: keys, tenant and soft references. */
1161
+ function keyColumnsOf(table, softColumns = /* @__PURE__ */ new Set()) {
1162
+ const keys = /* @__PURE__ */ new Set([
1163
+ ...table.primaryKey,
1164
+ ...table.foreignKeys.flatMap((key) => key.columns),
1165
+ ...table.tenantColumn === null ? [] : [table.tenantColumn],
1166
+ ...softColumns
1167
+ ]);
1168
+ return table.columns.filter((column) => keys.has(column.name));
1491
1169
  }
1492
- /** The name of row `index` of `table`, so a reference shows the row it points at. */
1493
- function rowTitle(table, index) {
1494
- return `${capitalized(singular(table))} ${String(index + 1)}`;
1170
+ /** The column the tenant blocks key rows by, from the preset's tenant name; `null` without tenants. */
1171
+ function tenantColumnOf(preset) {
1172
+ return preset.scope === "tenant" ? `${preset.tenantName}_id` : null;
1495
1173
  }
1496
- function pad(value) {
1497
- return String(value).padStart(2, "0");
1174
+ /**
1175
+ * Every module's file creates this table to record the installed modules.
1176
+ * It holds no app data, so the diagram leaves it out.
1177
+ */
1178
+ const BOOKKEEPING_TABLES = /* @__PURE__ */ new Set(["better_supabase.modules"]);
1179
+ const IDENT = String.raw`(?:"(?:[^"]|"")+"|[A-Za-z_][A-Za-z0-9_$]*)`;
1180
+ const QNAME = String.raw`${IDENT}(?:\s*\.\s*${IDENT})?`;
1181
+ const CREATE_TABLE = /\bcreate\s+(?:(?:global\s+|local\s+)?(?:temp|temporary)\s+|unlogged\s+)?table\b/giu;
1182
+ const CREATE_HEAD = new RegExp(String.raw`^create\s+(?:(?:global\s+|local\s+)?(?:temp|temporary)\s+|unlogged\s+)?table\s+(?:if\s+not\s+exists\s+)?(${QNAME})\s*\(`, "iu");
1183
+ const ALTER_TABLE = new RegExp(String.raw`\balter\s+table\s+(?:if\s+exists\s+)?(?:only\s+)?(${QNAME})\s+([^;]*);`, "giu");
1184
+ const REFERENCES = new RegExp(String.raw`\breferences\s+(${QNAME})\s*(?:\(([^)]*)\))?`, "iu");
1185
+ const LEADING_IDENT = new RegExp(String.raw`^(${IDENT})\s*`, "u");
1186
+ const CONSTRAINT_NAME = new RegExp(String.raw`^constraint\s+${IDENT}\s+`, "iu");
1187
+ /** Words that end a column's type in its definition. */
1188
+ const TYPE_END = /\s+(?:not\b|null\b|primary\b|references\b|default\b|generated\b|unique\b|check\b|constraint\b|collate\b)/iu;
1189
+ function unquote(ident) {
1190
+ const trimmed = ident.trim();
1191
+ return trimmed.startsWith("\"") ? trimmed.slice(1, -1).replaceAll("\"\"", "\"") : trimmed.toLowerCase();
1498
1192
  }
1499
- /** A date `days` after 5 January 2026, as `YYYY-MM-DD`. */
1500
- function dayAfter(days) {
1501
- const date = new Date(Date.UTC(2026, 0, 5 + days));
1502
- return `${String(date.getUTCFullYear())}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}`;
1193
+ function qualified(name) {
1194
+ const [first = "", second] = (name.match(new RegExp(IDENT, "gu")) ?? []).map((each) => unquote(each));
1195
+ return second === void 0 ? {
1196
+ schema: "public",
1197
+ table: first
1198
+ } : {
1199
+ schema: first,
1200
+ table: second
1201
+ };
1503
1202
  }
1504
- function numberIn(column, index, step) {
1505
- const value = (column.min ?? 0) + index * step;
1506
- return column.max === void 0 ? value : Math.min(value, column.max);
1203
+ function identList(list) {
1204
+ return (list ?? "").split(",").map((each) => each.trim()).filter((each) => each !== "").map((each) => unquote(each));
1507
1205
  }
1508
- function formatted(column, index, slug) {
1509
- switch (column.format) {
1510
- case void 0: return;
1511
- case "email": return `${(PEOPLE[index % PEOPLE.length] ?? "user").split(" ")[0]?.toLowerCase() ?? "user"}@example.com`;
1512
- case "url": return `https://example.com/${slug}/${String(index + 1)}`;
1513
- case "phone": return `+1 555 01${pad(index + 10)}`;
1514
- case "long_text": return SENTENCES[index % SENTENCES.length] ?? "";
1515
- case "color": return COLORS[index % COLORS.length] ?? "#000000";
1516
- case "rating": {
1517
- const min = column.min ?? 1;
1518
- const max = column.max ?? 5;
1519
- return String(min + index % (max - min + 1));
1206
+ /**
1207
+ * The SQL with comments removed and the inside of every single-quoted string
1208
+ * blanked, so a `create table` inside a string or a comment is not read and
1209
+ * the offsets still match the original text.
1210
+ */
1211
+ function codeOnly(sql) {
1212
+ let out = "";
1213
+ let index = 0;
1214
+ while (index < sql.length) {
1215
+ const char = sql[index];
1216
+ const next = sql[index + 1];
1217
+ if (char === "-" && next === "-") {
1218
+ const end = sql.indexOf("\n", index);
1219
+ const stop = end === -1 ? sql.length : end;
1220
+ out += " ".repeat(stop - index);
1221
+ index = stop;
1222
+ } else if (char === "/" && next === "*") {
1223
+ const end = sql.indexOf("*/", index + 2);
1224
+ const stop = end === -1 ? sql.length : end + 2;
1225
+ out += sql.slice(index, stop).replaceAll(/[^\n]/gu, " ");
1226
+ index = stop;
1227
+ } else if (char === "'") {
1228
+ let stop = index + 1;
1229
+ while (stop < sql.length) if (sql[stop] === "'" && sql[stop + 1] === "'") stop += 2;
1230
+ else if (sql[stop] === "'") break;
1231
+ else stop += 1;
1232
+ out += `'${sql.slice(index + 1, stop).replaceAll(/[^\n]/gu, " ")}'`;
1233
+ index = stop + 1;
1234
+ } else {
1235
+ out += char;
1236
+ index += 1;
1520
1237
  }
1521
- case "percent": return String(index * 17 % 101);
1522
- case "currency": return ((index + 1) * 1250 / 100).toFixed(2);
1523
- default: return column.format;
1524
1238
  }
1239
+ return out;
1525
1240
  }
1526
- function referenceValue(column, index) {
1527
- const reference = column.references;
1528
- if (reference === void 0) return;
1529
- if (reference.block === void 0 && reference.table === USERS) return PEOPLE[index % PEOPLE.length] ?? "";
1530
- return rowTitle(reference.table, index % 3);
1241
+ /** The text between the `(` at `open` and its matching `)`, or undefined when it never closes. */
1242
+ function balanced(text, open) {
1243
+ let depth = 0;
1244
+ for (let index = open; index < text.length; index += 1) if (text[index] === "(") depth += 1;
1245
+ else if (text[index] === ")") {
1246
+ depth -= 1;
1247
+ if (depth === 0) return text.slice(open + 1, index);
1248
+ }
1531
1249
  }
1532
- function typedValue(column, index, slug) {
1533
- switch (column.type) {
1534
- case "text": return `${capitalized(slug)} ${String(index + 1)}`;
1535
- case "uuid": return `00000000-0000-4000-8000-${String(index + 1).padStart(12, "0")}`;
1536
- case "integer":
1537
- case "bigint": return String(column.identity === true ? index + 1 : numberIn(column, index, 3));
1538
- case "numeric": return numberIn(column, index, 2.5).toFixed(2);
1539
- case "boolean": return String(index % 2 === 0);
1540
- case "timestamptz": return `${dayAfter(index * 2)} ${pad(9 + index % 8)}:00`;
1541
- case "date": return dayAfter(index * 3);
1542
- case "jsonb": return "{}";
1543
- case "text[]": return "{}";
1544
- default: return column.type;
1250
+ /** The comma-separated elements of `text` at depth 0, with `original` sliced at the same offsets. */
1251
+ function splitTopLevel(text, original = text) {
1252
+ const parts = [];
1253
+ let depth = 0;
1254
+ let start = 0;
1255
+ const push = (end) => {
1256
+ const code = text.slice(start, end);
1257
+ const lead = code.length - code.trimStart().length;
1258
+ const trimmed = code.trim();
1259
+ if (trimmed !== "") parts.push({
1260
+ code: trimmed,
1261
+ original: original.slice(start + lead, start + lead + trimmed.length)
1262
+ });
1263
+ };
1264
+ for (let index = 0; index < text.length; index += 1) {
1265
+ const char = text[index];
1266
+ if (char === "(") depth += 1;
1267
+ else if (char === ")") depth -= 1;
1268
+ else if (char === "," && depth === 0) {
1269
+ push(index);
1270
+ start = index + 1;
1271
+ }
1545
1272
  }
1273
+ push(text.length);
1274
+ return parts;
1546
1275
  }
1547
- function cell(table, key, column, index, title) {
1548
- if (key === title) return rowTitle(table, index);
1549
- if (column.nullable !== false && index % 4 === 3) return null;
1550
- if (column.options !== void 0 && column.options.length > 0) return column.options[index % column.options.length] ?? null;
1551
- return referenceValue(column, index) ?? formatted(column, index, key) ?? typedValue(column, index, key);
1276
+ function lineOf(text, offset) {
1277
+ return text.slice(0, offset).split("\n").length;
1552
1278
  }
1553
- /**
1554
- * Deterministic sample rows for app table `name`, from its columns' types,
1555
- * formats, options, bounds and references. A reference shows the name of the
1556
- * row it points at, so rows of related tables line up. A `member` viewer
1557
- * doesn't get the columns `hiddenColumns` lists.
1558
- */
1559
- function sampleRows(design, name, count = 8, viewer = "server") {
1560
- const table = design.appTables?.[name];
1561
- if (table === void 0) return {
1562
- columns: [],
1563
- rows: []
1564
- };
1565
- const hidden = new Set(hiddenColumns(table, viewer));
1566
- const entries = Object.entries(table.columns ?? {}).filter(([key]) => !hidden.has(key));
1567
- const title = titleColumnOf(table);
1279
+ function target(match) {
1280
+ const { schema, table } = qualified(match[1] ?? "");
1568
1281
  return {
1569
- columns: entries.map(([key]) => key),
1570
- rows: Array.from({ length: count }, (_, index) => Object.fromEntries(entries.map(([key, column]) => [key, cell(name, key, column, index, title)])))
1282
+ schema,
1283
+ table,
1284
+ columns: identList(match[2])
1571
1285
  };
1572
1286
  }
1573
- //#endregion
1574
- //#region src/create/schema-meta.ts
1575
- const AUTH_USERS = "auth.users";
1576
- /** The tenant name the module defaults use, which a preset's tenant name replaces. */
1577
- const DEFAULT_TENANT = "organization";
1287
+ const ON_DELETE = /\bon\s+delete\s+(cascade|restrict|set\s+null|set\s+default|no\s+action)\b/iu;
1288
+ /** The `on delete` action of a reference, `no action` when it names none. */
1289
+ function onDeleteOf(text) {
1290
+ return (ON_DELETE.exec(text)?.[1] ?? "no action").toLowerCase().replaceAll(/\s+/gu, " ");
1291
+ }
1292
+ /** Words that end a column's default expression at the top level. */
1293
+ const DEFAULT_END = /^(?:not\s+null|null|primary\s+key|references|unique|check|constraint|generated|collate)\b/iu;
1578
1294
  /**
1579
- * Finds the parsed table for a module's logical table by its default name,
1580
- * or by that name with the tenant renamed (`organizations` is `workspaces`
1581
- * for the `workspace` tenant).
1295
+ * The `default` expression of a column definition. `definition` is the code
1296
+ * with strings blanked and `original` the same text as written, so a keyword
1297
+ * inside a string never ends the expression.
1298
+ */
1299
+ function defaultOf(definition, original) {
1300
+ const start = /\bdefault\s+/iu.exec(definition);
1301
+ if (start === null) return null;
1302
+ const from = start.index + start[0].length;
1303
+ let depth = 0;
1304
+ let end = definition.length;
1305
+ for (let index = from; index < definition.length; index += 1) {
1306
+ const char = definition[index];
1307
+ if (char === "(") depth += 1;
1308
+ else if (char === ")") depth -= 1;
1309
+ else if (depth === 0 && /\s/u.test(char ?? "") && DEFAULT_END.test(definition.slice(index).trimStart())) {
1310
+ end = index;
1311
+ break;
1312
+ }
1313
+ }
1314
+ return original.slice(from, end).trim();
1315
+ }
1316
+ /** Adds a column definition (`"name" type ...`) to the draft. */
1317
+ function addColumn(draft, definition, original = definition) {
1318
+ const head = definition.match(LEADING_IDENT);
1319
+ if (head === null) return;
1320
+ const name = unquote(head[1] ?? "");
1321
+ const rest = definition.slice(head[0].length);
1322
+ const typeEnd = rest.search(TYPE_END);
1323
+ const type = (typeEnd === -1 ? rest : rest.slice(0, typeEnd)).trim();
1324
+ if (draft.columns.some((column) => column.name === name)) return;
1325
+ const primary = /\bprimary\s+key\b/iu.test(rest);
1326
+ draft.columns.push({
1327
+ name,
1328
+ type,
1329
+ nullable: !primary && !/\bnot\s+null\b/iu.test(rest),
1330
+ default: defaultOf(definition, original),
1331
+ unique: /\bunique\b/iu.test(rest)
1332
+ });
1333
+ if (primary) draft.primaryKey = [name];
1334
+ const references = rest.match(REFERENCES);
1335
+ if (references !== null) draft.foreignKeys.push({
1336
+ columns: [name],
1337
+ target: target(references),
1338
+ onDelete: onDeleteOf(rest)
1339
+ });
1340
+ }
1341
+ /**
1342
+ * Adds a table constraint (`primary key (...)`, `foreign key (...)
1343
+ * references ...`). Returns false when the element is not a constraint.
1582
1344
  */
1583
- function indexTables(tables, tenantName) {
1584
- const byName = new Map(tables.map((table) => [`${table.module}:${table.name}`, table]));
1585
- return (module, name) => byName.get(`${module}:${name}`) ?? byName.get(`${module}:${name.replaceAll(DEFAULT_TENANT, tenantName)}`);
1345
+ function addConstraint(draft, element) {
1346
+ const body = element.replace(CONSTRAINT_NAME, "");
1347
+ const named = body !== element;
1348
+ const primary = /^primary\s+key\s*\(([^)]*)\)/iu.exec(body);
1349
+ if (primary !== null) {
1350
+ draft.primaryKey = identList(primary[1]);
1351
+ return true;
1352
+ }
1353
+ const foreign = /^foreign\s+key\s*\(([^)]*)\)\s*([\s\S]*)$/iu.exec(body);
1354
+ if (foreign !== null) {
1355
+ const references = (foreign[2] ?? "").match(REFERENCES);
1356
+ if (references !== null) draft.foreignKeys.push({
1357
+ columns: identList(foreign[1]),
1358
+ target: target(references),
1359
+ onDelete: onDeleteOf(foreign[2] ?? "")
1360
+ });
1361
+ return true;
1362
+ }
1363
+ return named || /^(?:unique|check|exclude)\b/iu.test(body);
1586
1364
  }
1587
- function moduleTables(module) {
1588
- return Object.entries(SQL_MODULES[module]?.names?.tables ?? {});
1365
+ function finish(draft, tenantColumn) {
1366
+ const tenant = tenantColumn !== null && draft.columns.some((column) => column.name === tenantColumn) ? tenantColumn : null;
1367
+ const primary = new Set(draft.primaryKey);
1368
+ return {
1369
+ id: `${draft.schema}.${draft.name}`,
1370
+ schema: draft.schema,
1371
+ name: draft.name,
1372
+ module: draft.module,
1373
+ primaryKey: draft.primaryKey,
1374
+ foreignKeys: draft.foreignKeys,
1375
+ tenantColumn: tenant,
1376
+ columns: draft.columns.map((column) => primary.has(column.name) ? {
1377
+ ...column,
1378
+ nullable: false
1379
+ } : column)
1380
+ };
1589
1381
  }
1590
1382
  /**
1591
- * The table the tenant columns point at: the target most foreign keys on a
1592
- * tenant column share. `null` when no table has a tenant foreign key.
1383
+ * The tables in rendered module SQL: every `create table`, plus the columns
1384
+ * and foreign keys later `alter table ... add` statements give them. A
1385
+ * `create table` it can't read throws with the file and line, so a new SQL
1386
+ * shape fails the tests instead of dropping a table from the diagram.
1593
1387
  */
1594
- function tenantTable(tables) {
1595
- const counts = /* @__PURE__ */ new Map();
1596
- for (const table of tables) for (const key of table.foreignKeys) if (table.tenantColumn !== null && key.columns.length === 1 && key.columns[0] === table.tenantColumn) {
1597
- const to = `${key.target.schema}.${key.target.table}`;
1598
- counts.set(to, (counts.get(to) ?? 0) + 1);
1388
+ function parseSchema(files, options = {}) {
1389
+ const drafts = /* @__PURE__ */ new Map();
1390
+ const code = files.map((file) => ({
1391
+ file,
1392
+ text: codeOnly(file.contents)
1393
+ }));
1394
+ for (const { file, text } of code) for (const match of text.matchAll(CREATE_TABLE)) {
1395
+ const offset = match.index;
1396
+ const head = text.slice(offset).match(CREATE_HEAD);
1397
+ const open = head === null ? -1 : offset + head[0].length - 1;
1398
+ const body = open === -1 ? void 0 : balanced(text, open);
1399
+ const original = body === void 0 ? "" : file.contents.slice(open + 1, open + 1 + body.length);
1400
+ if (head === null || body === void 0) throw new Error(`parseSchema can't read the create table at ${file.path}:${lineOf(text, offset)}.`);
1401
+ const { schema, table } = qualified(head[1] ?? "");
1402
+ const id = `${schema}.${table}`;
1403
+ if (drafts.has(id)) continue;
1404
+ const draft = {
1405
+ schema,
1406
+ name: table,
1407
+ module: file.module,
1408
+ columns: [],
1409
+ primaryKey: [],
1410
+ foreignKeys: []
1411
+ };
1412
+ for (const element of splitTopLevel(body, original)) if (!addConstraint(draft, element.code)) addColumn(draft, element.code, element.original);
1413
+ drafts.set(id, draft);
1599
1414
  }
1600
- let best = null;
1601
- let most = 0;
1602
- for (const [id, count] of counts) if (count > most) {
1603
- best = id;
1604
- most = count;
1415
+ for (const { file, text } of code) for (const match of text.matchAll(ALTER_TABLE)) {
1416
+ const { schema, table } = qualified(match[1] ?? "");
1417
+ const draft = drafts.get(`${schema}.${table}`);
1418
+ if (draft === void 0) continue;
1419
+ const actions = match[2] ?? "";
1420
+ const start = match.index + match[0].lastIndexOf(actions);
1421
+ const original = file.contents.slice(start, start + actions.length);
1422
+ for (const action of splitTopLevel(actions, original)) {
1423
+ const column = /^add\s+column\s+(?:if\s+not\s+exists\s+)?/iu.exec(action.code);
1424
+ if (column !== null) addColumn(draft, action.code.slice(column[0].length), action.original.slice(column[0].length));
1425
+ else if (/^add\s+/iu.test(action.code)) addConstraint(draft, action.code.replace(/^add\s+/iu, ""));
1426
+ }
1605
1427
  }
1606
- return best;
1428
+ const tenantColumn = options.tenantColumn ?? null;
1429
+ return [...drafts.entries()].filter(([id]) => !BOOKKEEPING_TABLES.has(id)).map(([, draft]) => finish(draft, tenantColumn));
1607
1430
  }
1608
1431
  /**
1609
- * The physical column a logical lifecycle column maps to. A tenant name
1610
- * renames `organization_id`, so a default name the table lacks falls back to
1611
- * the table's tenant column.
1432
+ * The statements that shape one table, as written: its `create table` and
1433
+ * the `alter table` statements after it. Empty when no file creates it.
1612
1434
  */
1613
- function physicalColumn(table, name, tenant) {
1614
- if (name === void 0) return;
1615
- if (table.columns.some((column) => column.name === name)) return name;
1616
- return tenant && table.tenantColumn !== null ? table.tenantColumn : void 0;
1435
+ function tableStatements(files, id) {
1436
+ const statements = [];
1437
+ for (const file of files) {
1438
+ const text = codeOnly(file.contents);
1439
+ for (const match of text.matchAll(CREATE_TABLE)) {
1440
+ const head = text.slice(match.index).match(CREATE_HEAD);
1441
+ if (head === null) continue;
1442
+ const { schema, table } = qualified(head[1] ?? "");
1443
+ const open = match.index + head[0].length - 1;
1444
+ const body = balanced(text, open);
1445
+ if (`${schema}.${table}` !== id || body === void 0) continue;
1446
+ const end = text.indexOf(";", open + body.length + 1);
1447
+ statements.push(file.contents.slice(match.index, end === -1 ? text.length : end + 1));
1448
+ }
1449
+ for (const match of text.matchAll(ALTER_TABLE)) {
1450
+ const { schema, table } = qualified(match[1] ?? "");
1451
+ if (`${schema}.${table}` === id) statements.push(file.contents.slice(match.index, match.index + match[0].length));
1452
+ }
1453
+ }
1454
+ return statements;
1617
1455
  }
1618
- function hasForeignKey(table, column) {
1619
- return table.foreignKeys.some((key) => key.columns.length === 1 && key.columns[0] === column);
1456
+ /** The foreign keys between tables, one per pair, with the targets outside the schema named by id. */
1457
+ function schemaRelations(tables) {
1458
+ const seen = /* @__PURE__ */ new Set();
1459
+ return tables.flatMap((table) => table.foreignKeys.flatMap((key) => {
1460
+ const to = `${key.target.schema}.${key.target.table}`;
1461
+ const pair = `${table.id}>${to}`;
1462
+ if (to === table.id || seen.has(pair)) return [];
1463
+ seen.add(pair);
1464
+ return [{
1465
+ from: table.id,
1466
+ to
1467
+ }];
1468
+ }));
1469
+ }
1470
+ //#endregion
1471
+ //#region src/create/check.ts
1472
+ const messageOf = (error) => error instanceof Error ? error.message : String(error);
1473
+ async function designFrom(input) {
1474
+ if (typeof input !== "string") return parseDesign(input);
1475
+ const design = await designOf(input);
1476
+ if (design === void 0) throw new TypeError(`design: "${input.slice(0, 40)}" is neither a design code nor a /create URL with &design=`);
1477
+ return design;
1620
1478
  }
1621
1479
  /**
1622
- * The soft references in the tables: lifecycle tenant and user columns
1623
- * without a foreign key, and `regclass` columns, which name any table.
1480
+ * Checks a design against a preset with every rule the canvas and
1481
+ * `sql sync` apply, so a server, an MCP tool and the canvas share one
1482
+ * answer. `input` is a design object, a design code or a `/create` URL with
1483
+ * `&design=`. It never throws for a bad design or preset: each problem is
1484
+ * an issue.
1624
1485
  */
1625
- function softReferences(tables, tenantName = DEFAULT_TENANT) {
1626
- const lookup = indexTables(tables, tenantName);
1627
- const tenantTo = tenantTable(tables);
1628
- const refs = [];
1629
- const seen = /* @__PURE__ */ new Set();
1630
- const add = (ref) => {
1631
- const key = `${ref.from}.${ref.column}`;
1632
- if (!seen.has(key)) {
1633
- seen.add(key);
1634
- refs.push(ref);
1486
+ async function checkDesign(input, preset) {
1487
+ let design;
1488
+ try {
1489
+ design = await designFrom(input);
1490
+ } catch (error) {
1491
+ return {
1492
+ ok: false,
1493
+ issues: [{
1494
+ table: "design",
1495
+ message: messageOf(error)
1496
+ }]
1497
+ };
1498
+ }
1499
+ let resolvedPreset;
1500
+ try {
1501
+ resolvedPreset = presetOf(preset);
1502
+ } catch (error) {
1503
+ return {
1504
+ ok: false,
1505
+ issues: [{
1506
+ table: "preset",
1507
+ message: messageOf(error)
1508
+ }]
1509
+ };
1510
+ }
1511
+ const resolved = resolvePreset(resolvedPreset);
1512
+ if (resolved.conflicts.length > 0) return {
1513
+ ok: false,
1514
+ issues: resolved.conflicts.map((conflict) => ({
1515
+ table: "preset",
1516
+ message: `${conflict.block ?? conflict.field ?? "preset"}: ${conflict.reason}`
1517
+ }))
1518
+ };
1519
+ try {
1520
+ designConfig(resolved, design);
1521
+ } catch (error) {
1522
+ return {
1523
+ ok: false,
1524
+ issues: [{
1525
+ table: "design",
1526
+ message: messageOf(error)
1527
+ }]
1528
+ };
1529
+ }
1530
+ const data = schemaData(parseSchema(previewFiles(encodePreset(resolvedPreset)), { tenantColumn: tenantColumnOf(resolvedPreset) }), resolvedPreset.tenantName);
1531
+ const issues = designIssues(design, data, resolvedPreset);
1532
+ if (issues.length > 0) return {
1533
+ ok: false,
1534
+ issues
1535
+ };
1536
+ try {
1537
+ return {
1538
+ ok: true,
1539
+ design,
1540
+ code: await encodeDesign(design)
1541
+ };
1542
+ } catch (error) {
1543
+ if (error instanceof DesignTooLongError) return {
1544
+ ok: true,
1545
+ design,
1546
+ code: null
1547
+ };
1548
+ return {
1549
+ ok: false,
1550
+ issues: [{
1551
+ table: "design",
1552
+ message: messageOf(error)
1553
+ }]
1554
+ };
1555
+ }
1556
+ }
1557
+ //#endregion
1558
+ //#region src/create/column-kinds.ts
1559
+ /** The groups of the column type picker, in the order it shows them. */
1560
+ const KIND_GROUPS = [
1561
+ "Text",
1562
+ "Number",
1563
+ "Date and time",
1564
+ "Choice",
1565
+ "Relation",
1566
+ "Other"
1567
+ ];
1568
+ const USERS$1 = "auth.users";
1569
+ /** The first options a new select gets, for the user to rename. */
1570
+ const STARTER_OPTIONS = ["Option A", "Option B"];
1571
+ const COLUMN_KINDS = [
1572
+ {
1573
+ id: "text",
1574
+ label: "Text",
1575
+ group: "Text",
1576
+ short: "text",
1577
+ column: { type: "text" }
1578
+ },
1579
+ {
1580
+ id: "long_text",
1581
+ label: "Long text",
1582
+ group: "Text",
1583
+ short: "long text",
1584
+ column: {
1585
+ type: "text",
1586
+ format: "long_text"
1587
+ }
1588
+ },
1589
+ {
1590
+ id: "email",
1591
+ label: "Email",
1592
+ group: "Text",
1593
+ short: "email",
1594
+ column: {
1595
+ type: "text",
1596
+ format: "email"
1597
+ }
1598
+ },
1599
+ {
1600
+ id: "url",
1601
+ label: "URL",
1602
+ group: "Text",
1603
+ short: "url",
1604
+ column: {
1605
+ type: "text",
1606
+ format: "url"
1607
+ }
1608
+ },
1609
+ {
1610
+ id: "phone",
1611
+ label: "Phone",
1612
+ group: "Text",
1613
+ short: "phone",
1614
+ column: {
1615
+ type: "text",
1616
+ format: "phone"
1617
+ }
1618
+ },
1619
+ {
1620
+ id: "color",
1621
+ label: "Color",
1622
+ group: "Text",
1623
+ short: "color",
1624
+ column: {
1625
+ type: "text",
1626
+ format: "color"
1627
+ }
1628
+ },
1629
+ {
1630
+ id: "integer",
1631
+ label: "Whole number",
1632
+ group: "Number",
1633
+ short: "integer",
1634
+ column: { type: "integer" }
1635
+ },
1636
+ {
1637
+ id: "bigint",
1638
+ label: "Large whole number",
1639
+ group: "Number",
1640
+ short: "bigint",
1641
+ column: { type: "bigint" }
1642
+ },
1643
+ {
1644
+ id: "numeric",
1645
+ label: "Decimal",
1646
+ group: "Number",
1647
+ short: "numeric",
1648
+ column: { type: "numeric" }
1649
+ },
1650
+ {
1651
+ id: "rating",
1652
+ label: "Rating",
1653
+ group: "Number",
1654
+ short: "rating",
1655
+ column: {
1656
+ type: "integer",
1657
+ format: "rating"
1635
1658
  }
1636
- };
1637
- for (const block of new Set(tables.map((table) => table.module))) for (const [, spec] of moduleTables(block)) {
1638
- const table = lookup(block, spec.name);
1639
- const lifecycle = spec.lifecycle;
1640
- if (table === void 0 || lifecycle === void 0) continue;
1641
- const tenant = physicalColumn(table, lifecycle.tenant === void 0 ? void 0 : spec.columns[lifecycle.tenant], true);
1642
- if (tenant !== void 0 && tenantTo !== null && tenantTo !== table.id && !hasForeignKey(table, tenant)) add({
1643
- from: table.id,
1644
- column: tenant,
1645
- to: tenantTo,
1646
- kind: "tenant"
1647
- });
1648
- const user = physicalColumn(table, lifecycle.user === void 0 ? void 0 : spec.columns[lifecycle.user], false);
1649
- if (user !== void 0 && !hasForeignKey(table, user)) add({
1650
- from: table.id,
1651
- column: user,
1652
- to: AUTH_USERS,
1653
- kind: "user"
1654
- });
1659
+ },
1660
+ {
1661
+ id: "percent",
1662
+ label: "Percent",
1663
+ group: "Number",
1664
+ short: "percent",
1665
+ column: {
1666
+ type: "numeric",
1667
+ format: "percent"
1668
+ }
1669
+ },
1670
+ {
1671
+ id: "currency",
1672
+ label: "Currency",
1673
+ group: "Number",
1674
+ short: "money",
1675
+ column: {
1676
+ type: "bigint",
1677
+ format: "currency"
1678
+ }
1679
+ },
1680
+ {
1681
+ id: "autonumber",
1682
+ label: "Autonumber",
1683
+ group: "Number",
1684
+ short: "autonumber",
1685
+ column: {
1686
+ type: "bigint",
1687
+ identity: true
1688
+ }
1689
+ },
1690
+ {
1691
+ id: "date",
1692
+ label: "Date",
1693
+ group: "Date and time",
1694
+ short: "date",
1695
+ column: { type: "date" }
1696
+ },
1697
+ {
1698
+ id: "timestamptz",
1699
+ label: "Date and time",
1700
+ group: "Date and time",
1701
+ short: "timestamptz",
1702
+ column: { type: "timestamptz" }
1703
+ },
1704
+ {
1705
+ id: "boolean",
1706
+ label: "Yes or no",
1707
+ group: "Choice",
1708
+ short: "boolean",
1709
+ column: { type: "boolean" }
1710
+ },
1711
+ {
1712
+ id: "single_select",
1713
+ label: "Single select",
1714
+ group: "Choice",
1715
+ short: "select",
1716
+ column: {
1717
+ type: "text",
1718
+ options: STARTER_OPTIONS
1719
+ }
1720
+ },
1721
+ {
1722
+ id: "multi_select",
1723
+ label: "Multi-select",
1724
+ group: "Choice",
1725
+ short: "multi-select",
1726
+ column: {
1727
+ type: "text[]",
1728
+ options: STARTER_OPTIONS
1729
+ }
1730
+ },
1731
+ {
1732
+ id: "person",
1733
+ label: "Person",
1734
+ group: "Relation",
1735
+ short: "person",
1736
+ column: {
1737
+ type: "uuid",
1738
+ nullable: true,
1739
+ references: {
1740
+ table: USERS$1,
1741
+ onDelete: "set null"
1742
+ }
1743
+ }
1744
+ },
1745
+ {
1746
+ id: "reference",
1747
+ label: "Link to a table",
1748
+ group: "Relation",
1749
+ short: "link",
1750
+ column: { type: "uuid" },
1751
+ drawn: true
1752
+ },
1753
+ {
1754
+ id: "uuid",
1755
+ label: "UUID",
1756
+ group: "Other",
1757
+ short: "uuid",
1758
+ column: { type: "uuid" }
1759
+ },
1760
+ {
1761
+ id: "jsonb",
1762
+ label: "JSON",
1763
+ group: "Other",
1764
+ short: "jsonb",
1765
+ column: { type: "jsonb" }
1766
+ },
1767
+ {
1768
+ id: "text_list",
1769
+ label: "List of text",
1770
+ group: "Other",
1771
+ short: "text[]",
1772
+ column: { type: "text[]" }
1655
1773
  }
1656
- for (const table of tables) for (const column of table.columns) if (column.type.toLowerCase() === "regclass") add({
1657
- from: table.id,
1658
- column: column.name,
1659
- to: null,
1660
- kind: "any"
1661
- });
1662
- return refs;
1663
- }
1664
- const MANIFEST_BY_MODULE = new Map(PRESET_CATALOG.blocks.map((block) => [block.name, block.manifest]));
1665
- const EXTRA_TABLE_BY_MODULE = new Map(PRESET_CATALOG.blocks.flatMap((block) => block.extraColumns === void 0 ? [] : [[block.name, block.extraColumns]]));
1666
- /** Each table's module and logical table name. */
1667
- function blockTables(tables, lookup) {
1668
- return Object.fromEntries(tables.flatMap((table) => {
1669
- const logical = moduleTables(table.module).find(([, spec]) => lookup(table.module, spec.name) === table)?.[0];
1670
- return logical === void 0 ? [] : [[table.id, {
1671
- block: table.module,
1672
- table: logical
1673
- }]];
1674
- }));
1675
- }
1676
- /** The table ids `blocks.<module>.options.extraColumns` adds columns to. */
1677
- function extraColumnTables(tables, lookup) {
1678
- const installed = new Set(tables.map((table) => table.module));
1679
- return [...EXTRA_TABLE_BY_MODULE].flatMap(([module, logical]) => {
1680
- const spec = SQL_MODULES[module]?.names?.tables[logical];
1681
- const table = !installed.has(module) || spec === void 0 ? void 0 : lookup(module, spec.name);
1682
- return table === void 0 ? [] : [table.id];
1683
- });
1684
- }
1685
- /** The tables plus the soft references, manifests and extra-column tables the canvas draws. */
1686
- function schemaData(tables, tenantName = DEFAULT_TENANT) {
1687
- const lookup = indexTables(tables, tenantName);
1688
- return {
1689
- tables,
1690
- softRefs: softReferences(tables, tenantName),
1691
- manifests: Object.fromEntries(tables.map((table) => [table.id, MANIFEST_BY_MODULE.get(table.module) ?? table.module])),
1692
- extraColumns: extraColumnTables(tables, lookup),
1693
- blockTables: blockTables(tables, lookup),
1694
- tenantTable: tenantTable(tables)
1695
- };
1696
- }
1697
- //#endregion
1698
- //#region src/create/schema.ts
1699
- /** The columns a diagram shows before a table is expanded: keys, tenant and soft references. */
1700
- function keyColumnsOf(table, softColumns = /* @__PURE__ */ new Set()) {
1701
- const keys = /* @__PURE__ */ new Set([
1702
- ...table.primaryKey,
1703
- ...table.foreignKeys.flatMap((key) => key.columns),
1704
- ...table.tenantColumn === null ? [] : [table.tenantColumn],
1705
- ...softColumns
1706
- ]);
1707
- return table.columns.filter((column) => keys.has(column.name));
1708
- }
1709
- /** The column the tenant blocks key rows by, from the preset's tenant name; `null` without tenants. */
1710
- function tenantColumnOf(preset) {
1711
- return preset.scope === "tenant" ? `${preset.tenantName}_id` : null;
1712
- }
1713
- /**
1714
- * Every module's file creates this table to record the installed modules.
1715
- * It holds no app data, so the diagram leaves it out.
1716
- */
1717
- const BOOKKEEPING_TABLES = /* @__PURE__ */ new Set(["better_supabase.modules"]);
1718
- const IDENT = String.raw`(?:"(?:[^"]|"")+"|[A-Za-z_][A-Za-z0-9_$]*)`;
1719
- const QNAME = String.raw`${IDENT}(?:\s*\.\s*${IDENT})?`;
1720
- const CREATE_TABLE = /\bcreate\s+(?:(?:global\s+|local\s+)?(?:temp|temporary)\s+|unlogged\s+)?table\b/giu;
1721
- const CREATE_HEAD = new RegExp(String.raw`^create\s+(?:(?:global\s+|local\s+)?(?:temp|temporary)\s+|unlogged\s+)?table\s+(?:if\s+not\s+exists\s+)?(${QNAME})\s*\(`, "iu");
1722
- const ALTER_TABLE = new RegExp(String.raw`\balter\s+table\s+(?:if\s+exists\s+)?(?:only\s+)?(${QNAME})\s+([^;]*);`, "giu");
1723
- const REFERENCES = new RegExp(String.raw`\breferences\s+(${QNAME})\s*(?:\(([^)]*)\))?`, "iu");
1724
- const LEADING_IDENT = new RegExp(String.raw`^(${IDENT})\s*`, "u");
1725
- const CONSTRAINT_NAME = new RegExp(String.raw`^constraint\s+${IDENT}\s+`, "iu");
1726
- /** Words that end a column's type in its definition. */
1727
- const TYPE_END = /\s+(?:not\b|null\b|primary\b|references\b|default\b|generated\b|unique\b|check\b|constraint\b|collate\b)/iu;
1728
- function unquote(ident) {
1729
- const trimmed = ident.trim();
1730
- return trimmed.startsWith("\"") ? trimmed.slice(1, -1).replaceAll("\"\"", "\"") : trimmed.toLowerCase();
1774
+ ];
1775
+ const BY_ID = new Map(COLUMN_KINDS.map((kind) => [kind.id, kind]));
1776
+ const BY_FORMAT = new Map(COLUMN_KINDS.filter((kind) => kind.column.format !== void 0).map((kind) => [kind.column.format, kind]));
1777
+ const PLAIN = {
1778
+ text: "text",
1779
+ uuid: "uuid",
1780
+ integer: "integer",
1781
+ bigint: "bigint",
1782
+ numeric: "numeric",
1783
+ boolean: "boolean",
1784
+ timestamptz: "timestamptz",
1785
+ date: "date",
1786
+ jsonb: "jsonb",
1787
+ "text[]": "text_list"
1788
+ };
1789
+ function kindById(id) {
1790
+ return BY_ID.get(id);
1731
1791
  }
1732
- function qualified(name) {
1733
- const [first = "", second] = (name.match(new RegExp(IDENT, "gu")) ?? []).map((each) => unquote(each));
1734
- return second === void 0 ? {
1735
- schema: "public",
1736
- table: first
1737
- } : {
1738
- schema: first,
1739
- table: second
1740
- };
1792
+ /** The kind a column's identity, reference or options make it, before its format and type. */
1793
+ function structuralKind(column) {
1794
+ if (column.identity === true) return "autonumber";
1795
+ if (column.references !== void 0) return column.references.block === void 0 && column.references.table === USERS$1 ? "person" : "reference";
1796
+ if (column.options === void 0) return;
1797
+ return column.type === "text[]" ? "multi_select" : "single_select";
1741
1798
  }
1742
- function identList(list) {
1743
- return (list ?? "").split(",").map((each) => each.trim()).filter((each) => each !== "").map((each) => unquote(each));
1799
+ /** The picker choice a column reads as. */
1800
+ function kindOf(column) {
1801
+ const id = structuralKind(column);
1802
+ return (id === void 0 ? void 0 : BY_ID.get(id)) ?? (column.format === void 0 ? void 0 : BY_FORMAT.get(column.format)) ?? BY_ID.get(PLAIN[column.type]);
1744
1803
  }
1745
1804
  /**
1746
- * The SQL with comments removed and the inside of every single-quoted string
1747
- * blanked, so a `create table` inside a string or a comment is not read and
1748
- * the offsets still match the original text.
1805
+ * `column` as `kind`: the kind's keys, with the column's name-independent
1806
+ * settings (required, unique, comment, a default and bounds that still fit)
1807
+ * kept, and a select's options kept when it turns into the other select.
1749
1808
  */
1750
- function codeOnly(sql) {
1751
- let out = "";
1752
- let index = 0;
1753
- while (index < sql.length) {
1754
- const char = sql[index];
1755
- const next = sql[index + 1];
1756
- if (char === "-" && next === "-") {
1757
- const end = sql.indexOf("\n", index);
1758
- const stop = end === -1 ? sql.length : end;
1759
- out += " ".repeat(stop - index);
1760
- index = stop;
1761
- } else if (char === "/" && next === "*") {
1762
- const end = sql.indexOf("*/", index + 2);
1763
- const stop = end === -1 ? sql.length : end + 2;
1764
- out += sql.slice(index, stop).replaceAll(/[^\n]/gu, " ");
1765
- index = stop;
1766
- } else if (char === "'") {
1767
- let stop = index + 1;
1768
- while (stop < sql.length) if (sql[stop] === "'" && sql[stop + 1] === "'") stop += 2;
1769
- else if (sql[stop] === "'") break;
1770
- else stop += 1;
1771
- out += `'${sql.slice(index + 1, stop).replaceAll(/[^\n]/gu, " ")}'`;
1772
- index = stop + 1;
1773
- } else {
1774
- out += char;
1775
- index += 1;
1776
- }
1777
- }
1778
- return out;
1779
- }
1780
- /** The text between the `(` at `open` and its matching `)`, or undefined when it never closes. */
1781
- function balanced(text, open) {
1782
- let depth = 0;
1783
- for (let index = open; index < text.length; index += 1) if (text[index] === "(") depth += 1;
1784
- else if (text[index] === ")") {
1785
- depth -= 1;
1786
- if (depth === 0) return text.slice(open + 1, index);
1787
- }
1788
- }
1789
- /** The comma-separated elements of `text` at depth 0, with `original` sliced at the same offsets. */
1790
- function splitTopLevel(text, original = text) {
1791
- const parts = [];
1792
- let depth = 0;
1793
- let start = 0;
1794
- const push = (end) => {
1795
- const code = text.slice(start, end);
1796
- const lead = code.length - code.trimStart().length;
1797
- const trimmed = code.trim();
1798
- if (trimmed !== "") parts.push({
1799
- code: trimmed,
1800
- original: original.slice(start + lead, start + lead + trimmed.length)
1801
- });
1809
+ function withKind(column, kind) {
1810
+ const { format: _format, options, identity: _identity, references: _references, min, max, ...rest } = column;
1811
+ const kept = kind.column.options === void 0 || options === void 0 ? kind.column : {
1812
+ ...kind.column,
1813
+ options
1802
1814
  };
1803
- for (let index = 0; index < text.length; index += 1) {
1804
- const char = text[index];
1805
- if (char === "(") depth += 1;
1806
- else if (char === ")") depth -= 1;
1807
- else if (char === "," && depth === 0) {
1808
- push(index);
1809
- start = index + 1;
1810
- }
1811
- }
1812
- push(text.length);
1813
- return parts;
1814
- }
1815
- function lineOf(text, offset) {
1816
- return text.slice(0, offset).split("\n").length;
1815
+ return fitted(withBounds({
1816
+ ...rest,
1817
+ ...kept
1818
+ }, column.type === kind.column.type ? {
1819
+ min,
1820
+ max
1821
+ } : {}));
1817
1822
  }
1818
- function target(match) {
1819
- const { schema, table } = qualified(match[1] ?? "");
1823
+ /** The money columns of `name`: `<stem>_minor` and `<stem>_currency`. */
1824
+ function moneyColumns(name) {
1825
+ const stem = name.replace(/_minor$/u, "");
1820
1826
  return {
1821
- schema,
1822
- table,
1823
- columns: identList(match[2])
1827
+ minor: `${stem}_minor`,
1828
+ currency: `${stem}_currency`
1824
1829
  };
1825
1830
  }
1826
- const ON_DELETE = /\bon\s+delete\s+(cascade|restrict|set\s+null|set\s+default|no\s+action)\b/iu;
1827
- /** The `on delete` action of a reference, `no action` when it names none. */
1828
- function onDeleteOf(text) {
1829
- return (ON_DELETE.exec(text)?.[1] ?? "no action").toLowerCase().replaceAll(/\s+/gu, " ");
1830
- }
1831
- /** Words that end a column's default expression at the top level. */
1832
- const DEFAULT_END = /^(?:not\s+null|null|primary\s+key|references|unique|check|constraint|generated|collate)\b/iu;
1833
1831
  /**
1834
- * The `default` expression of a column definition. `definition` is the code
1835
- * with strings blanked and `original` the same text as written, so a keyword
1836
- * inside a string never ends the expression.
1832
+ * Sets an app table column to `kind`. Currency keeps money as two columns:
1833
+ * the column becomes `<name>_minor` (unless the name is taken) and a
1834
+ * `<name>_currency` text column of 3 characters joins it. Returns the
1835
+ * column's name after the change.
1837
1836
  */
1838
- function defaultOf(definition, original) {
1839
- const start = /\bdefault\s+/iu.exec(definition);
1840
- if (start === null) return null;
1841
- const from = start.index + start[0].length;
1842
- let depth = 0;
1843
- let end = definition.length;
1844
- for (let index = from; index < definition.length; index += 1) {
1845
- const char = definition[index];
1846
- if (char === "(") depth += 1;
1847
- else if (char === ")") depth -= 1;
1848
- else if (depth === 0 && /\s/u.test(char ?? "") && DEFAULT_END.test(definition.slice(index).trimStart())) {
1849
- end = index;
1850
- break;
1851
- }
1852
- }
1853
- return original.slice(from, end).trim();
1837
+ function setColumnKind(design, table, name, kind) {
1838
+ const columns = design.appTables?.[table]?.columns ?? {};
1839
+ const column = columns[name];
1840
+ if (column === void 0) return {
1841
+ design,
1842
+ name
1843
+ };
1844
+ const next = withKind(column, kind);
1845
+ if (kind.id !== "currency") return {
1846
+ design: setColumn(design, table, name, next),
1847
+ name
1848
+ };
1849
+ const { minor, currency } = moneyColumns(name);
1850
+ const renamed = minor === name || columns[minor] === void 0 ? minor : name;
1851
+ const moved = setColumn(renameColumn(design, table, name, renamed), table, renamed, next);
1852
+ if (columns[currency] !== void 0) return {
1853
+ design: moved,
1854
+ name: renamed
1855
+ };
1856
+ return {
1857
+ design: setColumn(moved, table, currency, next.nullable === false ? {
1858
+ type: "text",
1859
+ nullable: false,
1860
+ min: 3,
1861
+ max: 3
1862
+ } : {
1863
+ type: "text",
1864
+ min: 3,
1865
+ max: 3
1866
+ }),
1867
+ name: renamed
1868
+ };
1854
1869
  }
1855
- /** Adds a column definition (`"name" type ...`) to the draft. */
1856
- function addColumn(draft, definition, original = definition) {
1857
- const head = definition.match(LEADING_IDENT);
1858
- if (head === null) return;
1859
- const name = unquote(head[1] ?? "");
1860
- const rest = definition.slice(head[0].length);
1861
- const typeEnd = rest.search(TYPE_END);
1862
- const type = (typeEnd === -1 ? rest : rest.slice(0, typeEnd)).trim();
1863
- if (draft.columns.some((column) => column.name === name)) return;
1864
- const primary = /\bprimary\s+key\b/iu.test(rest);
1865
- draft.columns.push({
1866
- name,
1867
- type,
1868
- nullable: !primary && !/\bnot\s+null\b/iu.test(rest),
1869
- default: defaultOf(definition, original),
1870
- unique: /\bunique\b/iu.test(rest)
1871
- });
1872
- if (primary) draft.primaryKey = [name];
1873
- const references = rest.match(REFERENCES);
1874
- if (references !== null) draft.foreignKeys.push({
1875
- columns: [name],
1876
- target: target(references),
1877
- onDelete: onDeleteOf(rest)
1878
- });
1870
+ //#endregion
1871
+ //#region src/create/deploy.ts
1872
+ /** The name the deploy gives its migration in `supabase_migrations`. */
1873
+ const MIGRATION_NAME = "better_supabase_blocks";
1874
+ /**
1875
+ * Why this preset can't be deployed, or `undefined` when it can. With
1876
+ * `access: "provider"` the preview renders a stand-in provider whose
1877
+ * functions no real project has.
1878
+ */
1879
+ function deployBlocker(preset) {
1880
+ return preset.access === "provider" ? "Bring your own authorization provider: its SQL comes from the provider, so deploy it with the CLI." : void 0;
1879
1881
  }
1880
1882
  /**
1881
- * Adds a table constraint (`primary key (...)`, `foreign key (...)
1882
- * references ...`). Returns false when the element is not a constraint.
1883
+ * The SQL of one migration for the rendered files: every schema file, then
1884
+ * every data file, each in render order, which is the order `sql sync` and
1885
+ * `sql data` apply them. pgTAP tests stay out.
1883
1886
  */
1884
- function addConstraint(draft, element) {
1885
- const body = element.replace(CONSTRAINT_NAME, "");
1886
- const named = body !== element;
1887
- const primary = /^primary\s+key\s*\(([^)]*)\)/iu.exec(body);
1888
- if (primary !== null) {
1889
- draft.primaryKey = identList(primary[1]);
1890
- return true;
1891
- }
1892
- const foreign = /^foreign\s+key\s*\(([^)]*)\)\s*([\s\S]*)$/iu.exec(body);
1893
- if (foreign !== null) {
1894
- const references = (foreign[2] ?? "").match(REFERENCES);
1895
- if (references !== null) draft.foreignKeys.push({
1896
- columns: identList(foreign[1]),
1897
- target: target(references),
1898
- onDelete: onDeleteOf(foreign[2] ?? "")
1899
- });
1900
- return true;
1901
- }
1902
- return named || /^(?:unique|check|exclude)\b/iu.test(body);
1887
+ function deployQuery(files) {
1888
+ const schema = files.filter((file) => file.path.includes("/schemas/"));
1889
+ const data = files.filter((file) => file.path.includes("/better-supabase-data/"));
1890
+ return [...schema, ...data].map((file) => `-- ${file.path}\n${file.contents.trim()}\n`).join("\n");
1891
+ }
1892
+ /** A database password for a new project: 32 base64url characters. */
1893
+ function generatePassword() {
1894
+ const bytes = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(24));
1895
+ let binary = "";
1896
+ for (const byte of bytes) binary += String.fromCodePoint(byte);
1897
+ return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/u, "");
1898
+ }
1899
+ /** The project name the dialog suggests: the preset's name, or `my-app`. */
1900
+ function suggestedProjectName(named) {
1901
+ return named === void 0 ? "my-app" : `my-${named}-app`;
1902
+ }
1903
+ const DASHBOARD = "https://supabase.com/dashboard";
1904
+ function dashboardUrl(ref, page = "") {
1905
+ return `${DASHBOARD}/project/${encodeURIComponent(ref)}${page}`;
1906
+ }
1907
+ //#endregion
1908
+ //#region src/create/design-history.ts
1909
+ /** How many steps Undo can go back. */
1910
+ const HISTORY_LIMIT = 50;
1911
+ function initialHistory(value) {
1912
+ return {
1913
+ past: [],
1914
+ present: value,
1915
+ future: [],
1916
+ dragStart: null
1917
+ };
1903
1918
  }
1904
- function finish(draft, tenantColumn) {
1905
- const tenant = tenantColumn !== null && draft.columns.some((column) => column.name === tenantColumn) ? tenantColumn : null;
1906
- const primary = new Set(draft.primaryKey);
1919
+ function record(history, previous, next) {
1907
1920
  return {
1908
- id: `${draft.schema}.${draft.name}`,
1909
- schema: draft.schema,
1910
- name: draft.name,
1911
- module: draft.module,
1912
- primaryKey: draft.primaryKey,
1913
- foreignKeys: draft.foreignKeys,
1914
- tenantColumn: tenant,
1915
- columns: draft.columns.map((column) => primary.has(column.name) ? {
1916
- ...column,
1917
- nullable: false
1918
- } : column)
1921
+ past: [...history.past, previous].slice(-50),
1922
+ present: next,
1923
+ future: [],
1924
+ dragStart: null
1919
1925
  };
1920
1926
  }
1921
1927
  /**
1922
- * The tables in rendered module SQL: every `create table`, plus the columns
1923
- * and foreign keys later `alter table ... add` statements give them. A
1924
- * `create table` it can't read throws with the file and line, so a new SQL
1925
- * shape fails the tests instead of dropping a table from the diagram.
1928
+ * An undo history. `drag` updates the value without a step while the
1929
+ * pointer moves; `commitDrag` records the whole drag as one step. `amend`
1930
+ * replaces the value in the current step, so a follow-up such as placing a
1931
+ * dropped block stays part of the step that added it. `reset` replaces the
1932
+ * value and clears the history, as loading a link does.
1926
1933
  */
1927
- function parseSchema(files, options = {}) {
1928
- const drafts = /* @__PURE__ */ new Map();
1929
- const code = files.map((file) => ({
1930
- file,
1931
- text: codeOnly(file.contents)
1932
- }));
1933
- for (const { file, text } of code) for (const match of text.matchAll(CREATE_TABLE)) {
1934
- const offset = match.index;
1935
- const head = text.slice(offset).match(CREATE_HEAD);
1936
- const open = head === null ? -1 : offset + head[0].length - 1;
1937
- const body = open === -1 ? void 0 : balanced(text, open);
1938
- const original = body === void 0 ? "" : file.contents.slice(open + 1, open + 1 + body.length);
1939
- if (head === null || body === void 0) throw new Error(`parseSchema can't read the create table at ${file.path}:${lineOf(text, offset)}.`);
1940
- const { schema, table } = qualified(head[1] ?? "");
1941
- const id = `${schema}.${table}`;
1942
- if (drafts.has(id)) continue;
1943
- const draft = {
1944
- schema,
1945
- name: table,
1946
- module: file.module,
1947
- columns: [],
1948
- primaryKey: [],
1949
- foreignKeys: []
1934
+ function undoHistory(current, action) {
1935
+ switch (action.type) {
1936
+ case "apply": return action.value === current.present ? current : record(current, current.dragStart ?? current.present, action.value);
1937
+ case "drag": return {
1938
+ ...current,
1939
+ present: action.value,
1940
+ dragStart: current.dragStart ?? current.present
1950
1941
  };
1951
- for (const element of splitTopLevel(body, original)) if (!addConstraint(draft, element.code)) addColumn(draft, element.code, element.original);
1952
- drafts.set(id, draft);
1953
- }
1954
- for (const { file, text } of code) for (const match of text.matchAll(ALTER_TABLE)) {
1955
- const { schema, table } = qualified(match[1] ?? "");
1956
- const draft = drafts.get(`${schema}.${table}`);
1957
- if (draft === void 0) continue;
1958
- const actions = match[2] ?? "";
1959
- const start = match.index + match[0].lastIndexOf(actions);
1960
- const original = file.contents.slice(start, start + actions.length);
1961
- for (const action of splitTopLevel(actions, original)) {
1962
- const column = /^add\s+column\s+(?:if\s+not\s+exists\s+)?/iu.exec(action.code);
1963
- if (column !== null) addColumn(draft, action.code.slice(column[0].length), action.original.slice(column[0].length));
1964
- else if (/^add\s+/iu.test(action.code)) addConstraint(draft, action.code.replace(/^add\s+/iu, ""));
1942
+ case "commitDrag": return current.dragStart === null ? current : record(current, current.dragStart, current.present);
1943
+ case "amend": return {
1944
+ ...current,
1945
+ present: action.value
1946
+ };
1947
+ case "undo": {
1948
+ const previous = current.past.at(-1);
1949
+ return previous === void 0 ? current : {
1950
+ past: current.past.slice(0, -1),
1951
+ present: previous,
1952
+ future: [current.present, ...current.future],
1953
+ dragStart: null
1954
+ };
1955
+ }
1956
+ case "redo": {
1957
+ const [next, ...future] = current.future;
1958
+ return next === void 0 ? current : {
1959
+ past: [...current.past, current.present].slice(-50),
1960
+ present: next,
1961
+ future,
1962
+ dragStart: null
1963
+ };
1965
1964
  }
1965
+ case "reset": return initialHistory(action.value);
1966
+ default: return action;
1966
1967
  }
1967
- const tenantColumn = options.tenantColumn ?? null;
1968
- return [...drafts.entries()].filter(([id]) => !BOOKKEEPING_TABLES.has(id)).map(([, draft]) => finish(draft, tenantColumn));
1969
1968
  }
1970
- /**
1971
- * The statements that shape one table, as written: its `create table` and
1972
- * the `alter table` statements after it. Empty when no file creates it.
1973
- */
1974
- function tableStatements(files, id) {
1975
- const statements = [];
1976
- for (const file of files) {
1977
- const text = codeOnly(file.contents);
1978
- for (const match of text.matchAll(CREATE_TABLE)) {
1979
- const head = text.slice(match.index).match(CREATE_HEAD);
1980
- if (head === null) continue;
1981
- const { schema, table } = qualified(head[1] ?? "");
1982
- const open = match.index + head[0].length - 1;
1983
- const body = balanced(text, open);
1984
- if (`${schema}.${table}` !== id || body === void 0) continue;
1985
- const end = text.indexOf(";", open + body.length + 1);
1986
- statements.push(file.contents.slice(match.index, end === -1 ? text.length : end + 1));
1987
- }
1988
- for (const match of text.matchAll(ALTER_TABLE)) {
1989
- const { schema, table } = qualified(match[1] ?? "");
1990
- if (`${schema}.${table}` === id) statements.push(file.contents.slice(match.index, match.index + match[0].length));
1969
+ //#endregion
1970
+ //#region src/create/sample-rows.ts
1971
+ const SAMPLE_ROW_COUNT = 8;
1972
+ /** The columns of `table` a `viewer` can't select: `access: "server"` ones for a member. */
1973
+ function hiddenColumns(table, viewer) {
1974
+ if (viewer === "server") return [];
1975
+ return Object.entries(table?.columns ?? {}).filter(([, column]) => column.access === "server").map(([key]) => key);
1976
+ }
1977
+ const USERS = "auth.users";
1978
+ const PEOPLE = [
1979
+ "Ada Lovelace",
1980
+ "Grace Hopper",
1981
+ "Alan Turing",
1982
+ "Katherine Johnson",
1983
+ "Edsger Dijkstra",
1984
+ "Barbara Liskov",
1985
+ "Donald Knuth",
1986
+ "Frances Allen"
1987
+ ];
1988
+ const SENTENCES = [
1989
+ "A short note that explains the row.",
1990
+ "Longer text, such as a description or the body of a post.",
1991
+ "Written by the team and edited later.",
1992
+ "Kept for reference."
1993
+ ];
1994
+ const COLORS = [
1995
+ "#2563eb",
1996
+ "#16a34a",
1997
+ "#d97706",
1998
+ "#dc2626",
1999
+ "#7c3aed"
2000
+ ];
2001
+ const TITLE_COLUMNS = [
2002
+ "name",
2003
+ "title",
2004
+ "label",
2005
+ "subject"
2006
+ ];
2007
+ function capitalized(value) {
2008
+ return `${value.charAt(0).toUpperCase()}${value.slice(1)}`.replaceAll("_", " ");
2009
+ }
2010
+ /** The column a table's rows are named by: its subject title, then a likely name column. */
2011
+ function titleColumnOf(table) {
2012
+ const text = new Set(Object.entries(table.columns ?? {}).filter(([, column]) => column.type === "text" && column.format === void 0).map(([key]) => key));
2013
+ return table.subject?.title ?? TITLE_COLUMNS.find((key) => text.has(key));
2014
+ }
2015
+ /** The name of row `index` of `table`, so a reference shows the row it points at. */
2016
+ function rowTitle(table, index) {
2017
+ return `${capitalized(singular(table))} ${String(index + 1)}`;
2018
+ }
2019
+ function pad(value) {
2020
+ return String(value).padStart(2, "0");
2021
+ }
2022
+ /** A date `days` after 5 January 2026, as `YYYY-MM-DD`. */
2023
+ function dayAfter(days) {
2024
+ const date = new Date(Date.UTC(2026, 0, 5 + days));
2025
+ return `${String(date.getUTCFullYear())}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}`;
2026
+ }
2027
+ function numberIn(column, index, step) {
2028
+ const value = (column.min ?? 0) + index * step;
2029
+ return column.max === void 0 ? value : Math.min(value, column.max);
2030
+ }
2031
+ function formatted(column, index, slug) {
2032
+ switch (column.format) {
2033
+ case void 0: return;
2034
+ case "email": return `${(PEOPLE[index % PEOPLE.length] ?? "user").split(" ")[0]?.toLowerCase() ?? "user"}@example.com`;
2035
+ case "url": return `https://example.com/${slug}/${String(index + 1)}`;
2036
+ case "phone": return `+1 555 01${pad(index + 10)}`;
2037
+ case "long_text": return SENTENCES[index % SENTENCES.length] ?? "";
2038
+ case "color": return COLORS[index % COLORS.length] ?? "#000000";
2039
+ case "rating": {
2040
+ const min = column.min ?? 1;
2041
+ const max = column.max ?? 5;
2042
+ return String(min + index % (max - min + 1));
1991
2043
  }
2044
+ case "percent": return String(index * 17 % 101);
2045
+ case "currency": return ((index + 1) * 1250 / 100).toFixed(2);
2046
+ default: return column.format;
1992
2047
  }
1993
- return statements;
1994
2048
  }
1995
- /** The foreign keys between tables, one per pair, with the targets outside the schema named by id. */
1996
- function schemaRelations(tables) {
1997
- const seen = /* @__PURE__ */ new Set();
1998
- return tables.flatMap((table) => table.foreignKeys.flatMap((key) => {
1999
- const to = `${key.target.schema}.${key.target.table}`;
2000
- const pair = `${table.id}>${to}`;
2001
- if (to === table.id || seen.has(pair)) return [];
2002
- seen.add(pair);
2003
- return [{
2004
- from: table.id,
2005
- to
2006
- }];
2007
- }));
2049
+ function referenceValue(column, index) {
2050
+ const reference = column.references;
2051
+ if (reference === void 0) return;
2052
+ if (reference.block === void 0 && reference.table === USERS) return PEOPLE[index % PEOPLE.length] ?? "";
2053
+ return rowTitle(reference.table, index % 3);
2054
+ }
2055
+ function typedValue(column, index, slug) {
2056
+ switch (column.type) {
2057
+ case "text": return `${capitalized(slug)} ${String(index + 1)}`;
2058
+ case "uuid": return `00000000-0000-4000-8000-${String(index + 1).padStart(12, "0")}`;
2059
+ case "integer":
2060
+ case "bigint": return String(column.identity === true ? index + 1 : numberIn(column, index, 3));
2061
+ case "numeric": return numberIn(column, index, 2.5).toFixed(2);
2062
+ case "boolean": return String(index % 2 === 0);
2063
+ case "timestamptz": return `${dayAfter(index * 2)} ${pad(9 + index % 8)}:00`;
2064
+ case "date": return dayAfter(index * 3);
2065
+ case "jsonb": return "{}";
2066
+ case "text[]": return "{}";
2067
+ default: return column.type;
2068
+ }
2069
+ }
2070
+ function cell(table, key, column, index, title) {
2071
+ if (key === title) return rowTitle(table, index);
2072
+ if (column.nullable !== false && index % 4 === 3) return null;
2073
+ if (column.options !== void 0 && column.options.length > 0) return column.options[index % column.options.length] ?? null;
2074
+ return referenceValue(column, index) ?? formatted(column, index, key) ?? typedValue(column, index, key);
2075
+ }
2076
+ /**
2077
+ * Deterministic sample rows for app table `name`, from its columns' types,
2078
+ * formats, options, bounds and references. A reference shows the name of the
2079
+ * row it points at, so rows of related tables line up. A `member` viewer
2080
+ * doesn't get the columns `hiddenColumns` lists.
2081
+ */
2082
+ function sampleRows(design, name, count = 8, viewer = "server") {
2083
+ const table = design.appTables?.[name];
2084
+ if (table === void 0) return {
2085
+ columns: [],
2086
+ rows: []
2087
+ };
2088
+ const hidden = new Set(hiddenColumns(table, viewer));
2089
+ const entries = Object.entries(table.columns ?? {}).filter(([key]) => !hidden.has(key));
2090
+ const title = titleColumnOf(table);
2091
+ return {
2092
+ columns: entries.map(([key]) => key),
2093
+ rows: Array.from({ length: count }, (_, index) => Object.fromEntries(entries.map(([key, column]) => [key, cell(name, key, column, index, title)])))
2094
+ };
2008
2095
  }
2009
2096
  //#endregion
2010
2097
  //#region src/create/migration.ts
@@ -2046,4 +2133,4 @@ function migrationBetween(code, base, next) {
2046
2133
  };
2047
2134
  }
2048
2135
  //#endregion
2049
- export { APP_MODULE, COLUMN_KINDS, EMPTY_DESIGN, HISTORY_LIMIT, KIND_GROUPS, MIGRATION_NAME, APP_ON_DELETE_ACTIONS as ON_DELETE_ACTIONS, ROLLUP_AGGREGATES, SAMPLE_ROW_COUNT, addTable, appTableId, boundError, columnError, columnLabel, computedColumnRenamed, computedRows, computedTableRenamed, connect, dashboardUrl, defaultError, deleteColumn, deleteExtraColumn, deleteTable, deployBlocker, deployQuery, designIssues, duplicateTable, editTable, eventsColumnsEdited, filterColumns, fitted, fittedRollup, freeTableName, generatePassword, hiddenColumns, identifierError, initialHistory, isAppTable, isEmptyDesign, isRollupAggregate, keyColumnsOf, kindById, kindOf, lockedWithoutDefault, lookupSources, migrationBetween, moveTables, optionError, parseSchema, previewAccessProvider, previewFiles, prunedComputed, readableColumns, referenceFrom, renameColumn, renameTable, rollupColumns, rollupSources, sampleRows, schemaData, schemaRelations, setColumn, setColumnKind, setExtraColumn, setTableId, singular, subjectColumns, subjectColumnsEdited, subjectTypeError, suggestedProjectName, tableStatements, tableWithComputed, tableWithoutComputed, takesBounds, tenantColumnOf, tidy, undoHistory, updateTable, userConnection, withBounds, withDesign, withKind };
2136
+ export { APP_MODULE, COLUMN_KINDS, EMPTY_DESIGN, HISTORY_LIMIT, KIND_GROUPS, MIGRATION_NAME, APP_ON_DELETE_ACTIONS as ON_DELETE_ACTIONS, ROLLUP_AGGREGATES, SAMPLE_ROW_COUNT, addTable, appTableId, boundError, checkDesign, columnError, columnLabel, computedColumnRenamed, computedRows, computedTableRenamed, connect, dashboardUrl, defaultError, deleteColumn, deleteExtraColumn, deleteTable, deployBlocker, deployQuery, designIssues, duplicateTable, editTable, eventsColumnsEdited, filterColumns, fitted, fittedRollup, freeTableName, generatePassword, hiddenColumns, identifierError, initialHistory, isAppTable, isEmptyDesign, isRollupAggregate, keyColumnsOf, kindById, kindOf, lockedWithoutDefault, lookupSources, migrationBetween, moveTables, optionError, parseSchema, previewAccessProvider, previewFiles, prunedComputed, readableColumns, referenceFrom, renameColumn, renameTable, rollupColumns, rollupSources, sampleRows, schemaData, schemaRelations, setColumn, setColumnKind, setExtraColumn, setTableId, singular, subjectColumns, subjectColumnsEdited, subjectTypeError, suggestedProjectName, tableStatements, tableWithComputed, tableWithoutComputed, takesBounds, tenantColumnOf, tidy, undoHistory, updateTable, userConnection, withBounds, withDesign, withKind };