@lunora/studio 1.0.0-alpha.59 → 1.0.0-alpha.60

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 (381) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -43
  3. package/dist/mount.js +1 -27
  4. package/dist/packem_chunks/ApiTab.js +1 -251
  5. package/dist/packem_chunks/AuditPanel.js +1 -200
  6. package/dist/packem_chunks/DeploymentHealthPanel.js +1 -664
  7. package/dist/packem_chunks/ExportImportPanel.js +3 -198
  8. package/dist/packem_chunks/FileBrowser.js +4 -2955
  9. package/dist/packem_chunks/FunctionRunner.js +1 -326
  10. package/dist/packem_chunks/FunctionStatsPanel.js +1 -377
  11. package/dist/packem_chunks/HealthPanel.js +1 -648
  12. package/dist/packem_chunks/InsightsPanel.js +1 -462
  13. package/dist/packem_chunks/LogsPanel.js +1 -1303
  14. package/dist/packem_chunks/MailPanel.js +2 -353
  15. package/dist/packem_chunks/MetricsPanel.js +1 -1960
  16. package/dist/packem_chunks/MigrationsPanel.js +1 -239
  17. package/dist/packem_chunks/NotificationsPanel.js +1 -306
  18. package/dist/packem_chunks/PitrPanel.js +1 -252
  19. package/dist/packem_chunks/SchemaViewer.js +1 -2512
  20. package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -95
  21. package/dist/packem_chunks/SettingsPanel.js +1 -391
  22. package/dist/packem_chunks/SqlEditorPanel.js +4 -2340
  23. package/dist/packem_chunks/TableEditor.js +1 -290
  24. package/dist/packem_chunks/agents-panel.js +1 -326
  25. package/dist/packem_chunks/analytics-panel.js +1 -261
  26. package/dist/packem_chunks/auth-audit-panel.js +1 -247
  27. package/dist/packem_chunks/auth-config-panel.js +1 -365
  28. package/dist/packem_chunks/auth-sessions-panel.js +1 -175
  29. package/dist/packem_chunks/containers-panel.js +1 -261
  30. package/dist/packem_chunks/dashboards-panel.js +1 -781
  31. package/dist/packem_chunks/fanout-panel.js +1 -482
  32. package/dist/packem_chunks/flags-panel.js +1 -176
  33. package/dist/packem_chunks/issues-panel.js +1 -427
  34. package/dist/packem_chunks/kv-browser.js +1 -1896
  35. package/dist/packem_chunks/log-drains-panel.js +4 -273
  36. package/dist/packem_chunks/organizations-panel.js +1 -3209
  37. package/dist/packem_chunks/payments-panel.js +1 -213
  38. package/dist/packem_chunks/permissions-panel.js +1 -805
  39. package/dist/packem_chunks/queues-panel.js +1 -1075
  40. package/dist/packem_chunks/rls-panel.js +1 -315
  41. package/dist/packem_chunks/schedule-panel.js +1 -831
  42. package/dist/packem_chunks/sparkline.js +1 -79
  43. package/dist/packem_chunks/storage-rules-panel.js +1 -140
  44. package/dist/packem_chunks/subscriptions-panel.js +1 -238
  45. package/dist/packem_chunks/sync-client-panel.js +1 -0
  46. package/dist/packem_chunks/traces-panel.js +1 -747
  47. package/dist/packem_chunks/users-panel.js +1 -1731
  48. package/dist/packem_chunks/vector-browser.js +1 -281
  49. package/dist/packem_chunks/workflows-panel.js +1 -562
  50. package/dist/packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js +1 -0
  51. package/dist/packem_shared/ApiDocsPanel-eJYZlylw.js +2 -0
  52. package/dist/packem_shared/ApiReferencePanel-C42v1jr6.js +1 -0
  53. package/dist/packem_shared/CommandPalette-CVIaY3j8.js +1 -0
  54. package/dist/packem_shared/ConfirmButton-CTL3f3kr.js +1 -0
  55. package/dist/packem_shared/ConnectionBadge-DOk0CQWo.js +1 -0
  56. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js +1 -0
  57. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-B-hcFVoi.js +1 -0
  58. package/dist/packem_shared/DEFAULT_LOCALE-BZ4NojpD.js +1 -0
  59. package/dist/packem_shared/DataBrowser-B8J5lHjP.js +1 -0
  60. package/dist/packem_shared/DataFilters-Csb30F0C.js +1 -0
  61. package/dist/packem_shared/ErrorBoundary-DvzYskH7.js +1 -0
  62. package/dist/packem_shared/GlobalDataBrowser-RLJ6NvOs.js +1 -0
  63. package/dist/packem_shared/HomePanel-DL1HupAN.js +1 -0
  64. package/dist/packem_shared/OpenRpcReferencePanel-sGsIgYWj.js +1 -0
  65. package/dist/packem_shared/STUDIO_ROOT_CLASS-C6MccdVk.js +1 -0
  66. package/dist/packem_shared/ScheduledJobs-DUbo6epc.js +1 -0
  67. package/dist/packem_shared/ShardInput-BVn2iCU0.js +1 -0
  68. package/dist/packem_shared/Studio-BWBclm_C.js +1 -0
  69. package/dist/packem_shared/StudioApp-BFm73yVr.js +1 -0
  70. package/dist/packem_shared/StudioI18nProvider-CZ5h4nrV.js +1 -0
  71. package/dist/packem_shared/advisor-view-DaCX9Jy5.js +1 -0
  72. package/dist/packem_shared/aggregateMetrics-BNfajLa2.js +1 -0
  73. package/dist/packem_shared/alert-CVcOFuDR.js +1 -0
  74. package/dist/packem_shared/badge-BbuuAio7.js +1 -0
  75. package/dist/packem_shared/bar-chart-AryFCeoa.js +9 -0
  76. package/dist/packem_shared/browser-storage-xjTyMKY0.js +1 -0
  77. package/dist/packem_shared/button-BkCrNcAs.js +1 -0
  78. package/dist/packem_shared/card-CIDGUN6K.js +1 -0
  79. package/dist/packem_shared/cf-links-gbDy51nR.js +1 -0
  80. package/dist/packem_shared/checkbox-StT4Gob6.js +1 -0
  81. package/dist/packem_shared/data-grid-BMBKzMEJ.js +1 -0
  82. package/dist/packem_shared/data-view-params-C8T3bW1z.js +1 -0
  83. package/dist/packem_shared/dropdown-menu-C3RQ_HlW.js +2 -0
  84. package/dist/packem_shared/empty-state-Cg7t_8qu.js +1 -0
  85. package/dist/packem_shared/error-alert-B59DnrDI.js +1 -0
  86. package/dist/packem_shared/grid-features-uZCUj955.js +6 -0
  87. package/dist/packem_shared/home-panel-B-8BCffw.js +3 -0
  88. package/dist/packem_shared/input-JHu63lTv.js +1 -0
  89. package/dist/packem_shared/internal-AtZ4bTal.js +2 -0
  90. package/dist/packem_shared/label-6uP1obNF.js +1 -0
  91. package/dist/packem_shared/live-status-CGW2JHf_.js +1 -0
  92. package/dist/packem_shared/log-fields-CoL3hsIQ.js +1 -0
  93. package/dist/packem_shared/modal-shell-CUwwWC2o.js +1 -0
  94. package/dist/packem_shared/reference-view-KvhektwF.js +12 -0
  95. package/dist/packem_shared/result-chart-CwKhhKM0.js +1 -0
  96. package/dist/packem_shared/scroll-area-DTEq6Jec.js +2 -0
  97. package/dist/packem_shared/select-Bul-DeII.js +2 -0
  98. package/dist/packem_shared/shard-history-DMEW5VBE.js +1 -0
  99. package/dist/packem_shared/skeleton-C1wQ9M5t.js +1 -0
  100. package/dist/packem_shared/sparkline-DtcZoU48.js +1 -0
  101. package/dist/packem_shared/storage-tier-DznqOf-q.js +1 -0
  102. package/dist/packem_shared/studio-BHA7hnI3.js +2 -0
  103. package/dist/packem_shared/table-DdJBrClo.js +2 -0
  104. package/dist/packem_shared/table-list-sidebar-CMCcNALK.js +1 -0
  105. package/dist/packem_shared/textarea-Bu2-jKAs.js +1 -0
  106. package/dist/packem_shared/trace-handoff-Dw7mwjxu.js +1 -0
  107. package/dist/packem_shared/use-admin-query-Di3fLE8H.js +1 -0
  108. package/dist/packem_shared/use-async-submit-H68GHPz8.js +1 -0
  109. package/dist/packem_shared/useDebounced-Ihdiid_k.js +1 -0
  110. package/dist/packem_shared/utils-bhneXptQ.js +1 -0
  111. package/dist/packem_shared/virtual-rect-1o1veP7R.js +1 -0
  112. package/dist/standalone/chunk-23HKRH5H.js +13 -0
  113. package/dist/standalone/chunk-2A4RKII2.js +1 -0
  114. package/dist/standalone/chunk-3DTM4GI5.js +1 -0
  115. package/dist/standalone/chunk-3MHKT76P.js +1 -0
  116. package/dist/standalone/chunk-46IB4C4Q.js +1 -0
  117. package/dist/standalone/chunk-4AYEV5UN.js +1 -0
  118. package/dist/standalone/chunk-4FNHHFWR.js +1 -0
  119. package/dist/standalone/chunk-6CLVIOCB.js +1 -0
  120. package/dist/standalone/chunk-6I62RSI5.js +1 -0
  121. package/dist/standalone/chunk-6OKDCV7J.js +1 -0
  122. package/dist/standalone/chunk-6P7HIPUE.js +1 -0
  123. package/dist/standalone/chunk-6UYILUSX.js +1 -0
  124. package/dist/standalone/chunk-725RLB7D.js +1 -0
  125. package/dist/standalone/chunk-7AZZ7OJO.js +1 -0
  126. package/dist/standalone/chunk-7CRLAMGB.js +1 -0
  127. package/dist/standalone/chunk-7Z5QEFR4.js +2 -0
  128. package/dist/standalone/chunk-AGVJJQFL.js +1 -0
  129. package/dist/standalone/chunk-AKTGRZXN.js +1 -0
  130. package/dist/standalone/chunk-BAIN7UJ4.js +1 -0
  131. package/dist/standalone/chunk-BHWSIIDT.js +1 -0
  132. package/dist/standalone/{chunk-L7SK4ZZD.js → chunk-C4O5UR4Y.js} +1 -1
  133. package/dist/standalone/chunk-C4VURT57.js +1 -0
  134. package/dist/standalone/chunk-CKO3F55C.js +4 -0
  135. package/dist/standalone/chunk-CVMRZUF5.js +4 -0
  136. package/dist/standalone/chunk-CWWGDW4V.js +1 -0
  137. package/dist/standalone/chunk-CYET4BRZ.js +1 -0
  138. package/dist/standalone/chunk-CZEUVNCQ.js +1 -0
  139. package/dist/standalone/chunk-FXFK4M4E.js +1 -0
  140. package/dist/standalone/chunk-FYAJPWE7.js +1 -0
  141. package/dist/standalone/chunk-GS7OBQO5.js +1 -0
  142. package/dist/standalone/chunk-GTXVH7I5.js +1 -0
  143. package/dist/standalone/chunk-H6SIM4BT.js +1 -0
  144. package/dist/standalone/chunk-H6WOFY6A.js +8 -0
  145. package/dist/standalone/chunk-HA34GYEX.js +1 -0
  146. package/dist/standalone/chunk-HMIOF5GV.js +1 -0
  147. package/dist/standalone/chunk-HY46NTNW.js +6 -0
  148. package/dist/standalone/chunk-IBCKC2BO.js +1 -0
  149. package/dist/standalone/chunk-ICKBVXPP.js +1 -0
  150. package/dist/standalone/chunk-IE4ROTQD.js +1 -0
  151. package/dist/standalone/chunk-IYYTWZ2E.js +2 -0
  152. package/dist/standalone/chunk-J2LMP2A7.js +1 -0
  153. package/dist/standalone/chunk-JC6WYIHM.js +1 -0
  154. package/dist/standalone/chunk-JKPK25JO.js +1 -0
  155. package/dist/standalone/chunk-JLFCXBNQ.js +1 -0
  156. package/dist/standalone/chunk-JRWBGR5B.js +1 -0
  157. package/dist/standalone/chunk-K5PFWU5J.js +1 -0
  158. package/dist/standalone/chunk-KJTLW5W2.js +11 -0
  159. package/dist/standalone/{chunk-HBGS4SEX.js → chunk-KLLYGWNF.js} +9 -9
  160. package/dist/standalone/chunk-KNN3ZEQ7.js +1 -0
  161. package/dist/standalone/{chunk-4QHKBC77.js → chunk-KOC5KV3E.js} +1 -1
  162. package/dist/standalone/chunk-KSRXMTBV.js +1 -0
  163. package/dist/standalone/chunk-KYCAYNXM.js +1 -0
  164. package/dist/standalone/chunk-KZ2YUNMR.js +1 -0
  165. package/dist/standalone/chunk-LKHUVEHX.js +1 -0
  166. package/dist/standalone/chunk-LPOKAJT4.js +4 -0
  167. package/dist/standalone/chunk-MZEK4SGD.js +1 -0
  168. package/dist/standalone/chunk-NCCUM26H.js +1 -0
  169. package/dist/standalone/chunk-O62HJZV3.js +1 -0
  170. package/dist/standalone/chunk-OTJOI23O.js +62 -0
  171. package/dist/standalone/chunk-P2NBOUGZ.js +1 -0
  172. package/dist/standalone/chunk-P4J6XNG3.js +1 -0
  173. package/dist/standalone/chunk-PGDWFWH5.js +1 -0
  174. package/dist/standalone/chunk-PR2SE2MD.js +1 -0
  175. package/dist/standalone/chunk-PTTDIYGP.js +1 -0
  176. package/dist/standalone/chunk-PWDMXMRD.js +1 -0
  177. package/dist/standalone/chunk-Q34MSC2F.js +1 -0
  178. package/dist/standalone/chunk-Q5WXTZWX.js +1 -0
  179. package/dist/standalone/chunk-QC5HCNJZ.js +4 -0
  180. package/dist/standalone/chunk-QJKRHZYV.js +1 -0
  181. package/dist/standalone/chunk-R43KHQDA.js +1 -0
  182. package/dist/standalone/chunk-RC2K5RBE.js +1 -0
  183. package/dist/standalone/chunk-RE6UWCMG.js +1 -0
  184. package/dist/standalone/chunk-RUP3M2GF.js +3 -0
  185. package/dist/standalone/chunk-SA6MBPBL.js +1 -0
  186. package/dist/standalone/{chunk-BJGBHGK3.js → chunk-SEDZDNQF.js} +1 -1
  187. package/dist/standalone/chunk-SKHEGARW.js +1 -0
  188. package/dist/standalone/chunk-SKJZDOHG.js +1 -0
  189. package/dist/standalone/chunk-SNDYNCAA.js +1 -0
  190. package/dist/standalone/chunk-SZUHZ2OG.js +1 -0
  191. package/dist/standalone/chunk-TAE2H7PU.js +1 -0
  192. package/dist/standalone/chunk-TEIBKU46.js +1 -0
  193. package/dist/standalone/chunk-TO6NLVFD.js +1 -0
  194. package/dist/standalone/chunk-TYTJDFX2.js +1 -0
  195. package/dist/standalone/{chunk-LXULVPEM.js → chunk-UDZY7MKE.js} +3 -3
  196. package/dist/standalone/chunk-UHHTEBC3.js +1 -0
  197. package/dist/standalone/chunk-UNDFOYRI.js +1 -0
  198. package/dist/standalone/chunk-UNN4CESU.js +1 -0
  199. package/dist/standalone/chunk-UNXX5GQH.js +1 -0
  200. package/dist/standalone/{chunk-ZHVTQ37P.js → chunk-UREY4GLG.js} +1 -1
  201. package/dist/standalone/chunk-UWF5DOGV.js +1 -0
  202. package/dist/standalone/chunk-UY2Y5CXB.js +1 -0
  203. package/dist/standalone/{chunk-VLXV72QE.js → chunk-UZYGEOWY.js} +1 -1
  204. package/dist/standalone/chunk-V66TSUKV.js +1 -0
  205. package/dist/standalone/chunk-VEFNSN7P.js +1 -0
  206. package/dist/standalone/chunk-VUJGR4PB.js +1 -0
  207. package/dist/standalone/chunk-VUXJER3D.js +1 -0
  208. package/dist/standalone/chunk-W572365D.js +1 -0
  209. package/dist/standalone/chunk-WYFLGXZ3.js +3 -0
  210. package/dist/standalone/chunk-XDKFPBIL.js +1 -0
  211. package/dist/standalone/chunk-XRKCGQM2.js +1 -0
  212. package/dist/standalone/chunk-YNBJ6ICE.js +1 -0
  213. package/dist/standalone/chunk-YQ5PILIJ.js +1 -0
  214. package/dist/standalone/chunk-YT7VXQVX.js +1 -0
  215. package/dist/standalone/chunk-Z7MUQMLE.js +1 -0
  216. package/dist/standalone/chunk-ZFWEPGWG.js +1 -0
  217. package/dist/standalone/chunk-ZMFZRGAN.js +1 -0
  218. package/dist/standalone/studio.js +9 -214
  219. package/package.json +4 -4
  220. package/dist/packem_shared/ADMIN_FUNCTIONS-P2UzJscH.js +0 -62
  221. package/dist/packem_shared/ApiDocsPanel-DNDpeR5O.js +0 -842
  222. package/dist/packem_shared/ApiReferencePanel-ChlRsAXU.js +0 -230
  223. package/dist/packem_shared/CommandPalette-BpkopP5f.js +0 -373
  224. package/dist/packem_shared/ConfirmButton-C2eVi2Qv.js +0 -59
  225. package/dist/packem_shared/ConnectionBadge-B2DDM2Tn.js +0 -111
  226. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Vxwaxx51.js +0 -50
  227. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-DjF0h-gA.js +0 -89
  228. package/dist/packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js +0 -27
  229. package/dist/packem_shared/DataBrowser-obTn4sKX.js +0 -4493
  230. package/dist/packem_shared/DataFilters-B1Q7mrt7.js +0 -253
  231. package/dist/packem_shared/ErrorBoundary-BzAApI7J.js +0 -66
  232. package/dist/packem_shared/GlobalDataBrowser-BCaohHZ5.js +0 -293
  233. package/dist/packem_shared/HomePanel-DCRj3hGB.js +0 -14
  234. package/dist/packem_shared/OpenRpcReferencePanel-CIeQE1aE.js +0 -192
  235. package/dist/packem_shared/STUDIO_ROOT_CLASS-D12gX2dV.js +0 -3
  236. package/dist/packem_shared/ScheduledJobs-BQzQo84k.js +0 -262
  237. package/dist/packem_shared/ShardInput-CZnpHILL.js +0 -107
  238. package/dist/packem_shared/Studio-DnlPCbID.js +0 -16
  239. package/dist/packem_shared/StudioApp-CzqlB4zO.js +0 -708
  240. package/dist/packem_shared/StudioI18nProvider-B-tDCZIi.js +0 -48
  241. package/dist/packem_shared/advisor-view-D95sN-wO.js +0 -159
  242. package/dist/packem_shared/aggregateMetrics-D4nUHEKU.js +0 -108
  243. package/dist/packem_shared/alert-CdAET2K_.js +0 -68
  244. package/dist/packem_shared/badge-B2PKA1-5.js +0 -49
  245. package/dist/packem_shared/bar-chart-DSwcWIRy.js +0 -3246
  246. package/dist/packem_shared/browser-storage-L4gOP5gJ.js +0 -105
  247. package/dist/packem_shared/button-BhsN2uZH.js +0 -49
  248. package/dist/packem_shared/card-F2vH_aj2.js +0 -175
  249. package/dist/packem_shared/cf-links-SIbyi4Y1.js +0 -8
  250. package/dist/packem_shared/checkbox-UNkzAxl-.js +0 -63
  251. package/dist/packem_shared/data-grid-BywzWfek.js +0 -183
  252. package/dist/packem_shared/data-view-params-Cd6yRVbv.js +0 -96
  253. package/dist/packem_shared/dropdown-menu-WY4B_eJO.js +0 -280
  254. package/dist/packem_shared/empty-state-DY_oe0k6.js +0 -98
  255. package/dist/packem_shared/error-alert-D9uIFJUS.js +0 -114
  256. package/dist/packem_shared/grid-features-ZOLhHKrR.js +0 -809
  257. package/dist/packem_shared/home-panel-BRAA2UlM.js +0 -1889
  258. package/dist/packem_shared/input-XH4r1Pt1.js +0 -53
  259. package/dist/packem_shared/internal-DzHCc2Rq.js +0 -131
  260. package/dist/packem_shared/label-D8ykjn5J.js +0 -46
  261. package/dist/packem_shared/live-status-FZ0psC1z.js +0 -44
  262. package/dist/packem_shared/log-fields-jEH83H2G.js +0 -18
  263. package/dist/packem_shared/modal-shell-hyaJvIJ6.js +0 -100
  264. package/dist/packem_shared/reference-view-DfXN7oWP.js +0 -2127
  265. package/dist/packem_shared/result-chart-Bf9mbCIo.js +0 -119
  266. package/dist/packem_shared/scroll-area-DLhcy-ml.js +0 -93
  267. package/dist/packem_shared/select-D9OwHEch.js +0 -273
  268. package/dist/packem_shared/shard-history-AxiJ1WPP.js +0 -16
  269. package/dist/packem_shared/skeleton-CGhL0p20.js +0 -45
  270. package/dist/packem_shared/sparkline-BnA1kC9X.js +0 -93
  271. package/dist/packem_shared/storage-tier-CL98eOvn.js +0 -85
  272. package/dist/packem_shared/studio-8QSXbZ98.js +0 -4192
  273. package/dist/packem_shared/table-DsCa9Qp9.js +0 -246
  274. package/dist/packem_shared/table-list-sidebar-gCE17v9B.js +0 -842
  275. package/dist/packem_shared/textarea-D3gaCU_-.js +0 -46
  276. package/dist/packem_shared/trace-handoff-CGolF3KS.js +0 -38
  277. package/dist/packem_shared/use-admin-query-C7JNuQp-.js +0 -106
  278. package/dist/packem_shared/use-async-submit-rnSk_jXl.js +0 -91
  279. package/dist/packem_shared/useDebounced-Dxncpg6z.js +0 -32
  280. package/dist/packem_shared/utils-B05Dmz_H.js +0 -8
  281. package/dist/packem_shared/virtual-rect-CVMUskSm.js +0 -10
  282. package/dist/standalone/chunk-2K47A3P6.js +0 -1
  283. package/dist/standalone/chunk-2MLA6WFH.js +0 -1
  284. package/dist/standalone/chunk-2NGUNNGW.js +0 -1
  285. package/dist/standalone/chunk-2TJVFKD2.js +0 -1
  286. package/dist/standalone/chunk-2YTF6LJ6.js +0 -1
  287. package/dist/standalone/chunk-3GXGLNKW.js +0 -1
  288. package/dist/standalone/chunk-3HGNPZBN.js +0 -1
  289. package/dist/standalone/chunk-3LJEGSMK.js +0 -11
  290. package/dist/standalone/chunk-3OA7PECS.js +0 -6
  291. package/dist/standalone/chunk-4PC7IXNY.js +0 -1
  292. package/dist/standalone/chunk-56XQYNUJ.js +0 -1
  293. package/dist/standalone/chunk-5OIBXYZM.js +0 -1
  294. package/dist/standalone/chunk-5QT5JRXD.js +0 -3
  295. package/dist/standalone/chunk-6RLPR7PL.js +0 -1
  296. package/dist/standalone/chunk-6V74EUPK.js +0 -1
  297. package/dist/standalone/chunk-7EE33WLB.js +0 -1
  298. package/dist/standalone/chunk-7TJJXVSE.js +0 -1
  299. package/dist/standalone/chunk-AHILM3ZP.js +0 -1
  300. package/dist/standalone/chunk-AN4RKMKW.js +0 -1
  301. package/dist/standalone/chunk-APSSZB6Z.js +0 -1
  302. package/dist/standalone/chunk-AXNGWSBM.js +0 -1
  303. package/dist/standalone/chunk-AXZILWRM.js +0 -1
  304. package/dist/standalone/chunk-C7RHEBOH.js +0 -1
  305. package/dist/standalone/chunk-CKSHCYGC.js +0 -2
  306. package/dist/standalone/chunk-CSWIYOB3.js +0 -1
  307. package/dist/standalone/chunk-D3VAON25.js +0 -1
  308. package/dist/standalone/chunk-DDLQN67F.js +0 -1
  309. package/dist/standalone/chunk-DGHW5JG5.js +0 -1
  310. package/dist/standalone/chunk-DMCSOTAE.js +0 -3
  311. package/dist/standalone/chunk-E3BKETAS.js +0 -1
  312. package/dist/standalone/chunk-E3OXNN6O.js +0 -1
  313. package/dist/standalone/chunk-E6BOGDIS.js +0 -1
  314. package/dist/standalone/chunk-F2YMCQ6B.js +0 -1
  315. package/dist/standalone/chunk-F7GE4X2U.js +0 -1
  316. package/dist/standalone/chunk-FAVUOGJR.js +0 -1
  317. package/dist/standalone/chunk-FXP6256Q.js +0 -1
  318. package/dist/standalone/chunk-G6CTAYHJ.js +0 -1
  319. package/dist/standalone/chunk-GTM65MVX.js +0 -1
  320. package/dist/standalone/chunk-H42W62SE.js +0 -1
  321. package/dist/standalone/chunk-HTF5ZX4I.js +0 -8
  322. package/dist/standalone/chunk-HV7G6DFP.js +0 -5
  323. package/dist/standalone/chunk-I2PS4L74.js +0 -1
  324. package/dist/standalone/chunk-IYHPYY4A.js +0 -1
  325. package/dist/standalone/chunk-J6J54MBP.js +0 -1
  326. package/dist/standalone/chunk-J7OGP4NN.js +0 -1
  327. package/dist/standalone/chunk-JSEXCW5Q.js +0 -1
  328. package/dist/standalone/chunk-JZLGLG4T.js +0 -1
  329. package/dist/standalone/chunk-KEGAWN6Y.js +0 -1
  330. package/dist/standalone/chunk-KZ6INM5M.js +0 -1
  331. package/dist/standalone/chunk-L2LN3MK4.js +0 -4
  332. package/dist/standalone/chunk-LT3FH6MW.js +0 -1
  333. package/dist/standalone/chunk-LZUWZBPE.js +0 -1
  334. package/dist/standalone/chunk-M4JM3TOY.js +0 -1
  335. package/dist/standalone/chunk-MLA5ZAEB.js +0 -1
  336. package/dist/standalone/chunk-MRBI5HNQ.js +0 -1
  337. package/dist/standalone/chunk-N5XX4HOL.js +0 -6
  338. package/dist/standalone/chunk-N7SVJOHN.js +0 -1
  339. package/dist/standalone/chunk-NKFXMDOD.js +0 -1
  340. package/dist/standalone/chunk-NPSNKFHE.js +0 -1
  341. package/dist/standalone/chunk-O3NAGRTR.js +0 -1
  342. package/dist/standalone/chunk-O7FVPUCO.js +0 -1
  343. package/dist/standalone/chunk-OKQXTLFX.js +0 -1
  344. package/dist/standalone/chunk-OXHHSUXO.js +0 -1
  345. package/dist/standalone/chunk-QAFAJBAW.js +0 -1
  346. package/dist/standalone/chunk-QAIM6KWT.js +0 -1
  347. package/dist/standalone/chunk-QCPMTB6W.js +0 -1
  348. package/dist/standalone/chunk-QQ2LOSZL.js +0 -1
  349. package/dist/standalone/chunk-QVIPA6UJ.js +0 -1
  350. package/dist/standalone/chunk-QVUQXJCT.js +0 -4
  351. package/dist/standalone/chunk-R2GMHLJY.js +0 -1
  352. package/dist/standalone/chunk-RD5UG2YL.js +0 -1
  353. package/dist/standalone/chunk-RJTIP3WF.js +0 -1
  354. package/dist/standalone/chunk-RRCPZMC2.js +0 -22
  355. package/dist/standalone/chunk-SHERR7ZP.js +0 -1
  356. package/dist/standalone/chunk-SOC5CY3F.js +0 -1
  357. package/dist/standalone/chunk-SS7JLF2I.js +0 -4
  358. package/dist/standalone/chunk-SWWYUGPL.js +0 -2
  359. package/dist/standalone/chunk-TAD43CG5.js +0 -1
  360. package/dist/standalone/chunk-TTXRHJUP.js +0 -4
  361. package/dist/standalone/chunk-UK64ZSUW.js +0 -1
  362. package/dist/standalone/chunk-UKDHGVOC.js +0 -1
  363. package/dist/standalone/chunk-UPNTMJFF.js +0 -1
  364. package/dist/standalone/chunk-V43BLH4J.js +0 -1
  365. package/dist/standalone/chunk-VL23Y44O.js +0 -4
  366. package/dist/standalone/chunk-VXM5H542.js +0 -4
  367. package/dist/standalone/chunk-WMDH2CIZ.js +0 -1
  368. package/dist/standalone/chunk-WVTPZ6CM.js +0 -1
  369. package/dist/standalone/chunk-XN6QYJQ6.js +0 -13
  370. package/dist/standalone/chunk-XNJNSCLM.js +0 -1
  371. package/dist/standalone/chunk-Y4U6CC22.js +0 -1
  372. package/dist/standalone/chunk-Y572GMZE.js +0 -1
  373. package/dist/standalone/chunk-Y7PD5KP4.js +0 -76
  374. package/dist/standalone/chunk-YFIPHCEC.js +0 -1
  375. package/dist/standalone/chunk-YJXOWLFJ.js +0 -1
  376. package/dist/standalone/chunk-YNN6NFRZ.js +0 -1
  377. package/dist/standalone/chunk-YUGHRVPD.js +0 -1
  378. package/dist/standalone/chunk-ZIGWVHCS.js +0 -1
  379. package/dist/standalone/chunk-ZPP2KOR4.js +0 -1
  380. package/dist/standalone/chunk-ZPUO7FNI.js +0 -1
  381. /package/dist/standalone/{chunk-TEWVD66F.js → chunk-GXZAXNZI.js} +0 -0
@@ -1,2513 +1,2 @@
1
1
  'use client';
2
- import { c } from 'react/compiler-runtime';
3
- import { useLunora } from '@lunora/react';
4
- import { useState, useRef, useEffect } from 'react';
5
- import { ShardInput } from '../packem_shared/ShardInput-CZnpHILL.js';
6
- import { S as StorageTierBadge, T as TIER_META } from '../packem_shared/storage-tier-CL98eOvn.js';
7
- import { B as Badge } from '../packem_shared/badge-B2PKA1-5.js';
8
- import { B as Button } from '../packem_shared/button-BhsN2uZH.js';
9
- import { C as Card, c as CardHeader, b as CardTitle, d as CardDescription, a as CardContent } from '../packem_shared/card-F2vH_aj2.js';
10
- import { E as EmptyState } from '../packem_shared/empty-state-DY_oe0k6.js';
11
- import { I as Input } from '../packem_shared/input-XH4r1Pt1.js';
12
- import useDebounced from '../packem_shared/useDebounced-Dxncpg6z.js';
13
- import { useT } from '../packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js';
14
- import { ADMIN_FUNCTIONS } from '../packem_shared/ADMIN_FUNCTIONS-P2UzJscH.js';
15
- import { f as fireAndForget, c as callOptions, e as errorMessage, a as adminRef } from '../packem_shared/internal-DzHCc2Rq.js';
16
- import { r as recordShard } from '../packem_shared/shard-history-AxiJ1WPP.js';
17
- import { c as cn } from '../packem_shared/utils-B05Dmz_H.js';
18
- import { Download01Icon } from '@hugeicons/core-free-icons';
19
- import { HugeiconsIcon } from '@hugeicons/react';
20
- import { Handle, Position, getNodesBounds, getViewportForBounds, useNodesState, useEdgesState, Background, Panel, Controls, MiniMap, ReactFlow, useNodes, useReactFlow } from '@xyflow/react';
21
- import { d as DropdownMenu, D as DropdownMenuTrigger, c as DropdownMenuContent, b as DropdownMenuItem } from '../packem_shared/dropdown-menu-WY4B_eJO.js';
22
- import { jsxDEV } from 'react/jsx-dev-runtime';
23
- import { LunoraError } from '@lunora/errors';
24
- import { toBlob, toSvg } from 'html-to-image';
25
- import { useNavigate } from '@tanstack/react-router';
26
- import { L as Label } from '../packem_shared/label-D8ykjn5J.js';
27
-
28
- function BaseNode(t0) {
29
- const $ = c(10);
30
- let className;
31
- let props;
32
- let selected;
33
- if ($[0] !== t0) {
34
- ({
35
- className,
36
- selected,
37
- ...props
38
- } = t0);
39
- $[0] = t0;
40
- $[1] = className;
41
- $[2] = props;
42
- $[3] = selected;
43
- } else {
44
- className = $[1];
45
- props = $[2];
46
- selected = $[3];
47
- }
48
- const t1 = selected === true ? "" : void 0;
49
- let t2;
50
- if ($[4] !== className) {
51
- t2 = cn("rounded-md border border-border bg-card text-card-foreground shadow-sm transition-colors", "data-[selected]:border-ring data-[selected]:ring-[3px] data-[selected]:ring-ring/30", className);
52
- $[4] = className;
53
- $[5] = t2;
54
- } else {
55
- t2 = $[5];
56
- }
57
- let t3;
58
- if ($[6] !== props || $[7] !== t1 || $[8] !== t2) {
59
- t3 = /* @__PURE__ */ jsxDEV("div", {
60
- "data-slot": "base-node",
61
- "data-selected": t1,
62
- className: t2,
63
- ...props
64
- }, void 0, false);
65
- $[6] = props;
66
- $[7] = t1;
67
- $[8] = t2;
68
- $[9] = t3;
69
- } else {
70
- t3 = $[9];
71
- }
72
- return t3;
73
- }
74
- function BaseNodeHeader(t0) {
75
- const $ = c(8);
76
- let className;
77
- let props;
78
- if ($[0] !== t0) {
79
- ({
80
- className,
81
- ...props
82
- } = t0);
83
- $[0] = t0;
84
- $[1] = className;
85
- $[2] = props;
86
- } else {
87
- className = $[1];
88
- props = $[2];
89
- }
90
- let t1;
91
- if ($[3] !== className) {
92
- t1 = cn("flex items-center gap-2 rounded-t-md bg-muted/50 px-3 py-1.5", className);
93
- $[3] = className;
94
- $[4] = t1;
95
- } else {
96
- t1 = $[4];
97
- }
98
- let t2;
99
- if ($[5] !== props || $[6] !== t1) {
100
- t2 = /* @__PURE__ */ jsxDEV("div", {
101
- "data-slot": "base-node-header",
102
- className: t1,
103
- ...props
104
- }, void 0, false);
105
- $[5] = props;
106
- $[6] = t1;
107
- $[7] = t2;
108
- } else {
109
- t2 = $[7];
110
- }
111
- return t2;
112
- }
113
- function BaseNodeContent(t0) {
114
- const $ = c(8);
115
- let className;
116
- let props;
117
- if ($[0] !== t0) {
118
- ({
119
- className,
120
- ...props
121
- } = t0);
122
- $[0] = t0;
123
- $[1] = className;
124
- $[2] = props;
125
- } else {
126
- className = $[1];
127
- props = $[2];
128
- }
129
- let t1;
130
- if ($[3] !== className) {
131
- t1 = cn("flex flex-col", className);
132
- $[3] = className;
133
- $[4] = t1;
134
- } else {
135
- t1 = $[4];
136
- }
137
- let t2;
138
- if ($[5] !== props || $[6] !== t1) {
139
- t2 = /* @__PURE__ */ jsxDEV("div", {
140
- "data-slot": "base-node-content",
141
- className: t1,
142
- ...props
143
- }, void 0, false);
144
- $[5] = props;
145
- $[6] = t1;
146
- $[7] = t2;
147
- } else {
148
- t2 = $[7];
149
- }
150
- return t2;
151
- }
152
-
153
- const typeLabel = (column) => {
154
- const base = column.ref === void 0 ? column.type : `${column.type} → ${column.ref}`;
155
- return column.optional === true ? `${base}?` : base;
156
- };
157
- const DatabaseSchemaNode = (t0) => {
158
- const $ = c(22);
159
- const {
160
- data,
161
- selected
162
- } = t0;
163
- const t = useT();
164
- let t1;
165
- if ($[0] !== data.label || $[1] !== data.loadError || $[2] !== t) {
166
- t1 = data.loadError === true ? /* @__PURE__ */ jsxDEV("span", {
167
- className: "px-3 py-1.5 text-xs text-destructive",
168
- "data-testid": `sd-node-${data.label}-error`,
169
- children: t("Columns unavailable")
170
- }, void 0, false) : /* @__PURE__ */ jsxDEV("span", {
171
- className: "px-3 py-1.5 text-xs text-muted-foreground",
172
- children: "—"
173
- }, void 0, false);
174
- $[0] = data.label;
175
- $[1] = data.loadError;
176
- $[2] = t;
177
- $[3] = t1;
178
- } else {
179
- t1 = $[3];
180
- }
181
- const emptyPlaceholder = t1;
182
- const t2 = `sd-node-${data.label}`;
183
- let t3;
184
- if ($[4] !== data.label) {
185
- t3 = /* @__PURE__ */ jsxDEV("span", {
186
- className: "truncate font-mono text-xs font-semibold",
187
- title: data.label,
188
- children: data.label
189
- }, void 0, false);
190
- $[4] = data.label;
191
- $[5] = t3;
192
- } else {
193
- t3 = $[5];
194
- }
195
- let t4;
196
- if ($[6] !== data.tier) {
197
- t4 = /* @__PURE__ */ jsxDEV("span", {
198
- className: "ms-auto",
199
- children: /* @__PURE__ */ jsxDEV(StorageTierBadge, {
200
- tier: data.tier
201
- }, void 0, false)
202
- }, void 0, false);
203
- $[6] = data.tier;
204
- $[7] = t4;
205
- } else {
206
- t4 = $[7];
207
- }
208
- let t5;
209
- if ($[8] !== t3 || $[9] !== t4) {
210
- t5 = /* @__PURE__ */ jsxDEV(BaseNodeHeader, {
211
- children: [t3, t4]
212
- }, void 0, true);
213
- $[8] = t3;
214
- $[9] = t4;
215
- $[10] = t5;
216
- } else {
217
- t5 = $[10];
218
- }
219
- let t6;
220
- if ($[11] !== data.columns || $[12] !== data.label || $[13] !== emptyPlaceholder) {
221
- t6 = data.columns.length === 0 ? emptyPlaceholder : data.columns.map((column) => /* @__PURE__ */ jsxDEV("div", {
222
- className: cn("relative flex items-center gap-2 border-t border-border px-3 py-1.5 text-xs first:border-t-0", column.pk === true && "bg-muted/30"),
223
- "data-testid": `sd-col-${data.label}-${column.name}`,
224
- children: [/* @__PURE__ */ jsxDEV(Handle, {
225
- className: "!h-2 !w-2 !-left-1 !border-border !bg-muted-foreground/70",
226
- id: column.name,
227
- isConnectable: false,
228
- position: Position.Left,
229
- type: "target"
230
- }, void 0, false), /* @__PURE__ */ jsxDEV("span", {
231
- className: "truncate font-mono",
232
- title: column.name,
233
- children: column.name
234
- }, void 0, false), column.pk === true && /* @__PURE__ */ jsxDEV(Badge, {
235
- className: "px-1 py-0 text-[10px] leading-tight",
236
- variant: "secondary",
237
- children: "PK"
238
- }, void 0, false), column.ref !== void 0 && /* @__PURE__ */ jsxDEV(Badge, {
239
- className: "px-1 py-0 text-[10px] leading-tight",
240
- variant: "outline",
241
- children: "FK"
242
- }, void 0, false), /* @__PURE__ */ jsxDEV("span", {
243
- className: "ms-auto truncate text-muted-foreground",
244
- title: typeLabel(column),
245
- children: typeLabel(column)
246
- }, void 0, false), /* @__PURE__ */ jsxDEV(Handle, {
247
- className: "!h-2 !w-2 !-right-1 !border-border !bg-muted-foreground/70",
248
- id: column.name,
249
- isConnectable: false,
250
- position: Position.Right,
251
- type: "source"
252
- }, void 0, false)]
253
- }, column.name, true));
254
- $[11] = data.columns;
255
- $[12] = data.label;
256
- $[13] = emptyPlaceholder;
257
- $[14] = t6;
258
- } else {
259
- t6 = $[14];
260
- }
261
- let t7;
262
- if ($[15] !== t6) {
263
- t7 = /* @__PURE__ */ jsxDEV(BaseNodeContent, {
264
- children: t6
265
- }, void 0, false);
266
- $[15] = t6;
267
- $[16] = t7;
268
- } else {
269
- t7 = $[16];
270
- }
271
- let t8;
272
- if ($[17] !== selected || $[18] !== t2 || $[19] !== t5 || $[20] !== t7) {
273
- t8 = /* @__PURE__ */ jsxDEV(BaseNode, {
274
- className: "w-64 overflow-hidden",
275
- "data-testid": t2,
276
- selected,
277
- children: [t5, t7]
278
- }, void 0, true);
279
- $[17] = selected;
280
- $[18] = t2;
281
- $[19] = t5;
282
- $[20] = t7;
283
- $[21] = t8;
284
- } else {
285
- t8 = $[21];
286
- }
287
- return t8;
288
- };
289
-
290
- const IMAGE_WIDTH = 1920;
291
- const IMAGE_HEIGHT = 1080;
292
- const IMAGE_PADDING = 32;
293
- const triggerDownload = (href, filename) => {
294
- const link = globalThis.document.createElement("a");
295
- link.href = href;
296
- link.download = filename;
297
- globalThis.document.body.append(link);
298
- link.click();
299
- link.remove();
300
- };
301
- const exportDiagramAsJson = (nodes, edges, filename = "schema-diagram.json") => {
302
- const payload = {
303
- edges,
304
- exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
305
- nodes
306
- };
307
- const json = JSON.stringify(payload, void 0, 2);
308
- const url = globalThis.URL.createObjectURL(new globalThis.Blob([json], {
309
- type: "application/json"
310
- }));
311
- triggerDownload(url, filename);
312
- globalThis.setTimeout(() => {
313
- globalThis.URL.revokeObjectURL(url);
314
- }, 0);
315
- };
316
- const viewportForExport = (nodes, width, height, padding) => {
317
- const bounds = getNodesBounds(nodes);
318
- const {
319
- x,
320
- y,
321
- zoom
322
- } = getViewportForBounds(bounds, width, height, 0.1, 2, padding);
323
- return {
324
- transform: [x, y, zoom],
325
- zoom
326
- };
327
- };
328
- const exportDiagramAsPng = async (viewportElement, nodes, filename = "schema-diagram.png") => {
329
- const {
330
- transform
331
- } = viewportForExport(nodes, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_PADDING);
332
- const [tx, ty, scale] = transform;
333
- const blob = await toBlob(viewportElement, {
334
- backgroundColor: "#ffffff",
335
- height: IMAGE_HEIGHT,
336
- style: {
337
- transform: `translate(${tx.toString()}px, ${ty.toString()}px) scale(${scale.toString()})`,
338
- transformOrigin: "top left",
339
- width: `${IMAGE_WIDTH.toString()}px`
340
- },
341
- width: IMAGE_WIDTH
342
- });
343
- if (blob === null) {
344
- throw new LunoraError("INTERNAL", "html-to-image produced no blob");
345
- }
346
- const url = globalThis.URL.createObjectURL(blob);
347
- triggerDownload(url, filename);
348
- globalThis.setTimeout(() => {
349
- globalThis.URL.revokeObjectURL(url);
350
- }, 0);
351
- };
352
- const exportDiagramAsSvg = async (viewportElement, nodes, filename = "schema-diagram.svg") => {
353
- const {
354
- transform
355
- } = viewportForExport(nodes, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_PADDING);
356
- const [tx, ty, scale] = transform;
357
- const svgDataUrl = await toSvg(viewportElement, {
358
- backgroundColor: "#ffffff",
359
- height: IMAGE_HEIGHT,
360
- style: {
361
- transform: `translate(${tx.toString()}px, ${ty.toString()}px) scale(${scale.toString()})`,
362
- transformOrigin: "top left",
363
- width: `${IMAGE_WIDTH.toString()}px`
364
- },
365
- width: IMAGE_WIDTH
366
- });
367
- triggerDownload(svgDataUrl, filename);
368
- };
369
-
370
- const NODE_WIDTH = 256;
371
- const COLUMN_GAP = 112;
372
- const ROW_GAP = 36;
373
- const PADDING = 24;
374
- const HEADER_HEIGHT = 38;
375
- const ROW_HEIGHT = 28;
376
- const nodeHeight = (columnCount) => HEADER_HEIGHT + Math.max(1, columnCount) * ROW_HEIGHT;
377
- const computeDepths = (tables, edges) => {
378
- const targetsOf = /* @__PURE__ */ new Map();
379
- for (const table of tables) {
380
- targetsOf.set(table, []);
381
- }
382
- for (const edge of edges) {
383
- if (edge.to !== edge.from && targetsOf.has(edge.from) && targetsOf.has(edge.to)) {
384
- targetsOf.get(edge.from)?.push(edge.to);
385
- }
386
- }
387
- const depth = /* @__PURE__ */ new Map();
388
- const visiting = /* @__PURE__ */ new Set();
389
- const resolve = (table) => {
390
- const cached = depth.get(table);
391
- if (cached !== void 0) {
392
- return cached;
393
- }
394
- if (visiting.has(table)) {
395
- return 0;
396
- }
397
- visiting.add(table);
398
- let deepest = 0;
399
- for (const target of targetsOf.get(table) ?? []) {
400
- deepest = Math.max(deepest, resolve(target) + 1);
401
- }
402
- visiting.delete(table);
403
- depth.set(table, deepest);
404
- return deepest;
405
- };
406
- for (const table of tables) {
407
- resolve(table);
408
- }
409
- return depth;
410
- };
411
- const computeLayout = (tables, edges, columnCounts) => {
412
- const depth = computeDepths(tables, edges);
413
- const offsetByColumn = /* @__PURE__ */ new Map();
414
- const nodes = [];
415
- for (const name of tables) {
416
- const column = depth.get(name) ?? 0;
417
- const y = offsetByColumn.get(column) ?? PADDING;
418
- nodes.push({
419
- name,
420
- x: PADDING + column * (NODE_WIDTH + COLUMN_GAP),
421
- y
422
- });
423
- offsetByColumn.set(column, y + nodeHeight(columnCounts.get(name) ?? 0) + ROW_GAP);
424
- }
425
- return nodes;
426
- };
427
-
428
- const NODE_TYPES = {
429
- databaseSchema: DatabaseSchemaNode
430
- };
431
- const SHARD_DOT_STYLE = {
432
- backgroundColor: TIER_META.shard.color
433
- };
434
- const GLOBAL_DOT_STYLE = {
435
- backgroundColor: TIER_META.global.color
436
- };
437
- const ALL_TIERS = {
438
- global: true,
439
- shard: true
440
- };
441
- const pkColumnOf = (columns) => {
442
- const flagged = columns.find((column) => column.pk === true)?.name;
443
- if (flagged !== void 0) {
444
- return flagged;
445
- }
446
- if (columns.some((column) => column.name === "_id")) {
447
- return "_id";
448
- }
449
- if (columns.some((column) => column.name === "id")) {
450
- return "id";
451
- }
452
- return columns[0]?.name ?? "_id";
453
- };
454
- const deriveEdges = (tables) => tables.flatMap((table) => table.columns.filter((column) => column.ref !== void 0).map((column) => {
455
- return {
456
- column: column.name,
457
- from: table.name,
458
- to: column.ref
459
- };
460
- }));
461
- const buildNodes = (tables, columnsError) => {
462
- const names = tables.map((table) => table.name);
463
- const counts = new Map(tables.map((table) => [table.name, table.columns.length]));
464
- const positions = computeLayout(names, deriveEdges(tables), counts);
465
- const byName = new Map(tables.map((table) => [table.name, table]));
466
- return positions.flatMap(({
467
- name,
468
- x,
469
- y
470
- }) => {
471
- const table = byName.get(name);
472
- if (table === void 0) {
473
- return [];
474
- }
475
- return [{
476
- data: {
477
- columns: table.columns,
478
- label: name,
479
- loadError: columnsError,
480
- tier: table.tier
481
- },
482
- id: name,
483
- position: {
484
- x,
485
- y
486
- },
487
- type: "databaseSchema"
488
- }];
489
- });
490
- };
491
- const buildEdges = (tables) => {
492
- const columnsByTable = new Map(tables.map((table) => [table.name, table.columns]));
493
- return deriveEdges(tables).flatMap((edge) => {
494
- const targetColumns = columnsByTable.get(edge.to) ?? [];
495
- const sourceColumns = columnsByTable.get(edge.from) ?? [];
496
- const pk = pkColumnOf(targetColumns);
497
- if (!targetColumns.some((column) => column.name === pk) || !sourceColumns.some((column) => column.name === edge.column)) {
498
- return [];
499
- }
500
- return [{
501
- id: `${edge.from}.${edge.column}->${edge.to}`,
502
- source: edge.to,
503
- sourceHandle: pk,
504
- target: edge.from,
505
- targetHandle: edge.column
506
- }];
507
- });
508
- };
509
- const Legend = () => {
510
- const $ = c(15);
511
- const t = useT();
512
- let t0;
513
- if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
514
- t0 = /* @__PURE__ */ jsxDEV("span", {
515
- className: "flex items-center gap-1",
516
- children: [/* @__PURE__ */ jsxDEV("span", {
517
- "aria-hidden": "true",
518
- className: "size-1.5 rounded-full",
519
- style: SHARD_DOT_STYLE
520
- }, void 0, false), TIER_META.shard.label]
521
- }, void 0, true);
522
- $[0] = t0;
523
- } else {
524
- t0 = $[0];
525
- }
526
- let t1;
527
- if ($[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
528
- t1 = /* @__PURE__ */ jsxDEV("span", {
529
- className: "flex items-center gap-1",
530
- children: [/* @__PURE__ */ jsxDEV("span", {
531
- "aria-hidden": "true",
532
- className: "size-1.5 rounded-full",
533
- style: GLOBAL_DOT_STYLE
534
- }, void 0, false), TIER_META.global.label]
535
- }, void 0, true);
536
- $[1] = t1;
537
- } else {
538
- t1 = $[1];
539
- }
540
- let t2;
541
- if ($[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
542
- t2 = /* @__PURE__ */ jsxDEV(Badge, {
543
- className: "px-1 py-0 text-[10px] leading-tight",
544
- variant: "secondary",
545
- children: "PK"
546
- }, void 0, false);
547
- $[2] = t2;
548
- } else {
549
- t2 = $[2];
550
- }
551
- let t3;
552
- if ($[3] !== t) {
553
- t3 = t("Primary key");
554
- $[3] = t;
555
- $[4] = t3;
556
- } else {
557
- t3 = $[4];
558
- }
559
- let t4;
560
- if ($[5] !== t3) {
561
- t4 = /* @__PURE__ */ jsxDEV("span", {
562
- className: "flex items-center gap-1",
563
- children: [t2, t3]
564
- }, void 0, true);
565
- $[5] = t3;
566
- $[6] = t4;
567
- } else {
568
- t4 = $[6];
569
- }
570
- let t5;
571
- if ($[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
572
- t5 = /* @__PURE__ */ jsxDEV(Badge, {
573
- className: "px-1 py-0 text-[10px] leading-tight",
574
- variant: "outline",
575
- children: "FK"
576
- }, void 0, false);
577
- $[7] = t5;
578
- } else {
579
- t5 = $[7];
580
- }
581
- let t6;
582
- if ($[8] !== t) {
583
- t6 = t("Foreign key");
584
- $[8] = t;
585
- $[9] = t6;
586
- } else {
587
- t6 = $[9];
588
- }
589
- let t7;
590
- if ($[10] !== t6) {
591
- t7 = /* @__PURE__ */ jsxDEV("span", {
592
- className: "flex items-center gap-1",
593
- children: [t5, t6]
594
- }, void 0, true);
595
- $[10] = t6;
596
- $[11] = t7;
597
- } else {
598
- t7 = $[11];
599
- }
600
- let t8;
601
- if ($[12] !== t4 || $[13] !== t7) {
602
- t8 = /* @__PURE__ */ jsxDEV("div", {
603
- className: "flex flex-wrap items-center gap-x-3 gap-y-1 rounded-xl border border-border bg-card/95 px-2.5 py-1.5 text-[11px] text-muted-foreground shadow-xs",
604
- children: [t0, t1, t4, t7]
605
- }, void 0, true);
606
- $[12] = t4;
607
- $[13] = t7;
608
- $[14] = t8;
609
- } else {
610
- t8 = $[14];
611
- }
612
- return t8;
613
- };
614
- const DiagramExportPanel = ({
615
- containerRef,
616
- testIdPrefix
617
- }) => {
618
- const t = useT();
619
- const nodes = useNodes();
620
- const {
621
- getEdges
622
- } = useReactFlow();
623
- const [exporting, setExporting] = useState(null);
624
- const handlePng = async () => {
625
- const viewport = containerRef.current?.querySelector(".react-flow__viewport");
626
- if (!viewport) {
627
- return;
628
- }
629
- setExporting("png");
630
- try {
631
- await exportDiagramAsPng(viewport, nodes, `${testIdPrefix}-schema-diagram.png`);
632
- } finally {
633
- setExporting(null);
634
- }
635
- };
636
- const handleSvg = async () => {
637
- const viewport_0 = containerRef.current?.querySelector(".react-flow__viewport");
638
- if (!viewport_0) {
639
- return;
640
- }
641
- setExporting("svg");
642
- try {
643
- await exportDiagramAsSvg(viewport_0, nodes, `${testIdPrefix}-schema-diagram.svg`);
644
- } finally {
645
- setExporting(null);
646
- }
647
- };
648
- const handleJson = () => {
649
- setExporting("json");
650
- try {
651
- exportDiagramAsJson(nodes, getEdges(), `${testIdPrefix}-schema-diagram.json`);
652
- } finally {
653
- setExporting(null);
654
- }
655
- };
656
- const onClickPng = () => {
657
- fireAndForget(handlePng());
658
- };
659
- const onClickSvg = () => {
660
- fireAndForget(handleSvg());
661
- };
662
- return /* @__PURE__ */ jsxDEV(Panel, {
663
- position: "top-right",
664
- children: /* @__PURE__ */ jsxDEV(DropdownMenu, {
665
- children: [/* @__PURE__ */ jsxDEV(DropdownMenuTrigger, {
666
- className: "group/button inline-flex shrink-0 cursor-pointer items-center justify-center gap-1 rounded-md border border-border bg-background px-2 text-xs font-medium whitespace-nowrap hover:bg-muted disabled:pointer-events-none disabled:opacity-50",
667
- "data-testid": `${testIdPrefix}-export-trigger`,
668
- disabled: exporting !== null,
669
- children: [/* @__PURE__ */ jsxDEV(HugeiconsIcon, {
670
- className: "size-3.5",
671
- icon: Download01Icon,
672
- strokeWidth: 2
673
- }, void 0, false), t("Export")]
674
- }, void 0, true), /* @__PURE__ */ jsxDEV(DropdownMenuContent, {
675
- align: "end",
676
- children: [/* @__PURE__ */ jsxDEV(DropdownMenuItem, {
677
- "data-testid": `${testIdPrefix}-export-png`,
678
- disabled: exporting !== null,
679
- onClick: onClickPng,
680
- children: t("PNG")
681
- }, void 0, false), /* @__PURE__ */ jsxDEV(DropdownMenuItem, {
682
- "data-testid": `${testIdPrefix}-export-svg`,
683
- disabled: exporting !== null,
684
- onClick: onClickSvg,
685
- children: t("SVG")
686
- }, void 0, false), /* @__PURE__ */ jsxDEV(DropdownMenuItem, {
687
- "data-testid": `${testIdPrefix}-export-json`,
688
- disabled: exporting !== null,
689
- onClick: handleJson,
690
- children: t("JSON")
691
- }, void 0, false)]
692
- }, void 0, true)]
693
- }, void 0, true)
694
- }, void 0, false);
695
- };
696
- const SchemaDiagram = (t0) => {
697
- const $ = c(75);
698
- const {
699
- columnsError,
700
- tables,
701
- testIdPrefix
702
- } = t0;
703
- const t = useT();
704
- const [tierFilter, setTierFilter] = useState(ALL_TIERS);
705
- const [query, setQuery] = useState("");
706
- let t1;
707
- if ($[0] !== query || $[1] !== tables || $[2] !== tierFilter) {
708
- const needle = query.trim().toLowerCase();
709
- t1 = tables.filter((table) => tierFilter[table.tier] && table.name.toLowerCase().includes(needle));
710
- $[0] = query;
711
- $[1] = tables;
712
- $[2] = tierFilter;
713
- $[3] = t1;
714
- } else {
715
- t1 = $[3];
716
- }
717
- const visibleTables = t1;
718
- const t2 = columnsError ?? false;
719
- let t3;
720
- if ($[4] !== t2 || $[5] !== visibleTables) {
721
- t3 = buildNodes(visibleTables, t2);
722
- $[4] = t2;
723
- $[5] = visibleTables;
724
- $[6] = t3;
725
- } else {
726
- t3 = $[6];
727
- }
728
- const seededNodes = t3;
729
- let t4;
730
- if ($[7] !== visibleTables) {
731
- t4 = buildEdges(visibleTables);
732
- $[7] = visibleTables;
733
- $[8] = t4;
734
- } else {
735
- t4 = $[8];
736
- }
737
- const seededEdges = t4;
738
- const [nodes, setNodes, onNodesChange] = useNodesState(seededNodes);
739
- const [flowEdges, setEdges, onEdgesChange] = useEdgesState(seededEdges);
740
- const canvasRef = useRef(null);
741
- let t5;
742
- let t6;
743
- if ($[9] !== seededNodes || $[10] !== setNodes) {
744
- t5 = () => {
745
- setNodes(seededNodes);
746
- };
747
- t6 = [seededNodes, setNodes];
748
- $[9] = seededNodes;
749
- $[10] = setNodes;
750
- $[11] = t5;
751
- $[12] = t6;
752
- } else {
753
- t5 = $[11];
754
- t6 = $[12];
755
- }
756
- useEffect(t5, t6);
757
- let t7;
758
- let t8;
759
- if ($[13] !== seededEdges || $[14] !== setEdges) {
760
- t7 = () => {
761
- setEdges(seededEdges);
762
- };
763
- t8 = [seededEdges, setEdges];
764
- $[13] = seededEdges;
765
- $[14] = setEdges;
766
- $[15] = t7;
767
- $[16] = t8;
768
- } else {
769
- t7 = $[15];
770
- t8 = $[16];
771
- }
772
- useEffect(t7, t8);
773
- let t9;
774
- if ($[17] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
775
- t9 = (event) => {
776
- setQuery(event.target.value);
777
- };
778
- $[17] = t9;
779
- } else {
780
- t9 = $[17];
781
- }
782
- const onQueryChange = t9;
783
- let t10;
784
- if ($[18] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
785
- t10 = () => {
786
- setTierFilter(_temp$1);
787
- };
788
- $[18] = t10;
789
- } else {
790
- t10 = $[18];
791
- }
792
- const toggleShard = t10;
793
- let t11;
794
- if ($[19] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
795
- t11 = () => {
796
- setTierFilter(_temp2$1);
797
- };
798
- $[19] = t11;
799
- } else {
800
- t11 = $[19];
801
- }
802
- const toggleGlobal = t11;
803
- if (tables.length === 0) {
804
- const t122 = `${testIdPrefix}-section`;
805
- const t132 = `${testIdPrefix}-empty`;
806
- let t142;
807
- if ($[20] !== t) {
808
- t142 = t("No tables to graph.");
809
- $[20] = t;
810
- $[21] = t142;
811
- } else {
812
- t142 = $[21];
813
- }
814
- let t152;
815
- if ($[22] !== t132 || $[23] !== t142) {
816
- t152 = /* @__PURE__ */ jsxDEV("p", {
817
- className: "text-sm text-muted-foreground",
818
- "data-testid": t132,
819
- children: t142
820
- }, void 0, false);
821
- $[22] = t132;
822
- $[23] = t142;
823
- $[24] = t152;
824
- } else {
825
- t152 = $[24];
826
- }
827
- let t162;
828
- if ($[25] !== t122 || $[26] !== t152) {
829
- t162 = /* @__PURE__ */ jsxDEV("section", {
830
- className: "flex flex-col gap-2",
831
- "data-testid": t122,
832
- children: t152
833
- }, void 0, false);
834
- $[25] = t122;
835
- $[26] = t152;
836
- $[27] = t162;
837
- } else {
838
- t162 = $[27];
839
- }
840
- return t162;
841
- }
842
- const t12 = `${testIdPrefix}-section`;
843
- const t13 = `${testIdPrefix}-canvas`;
844
- let t14;
845
- if ($[28] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
846
- t14 = /* @__PURE__ */ jsxDEV(Background, {}, void 0, false);
847
- $[28] = t14;
848
- } else {
849
- t14 = $[28];
850
- }
851
- let t15;
852
- if ($[29] !== t) {
853
- t15 = t("Find table…");
854
- $[29] = t;
855
- $[30] = t15;
856
- } else {
857
- t15 = $[30];
858
- }
859
- const t16 = `${testIdPrefix}-find`;
860
- let t17;
861
- if ($[31] !== t) {
862
- t17 = t("Find table…");
863
- $[31] = t;
864
- $[32] = t17;
865
- } else {
866
- t17 = $[32];
867
- }
868
- let t18;
869
- if ($[33] !== query || $[34] !== t15 || $[35] !== t16 || $[36] !== t17) {
870
- t18 = /* @__PURE__ */ jsxDEV(Input, {
871
- "aria-label": t15,
872
- className: "h-7 w-44 text-xs",
873
- "data-testid": t16,
874
- onChange: onQueryChange,
875
- placeholder: t17,
876
- value: query
877
- }, void 0, false);
878
- $[33] = query;
879
- $[34] = t15;
880
- $[35] = t16;
881
- $[36] = t17;
882
- $[37] = t18;
883
- } else {
884
- t18 = $[37];
885
- }
886
- let t19;
887
- if ($[38] !== t) {
888
- t19 = t("Storage tiers");
889
- $[38] = t;
890
- $[39] = t19;
891
- } else {
892
- t19 = $[39];
893
- }
894
- const t20 = `${testIdPrefix}-tier-shard`;
895
- const t21 = tierFilter.shard ? "default" : "outline";
896
- let t22;
897
- if ($[40] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
898
- t22 = /* @__PURE__ */ jsxDEV("span", {
899
- "aria-hidden": "true",
900
- className: "size-1.5 rounded-full",
901
- style: SHARD_DOT_STYLE
902
- }, void 0, false);
903
- $[40] = t22;
904
- } else {
905
- t22 = $[40];
906
- }
907
- let t23;
908
- if ($[41] !== t20 || $[42] !== t21 || $[43] !== tierFilter.shard) {
909
- t23 = /* @__PURE__ */ jsxDEV(Button, {
910
- "aria-pressed": tierFilter.shard,
911
- className: "gap-1.5",
912
- "data-testid": t20,
913
- onClick: toggleShard,
914
- size: "xs",
915
- type: "button",
916
- variant: t21,
917
- children: [t22, TIER_META.shard.label]
918
- }, void 0, true);
919
- $[41] = t20;
920
- $[42] = t21;
921
- $[43] = tierFilter.shard;
922
- $[44] = t23;
923
- } else {
924
- t23 = $[44];
925
- }
926
- const t24 = `${testIdPrefix}-tier-global`;
927
- const t25 = tierFilter.global ? "default" : "outline";
928
- let t26;
929
- if ($[45] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
930
- t26 = /* @__PURE__ */ jsxDEV("span", {
931
- "aria-hidden": "true",
932
- className: "size-1.5 rounded-full",
933
- style: GLOBAL_DOT_STYLE
934
- }, void 0, false);
935
- $[45] = t26;
936
- } else {
937
- t26 = $[45];
938
- }
939
- let t27;
940
- if ($[46] !== t24 || $[47] !== t25 || $[48] !== tierFilter.global) {
941
- t27 = /* @__PURE__ */ jsxDEV(Button, {
942
- "aria-pressed": tierFilter.global,
943
- className: "gap-1.5",
944
- "data-testid": t24,
945
- onClick: toggleGlobal,
946
- size: "xs",
947
- type: "button",
948
- variant: t25,
949
- children: [t26, TIER_META.global.label]
950
- }, void 0, true);
951
- $[46] = t24;
952
- $[47] = t25;
953
- $[48] = tierFilter.global;
954
- $[49] = t27;
955
- } else {
956
- t27 = $[49];
957
- }
958
- let t28;
959
- if ($[50] !== t19 || $[51] !== t23 || $[52] !== t27) {
960
- t28 = /* @__PURE__ */ jsxDEV("div", {
961
- "aria-label": t19,
962
- className: "flex items-center gap-1.5",
963
- role: "group",
964
- children: [t23, t27]
965
- }, void 0, true);
966
- $[50] = t19;
967
- $[51] = t23;
968
- $[52] = t27;
969
- $[53] = t28;
970
- } else {
971
- t28 = $[53];
972
- }
973
- let t29;
974
- if ($[54] !== t18 || $[55] !== t28) {
975
- t29 = /* @__PURE__ */ jsxDEV(Panel, {
976
- position: "top-left",
977
- children: /* @__PURE__ */ jsxDEV("div", {
978
- className: "flex flex-col gap-2 rounded-xl border border-border bg-card/95 p-2 shadow-xs",
979
- children: [t18, t28]
980
- }, void 0, true)
981
- }, void 0, false);
982
- $[54] = t18;
983
- $[55] = t28;
984
- $[56] = t29;
985
- } else {
986
- t29 = $[56];
987
- }
988
- let t30;
989
- let t31;
990
- let t32;
991
- if ($[57] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
992
- t30 = /* @__PURE__ */ jsxDEV(Panel, {
993
- position: "bottom-left",
994
- children: /* @__PURE__ */ jsxDEV(Legend, {}, void 0, false)
995
- }, void 0, false);
996
- t31 = /* @__PURE__ */ jsxDEV(Controls, {
997
- showInteractive: false
998
- }, void 0, false);
999
- t32 = /* @__PURE__ */ jsxDEV(MiniMap, {
1000
- pannable: true,
1001
- zoomable: true
1002
- }, void 0, false);
1003
- $[57] = t30;
1004
- $[58] = t31;
1005
- $[59] = t32;
1006
- } else {
1007
- t30 = $[57];
1008
- t31 = $[58];
1009
- t32 = $[59];
1010
- }
1011
- let t33;
1012
- if ($[60] !== testIdPrefix) {
1013
- t33 = /* @__PURE__ */ jsxDEV(DiagramExportPanel, {
1014
- containerRef: canvasRef,
1015
- testIdPrefix
1016
- }, void 0, false);
1017
- $[60] = testIdPrefix;
1018
- $[61] = t33;
1019
- } else {
1020
- t33 = $[61];
1021
- }
1022
- let t34;
1023
- if ($[62] !== flowEdges || $[63] !== nodes || $[64] !== onEdgesChange || $[65] !== onNodesChange || $[66] !== t29 || $[67] !== t33) {
1024
- t34 = /* @__PURE__ */ jsxDEV(ReactFlow, {
1025
- edges: flowEdges,
1026
- elementsSelectable: true,
1027
- fitView: true,
1028
- minZoom: 0.2,
1029
- nodes,
1030
- nodesConnectable: false,
1031
- nodeTypes: NODE_TYPES,
1032
- onEdgesChange,
1033
- onNodesChange,
1034
- children: [t14, t29, t30, t31, t32, t33]
1035
- }, void 0, true);
1036
- $[62] = flowEdges;
1037
- $[63] = nodes;
1038
- $[64] = onEdgesChange;
1039
- $[65] = onNodesChange;
1040
- $[66] = t29;
1041
- $[67] = t33;
1042
- $[68] = t34;
1043
- } else {
1044
- t34 = $[68];
1045
- }
1046
- let t35;
1047
- if ($[69] !== t13 || $[70] !== t34) {
1048
- t35 = /* @__PURE__ */ jsxDEV("div", {
1049
- className: "h-[560px] w-full overflow-hidden rounded-xl border border-border bg-muted/20 shadow-xs",
1050
- "data-testid": t13,
1051
- ref: canvasRef,
1052
- children: t34
1053
- }, void 0, false);
1054
- $[69] = t13;
1055
- $[70] = t34;
1056
- $[71] = t35;
1057
- } else {
1058
- t35 = $[71];
1059
- }
1060
- let t36;
1061
- if ($[72] !== t12 || $[73] !== t35) {
1062
- t36 = /* @__PURE__ */ jsxDEV("section", {
1063
- className: "flex flex-col gap-2",
1064
- "data-testid": t12,
1065
- children: t35
1066
- }, void 0, false);
1067
- $[72] = t12;
1068
- $[73] = t35;
1069
- $[74] = t36;
1070
- } else {
1071
- t36 = $[74];
1072
- }
1073
- return t36;
1074
- };
1075
- function _temp$1(previous) {
1076
- return {
1077
- ...previous,
1078
- shard: !previous.shard
1079
- };
1080
- }
1081
- function _temp2$1(previous_0) {
1082
- return {
1083
- ...previous_0,
1084
- global: !previous_0.global
1085
- };
1086
- }
1087
-
1088
- const SCHEMA_EDIT_ENDPOINT = "/__lunora/schema-edit";
1089
- const applyEdit = async (edit) => {
1090
- const response = await fetch(SCHEMA_EDIT_ENDPOINT, {
1091
- body: JSON.stringify(edit),
1092
- // `Content-Type: application/json` is non-simple and forces a CORS preflight
1093
- // for cross-origin fetches, preventing CSRF via the browser's same-origin
1094
- // policy. `X-Lunora-Studio` is an additional custom header that also triggers
1095
- // a preflight and lets the server-side guard identify studio traffic; both
1096
- // headers are checked by the `@lunora/config` `csrfRejectionReason` guard.
1097
- headers: {
1098
- "Content-Type": "application/json",
1099
- "X-Lunora-Studio": "1"
1100
- },
1101
- method: "POST"
1102
- });
1103
- const body = await response.json();
1104
- if (body.needsMigration === true) {
1105
- return {
1106
- kind: "needs-migration",
1107
- message: body.message ?? "This edit needs a migration."
1108
- };
1109
- }
1110
- if (response.ok && body.tables !== void 0) {
1111
- return {
1112
- diagnostics: body.diagnostics ?? [],
1113
- kind: "ok",
1114
- tables: body.tables
1115
- };
1116
- }
1117
- return {
1118
- kind: "error",
1119
- message: body.error ?? `schema edit failed (${String(response.status)})`
1120
- };
1121
- };
1122
-
1123
- const COLUMN_TYPES = [{
1124
- label: "string",
1125
- validator: "v.string()"
1126
- }, {
1127
- label: "number",
1128
- validator: "v.number()"
1129
- }, {
1130
- label: "boolean",
1131
- validator: "v.boolean()"
1132
- }, {
1133
- label: "bigint",
1134
- validator: "v.int64()"
1135
- }, {
1136
- label: "bytes",
1137
- validator: "v.bytes()"
1138
- }, {
1139
- label: "any",
1140
- validator: "v.any()"
1141
- }];
1142
- const DEFAULT_VALIDATOR = "v.string()";
1143
- const splitFields = (raw) => raw.split(",").map((field) => field.trim()).filter((field) => field !== "");
1144
- const SchemaEditorOverlay = ({
1145
- onApplied,
1146
- tableNames
1147
- }) => {
1148
- const t = useT();
1149
- const navigate = useNavigate();
1150
- const [mode, setMode] = useState(null);
1151
- const [busy, setBusy] = useState(false);
1152
- const [result, setResult] = useState(null);
1153
- const [tableName, setTableName] = useState("");
1154
- const [columnName, setColumnName] = useState("");
1155
- const [validator, setValidator] = useState(DEFAULT_VALIDATOR);
1156
- const [targetTable, setTargetTable] = useState(tableNames[0] ?? "");
1157
- const [indexName, setIndexName] = useState("");
1158
- const [indexFields, setIndexFields] = useState("");
1159
- const [unique, setUnique] = useState(false);
1160
- const reset = () => {
1161
- setMode(null);
1162
- setTableName("");
1163
- setColumnName("");
1164
- setIndexName("");
1165
- setIndexFields("");
1166
- setUnique(false);
1167
- };
1168
- const submit = async (edit) => {
1169
- setBusy(true);
1170
- setResult(null);
1171
- try {
1172
- const outcome = await applyEdit(edit);
1173
- setResult(outcome);
1174
- if (outcome.kind === "ok") {
1175
- onApplied(outcome.tables);
1176
- reset();
1177
- }
1178
- } catch (error) {
1179
- setResult({
1180
- kind: "error",
1181
- message: error instanceof Error ? error.message : String(error)
1182
- });
1183
- } finally {
1184
- setBusy(false);
1185
- }
1186
- };
1187
- const onSubmitTable = () => {
1188
- fireAndForget(submit({
1189
- kind: "addTable",
1190
- table: tableName.trim()
1191
- }));
1192
- };
1193
- const onSubmitColumn = () => {
1194
- fireAndForget(submit({
1195
- column: columnName.trim(),
1196
- kind: "addOptionalColumn",
1197
- table: targetTable,
1198
- validator
1199
- }));
1200
- };
1201
- const onSubmitIndex = () => {
1202
- fireAndForget(submit({
1203
- fields: splitFields(indexFields),
1204
- kind: "addIndex",
1205
- name: indexName.trim(),
1206
- table: targetTable,
1207
- unique
1208
- }));
1209
- };
1210
- const openTable = () => {
1211
- setResult(null);
1212
- setMode("addTable");
1213
- };
1214
- const openColumn = () => {
1215
- setResult(null);
1216
- setMode("addColumn");
1217
- };
1218
- const openIndex = () => {
1219
- setResult(null);
1220
- setMode("addIndex");
1221
- };
1222
- const openDestructive = () => {
1223
- setMode("destructive");
1224
- setResult({
1225
- kind: "needs-migration",
1226
- message: t("This edit changes stored data and must go through a migration. Review the migration before applying.")
1227
- });
1228
- };
1229
- const onTableNameChange = (event) => {
1230
- setTableName(event.target.value);
1231
- };
1232
- const onColumnNameChange = (event_0) => {
1233
- setColumnName(event_0.target.value);
1234
- };
1235
- const onValidatorChange = (event_1) => {
1236
- setValidator(event_1.target.value);
1237
- };
1238
- const onTargetTableChange = (event_2) => {
1239
- setTargetTable(event_2.target.value);
1240
- };
1241
- const onIndexNameChange = (event_3) => {
1242
- setIndexName(event_3.target.value);
1243
- };
1244
- const onIndexFieldsChange = (event_4) => {
1245
- setIndexFields(event_4.target.value);
1246
- };
1247
- const onUniqueChange = (event_5) => {
1248
- setUnique(event_5.target.checked);
1249
- };
1250
- const onOpenMigrations = () => {
1251
- fireAndForget(navigate({
1252
- to: "/migrations"
1253
- }));
1254
- };
1255
- return /* @__PURE__ */ jsxDEV(Card, {
1256
- "data-testid": "sc-editor",
1257
- size: "sm",
1258
- children: [/* @__PURE__ */ jsxDEV(CardHeader, {
1259
- children: [/* @__PURE__ */ jsxDEV(CardTitle, {
1260
- children: t("Edit schema")
1261
- }, void 0, false), /* @__PURE__ */ jsxDEV(CardDescription, {
1262
- children: t("Adds a table, column, or index to lunora/schema.ts and reruns codegen.")
1263
- }, void 0, false)]
1264
- }, void 0, true), /* @__PURE__ */ jsxDEV(CardContent, {
1265
- children: [/* @__PURE__ */ jsxDEV("div", {
1266
- className: "flex flex-wrap gap-2",
1267
- children: [/* @__PURE__ */ jsxDEV(Button, {
1268
- "data-testid": "sc-editor-add-table",
1269
- onClick: openTable,
1270
- size: "xs",
1271
- type: "button",
1272
- variant: mode === "addTable" ? "default" : "outline",
1273
- children: t("Add table")
1274
- }, void 0, false), /* @__PURE__ */ jsxDEV(Button, {
1275
- "data-testid": "sc-editor-add-column",
1276
- disabled: tableNames.length === 0,
1277
- onClick: openColumn,
1278
- size: "xs",
1279
- type: "button",
1280
- variant: mode === "addColumn" ? "default" : "outline",
1281
- children: t("Add column")
1282
- }, void 0, false), /* @__PURE__ */ jsxDEV(Button, {
1283
- "data-testid": "sc-editor-add-index",
1284
- disabled: tableNames.length === 0,
1285
- onClick: openIndex,
1286
- size: "xs",
1287
- type: "button",
1288
- variant: mode === "addIndex" ? "default" : "outline",
1289
- children: t("Add index")
1290
- }, void 0, false), /* @__PURE__ */ jsxDEV(Button, {
1291
- "data-testid": "sc-editor-destructive",
1292
- disabled: tableNames.length === 0,
1293
- onClick: openDestructive,
1294
- size: "xs",
1295
- type: "button",
1296
- variant: mode === "destructive" ? "default" : "ghost",
1297
- children: t("Rename / drop / change type…")
1298
- }, void 0, false)]
1299
- }, void 0, true), mode === "addTable" && /* @__PURE__ */ jsxDEV("div", {
1300
- className: "mt-3 flex flex-wrap items-end gap-2",
1301
- "data-testid": "sc-editor-table-form",
1302
- children: [/* @__PURE__ */ jsxDEV("div", {
1303
- className: "flex flex-col gap-1 text-xs",
1304
- children: [/* @__PURE__ */ jsxDEV(Label, {
1305
- htmlFor: "sc-editor-table-name",
1306
- children: t("Table name")
1307
- }, void 0, false), /* @__PURE__ */ jsxDEV(Input, {
1308
- "data-testid": "sc-editor-table-name",
1309
- id: "sc-editor-table-name",
1310
- onChange: onTableNameChange,
1311
- value: tableName
1312
- }, void 0, false)]
1313
- }, void 0, true), /* @__PURE__ */ jsxDEV(Button, {
1314
- "data-testid": "sc-editor-table-apply",
1315
- disabled: busy || tableName.trim() === "",
1316
- onClick: onSubmitTable,
1317
- size: "xs",
1318
- type: "button",
1319
- children: busy ? t("Applying…") : t("Apply")
1320
- }, void 0, false), /* @__PURE__ */ jsxDEV(Button, {
1321
- onClick: reset,
1322
- size: "xs",
1323
- type: "button",
1324
- variant: "ghost",
1325
- children: t("Cancel")
1326
- }, void 0, false)]
1327
- }, void 0, true), mode === "addColumn" && /* @__PURE__ */ jsxDEV("div", {
1328
- className: "mt-3 flex flex-wrap items-end gap-2",
1329
- "data-testid": "sc-editor-column-form",
1330
- children: [/* @__PURE__ */ jsxDEV("div", {
1331
- className: "flex flex-col gap-1 text-xs",
1332
- children: [/* @__PURE__ */ jsxDEV(Label, {
1333
- htmlFor: "sc-editor-column-table",
1334
- children: t("Table name")
1335
- }, void 0, false), /* @__PURE__ */ jsxDEV("select", {
1336
- className: "h-8 rounded-md border border-input bg-transparent px-2 text-xs",
1337
- "data-testid": "sc-editor-column-table",
1338
- id: "sc-editor-column-table",
1339
- onChange: onTargetTableChange,
1340
- value: targetTable,
1341
- children: tableNames.map((name) => /* @__PURE__ */ jsxDEV("option", {
1342
- value: name,
1343
- children: name
1344
- }, name, false))
1345
- }, void 0, false)]
1346
- }, void 0, true), /* @__PURE__ */ jsxDEV("div", {
1347
- className: "flex flex-col gap-1 text-xs",
1348
- children: [/* @__PURE__ */ jsxDEV(Label, {
1349
- htmlFor: "sc-editor-column-name",
1350
- children: t("Column name")
1351
- }, void 0, false), /* @__PURE__ */ jsxDEV(Input, {
1352
- "data-testid": "sc-editor-column-name",
1353
- id: "sc-editor-column-name",
1354
- onChange: onColumnNameChange,
1355
- value: columnName
1356
- }, void 0, false)]
1357
- }, void 0, true), /* @__PURE__ */ jsxDEV("div", {
1358
- className: "flex flex-col gap-1 text-xs",
1359
- children: [/* @__PURE__ */ jsxDEV(Label, {
1360
- htmlFor: "sc-editor-column-type",
1361
- children: t("Column type")
1362
- }, void 0, false), /* @__PURE__ */ jsxDEV("select", {
1363
- className: "h-8 rounded-md border border-input bg-transparent px-2 text-xs",
1364
- "data-testid": "sc-editor-column-type",
1365
- id: "sc-editor-column-type",
1366
- onChange: onValidatorChange,
1367
- value: validator,
1368
- children: COLUMN_TYPES.map((type) => /* @__PURE__ */ jsxDEV("option", {
1369
- value: type.validator,
1370
- children: type.label
1371
- }, type.validator, false))
1372
- }, void 0, false)]
1373
- }, void 0, true), /* @__PURE__ */ jsxDEV("span", {
1374
- className: "text-[11px] text-muted-foreground",
1375
- children: t("Optional")
1376
- }, void 0, false), /* @__PURE__ */ jsxDEV(Button, {
1377
- "data-testid": "sc-editor-column-apply",
1378
- disabled: busy || columnName.trim() === "" || targetTable === "",
1379
- onClick: onSubmitColumn,
1380
- size: "xs",
1381
- type: "button",
1382
- children: busy ? t("Applying…") : t("Apply")
1383
- }, void 0, false), /* @__PURE__ */ jsxDEV(Button, {
1384
- onClick: reset,
1385
- size: "xs",
1386
- type: "button",
1387
- variant: "ghost",
1388
- children: t("Cancel")
1389
- }, void 0, false)]
1390
- }, void 0, true), mode === "addIndex" && /* @__PURE__ */ jsxDEV("div", {
1391
- className: "mt-3 flex flex-wrap items-end gap-2",
1392
- "data-testid": "sc-editor-index-form",
1393
- children: [/* @__PURE__ */ jsxDEV("div", {
1394
- className: "flex flex-col gap-1 text-xs",
1395
- children: [/* @__PURE__ */ jsxDEV(Label, {
1396
- htmlFor: "sc-editor-index-table",
1397
- children: t("Table name")
1398
- }, void 0, false), /* @__PURE__ */ jsxDEV("select", {
1399
- className: "h-8 rounded-md border border-input bg-transparent px-2 text-xs",
1400
- "data-testid": "sc-editor-index-table",
1401
- id: "sc-editor-index-table",
1402
- onChange: onTargetTableChange,
1403
- value: targetTable,
1404
- children: tableNames.map((name_0) => /* @__PURE__ */ jsxDEV("option", {
1405
- value: name_0,
1406
- children: name_0
1407
- }, name_0, false))
1408
- }, void 0, false)]
1409
- }, void 0, true), /* @__PURE__ */ jsxDEV("div", {
1410
- className: "flex flex-col gap-1 text-xs",
1411
- children: [/* @__PURE__ */ jsxDEV(Label, {
1412
- htmlFor: "sc-editor-index-name",
1413
- children: t("Index name")
1414
- }, void 0, false), /* @__PURE__ */ jsxDEV(Input, {
1415
- "data-testid": "sc-editor-index-name",
1416
- id: "sc-editor-index-name",
1417
- onChange: onIndexNameChange,
1418
- value: indexName
1419
- }, void 0, false)]
1420
- }, void 0, true), /* @__PURE__ */ jsxDEV("div", {
1421
- className: "flex flex-col gap-1 text-xs",
1422
- children: [/* @__PURE__ */ jsxDEV(Label, {
1423
- htmlFor: "sc-editor-index-fields",
1424
- children: t("Index fields (comma-separated)")
1425
- }, void 0, false), /* @__PURE__ */ jsxDEV(Input, {
1426
- "data-testid": "sc-editor-index-fields",
1427
- id: "sc-editor-index-fields",
1428
- onChange: onIndexFieldsChange,
1429
- value: indexFields
1430
- }, void 0, false)]
1431
- }, void 0, true), /* @__PURE__ */ jsxDEV(Label, {
1432
- className: "flex items-center gap-1 text-xs",
1433
- htmlFor: "sc-editor-index-unique",
1434
- children: [/* @__PURE__ */ jsxDEV("input", {
1435
- checked: unique,
1436
- "data-testid": "sc-editor-index-unique",
1437
- id: "sc-editor-index-unique",
1438
- onChange: onUniqueChange,
1439
- type: "checkbox"
1440
- }, void 0, false), /* @__PURE__ */ jsxDEV("span", {
1441
- className: "text-muted-foreground",
1442
- children: t("Unique")
1443
- }, void 0, false)]
1444
- }, void 0, true), /* @__PURE__ */ jsxDEV(Button, {
1445
- "data-testid": "sc-editor-index-apply",
1446
- disabled: busy || indexName.trim() === "" || indexFields.trim() === "",
1447
- onClick: onSubmitIndex,
1448
- size: "xs",
1449
- type: "button",
1450
- children: busy ? t("Applying…") : t("Apply")
1451
- }, void 0, false), /* @__PURE__ */ jsxDEV(Button, {
1452
- onClick: reset,
1453
- size: "xs",
1454
- type: "button",
1455
- variant: "ghost",
1456
- children: t("Cancel")
1457
- }, void 0, false)]
1458
- }, void 0, true), result?.kind === "error" && /* @__PURE__ */ jsxDEV("p", {
1459
- className: "mt-3 text-sm text-destructive",
1460
- "data-testid": "sc-editor-error",
1461
- role: "alert",
1462
- children: result.message
1463
- }, void 0, false), result?.kind === "needs-migration" && /* @__PURE__ */ jsxDEV("div", {
1464
- className: "mt-3 flex flex-col gap-2",
1465
- "data-testid": "sc-editor-needs-migration",
1466
- children: [/* @__PURE__ */ jsxDEV("p", {
1467
- className: "text-sm text-warning",
1468
- role: "alert",
1469
- children: t("This edit changes stored data and must go through a migration. Review the migration before applying.")
1470
- }, void 0, false), /* @__PURE__ */ jsxDEV(Button, {
1471
- className: "self-start",
1472
- "data-testid": "sc-editor-open-migrations",
1473
- onClick: onOpenMigrations,
1474
- size: "xs",
1475
- type: "button",
1476
- variant: "outline",
1477
- children: t("Open Migrations")
1478
- }, void 0, false)]
1479
- }, void 0, true), result?.kind === "ok" && result.diagnostics.length > 0 && /* @__PURE__ */ jsxDEV("div", {
1480
- className: "mt-3 flex flex-col gap-1",
1481
- "data-testid": "sc-editor-diagnostics",
1482
- children: [/* @__PURE__ */ jsxDEV("p", {
1483
- className: "text-sm text-destructive",
1484
- role: "alert",
1485
- children: t("Codegen reported diagnostics:")
1486
- }, void 0, false), /* @__PURE__ */ jsxDEV("ul", {
1487
- className: "flex flex-col gap-0.5",
1488
- children: result.diagnostics.map((diagnostic) => /* @__PURE__ */ jsxDEV("li", {
1489
- className: "font-mono text-[11px] text-destructive",
1490
- children: diagnostic
1491
- }, diagnostic, false))
1492
- }, void 0, false)]
1493
- }, void 0, true)]
1494
- }, void 0, true)]
1495
- }, void 0, true);
1496
- };
1497
-
1498
- const LIST_TABLES = adminRef(ADMIN_FUNCTIONS.listTables);
1499
- const LIST_TABLE_INDEXES = adminRef(ADMIN_FUNCTIONS.listTableIndexes);
1500
- const READ_TABLE_PAGE = adminRef(ADMIN_FUNCTIONS.readTablePage);
1501
- const DESCRIBE_TABLES = adminRef(ADMIN_FUNCTIONS.describeTables);
1502
- const EMPTY_COLUMNS = {};
1503
- const EMPTY_COLUMN_NAMES = [];
1504
- const EMPTY_COLUMN_META = [];
1505
- const ChevronIcon = (t0) => {
1506
- const $ = c(5);
1507
- const {
1508
- open
1509
- } = t0;
1510
- const t1 = open && "rotate-90";
1511
- let t2;
1512
- if ($[0] !== t1) {
1513
- t2 = cn("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150", t1);
1514
- $[0] = t1;
1515
- $[1] = t2;
1516
- } else {
1517
- t2 = $[1];
1518
- }
1519
- let t3;
1520
- if ($[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1521
- t3 = /* @__PURE__ */ jsxDEV("path", {
1522
- d: "m9 6 6 6-6 6"
1523
- }, void 0, false);
1524
- $[2] = t3;
1525
- } else {
1526
- t3 = $[2];
1527
- }
1528
- let t4;
1529
- if ($[3] !== t2) {
1530
- t4 = /* @__PURE__ */ jsxDEV("svg", {
1531
- "aria-hidden": "true",
1532
- className: t2,
1533
- fill: "none",
1534
- stroke: "currentColor",
1535
- strokeLinecap: "round",
1536
- strokeLinejoin: "round",
1537
- strokeWidth: 1.8,
1538
- viewBox: "0 0 24 24",
1539
- children: t3
1540
- }, void 0, false);
1541
- $[3] = t2;
1542
- $[4] = t4;
1543
- } else {
1544
- t4 = $[4];
1545
- }
1546
- return t4;
1547
- };
1548
- const TableEntry = (t0) => {
1549
- const $ = c(20);
1550
- const {
1551
- children,
1552
- expanded,
1553
- name,
1554
- onToggle,
1555
- rowCount,
1556
- rowTestId,
1557
- toggleTestId
1558
- } = t0;
1559
- let t1;
1560
- if ($[0] !== expanded) {
1561
- t1 = /* @__PURE__ */ jsxDEV(ChevronIcon, {
1562
- open: expanded
1563
- }, void 0, false);
1564
- $[0] = expanded;
1565
- $[1] = t1;
1566
- } else {
1567
- t1 = $[1];
1568
- }
1569
- let t2;
1570
- if ($[2] !== name) {
1571
- t2 = /* @__PURE__ */ jsxDEV("span", {
1572
- className: "truncate font-mono text-xs text-foreground",
1573
- title: name,
1574
- children: name
1575
- }, void 0, false);
1576
- $[2] = name;
1577
- $[3] = t2;
1578
- } else {
1579
- t2 = $[3];
1580
- }
1581
- let t3;
1582
- if ($[4] !== rowCount) {
1583
- t3 = /* @__PURE__ */ jsxDEV("span", {
1584
- className: "ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",
1585
- children: ["(", rowCount, ")"]
1586
- }, void 0, true);
1587
- $[4] = rowCount;
1588
- $[5] = t3;
1589
- } else {
1590
- t3 = $[5];
1591
- }
1592
- let t4;
1593
- if ($[6] !== expanded || $[7] !== onToggle || $[8] !== t1 || $[9] !== t2 || $[10] !== t3 || $[11] !== toggleTestId) {
1594
- t4 = /* @__PURE__ */ jsxDEV("button", {
1595
- "aria-expanded": expanded,
1596
- className: "flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40",
1597
- "data-testid": toggleTestId,
1598
- onClick: onToggle,
1599
- type: "button",
1600
- children: [t1, t2, " ", t3]
1601
- }, void 0, true);
1602
- $[6] = expanded;
1603
- $[7] = onToggle;
1604
- $[8] = t1;
1605
- $[9] = t2;
1606
- $[10] = t3;
1607
- $[11] = toggleTestId;
1608
- $[12] = t4;
1609
- } else {
1610
- t4 = $[12];
1611
- }
1612
- let t5;
1613
- if ($[13] !== children || $[14] !== expanded) {
1614
- t5 = expanded && /* @__PURE__ */ jsxDEV("div", {
1615
- className: "px-3 pb-3 ps-8",
1616
- children
1617
- }, void 0, false);
1618
- $[13] = children;
1619
- $[14] = expanded;
1620
- $[15] = t5;
1621
- } else {
1622
- t5 = $[15];
1623
- }
1624
- let t6;
1625
- if ($[16] !== rowTestId || $[17] !== t4 || $[18] !== t5) {
1626
- t6 = /* @__PURE__ */ jsxDEV("li", {
1627
- className: "border-t border-border/60 first:border-t-0",
1628
- "data-testid": rowTestId,
1629
- children: [t4, t5]
1630
- }, void 0, true);
1631
- $[16] = rowTestId;
1632
- $[17] = t4;
1633
- $[18] = t5;
1634
- $[19] = t6;
1635
- } else {
1636
- t6 = $[19];
1637
- }
1638
- return t6;
1639
- };
1640
- const ColumnChips = (t0) => {
1641
- const $ = c(5);
1642
- const {
1643
- columns,
1644
- testId
1645
- } = t0;
1646
- let t1;
1647
- if ($[0] !== columns) {
1648
- t1 = columns.map(_temp);
1649
- $[0] = columns;
1650
- $[1] = t1;
1651
- } else {
1652
- t1 = $[1];
1653
- }
1654
- let t2;
1655
- if ($[2] !== t1 || $[3] !== testId) {
1656
- t2 = /* @__PURE__ */ jsxDEV("ul", {
1657
- className: "flex flex-wrap gap-1.5 pt-1",
1658
- "data-testid": testId,
1659
- children: t1
1660
- }, void 0, false);
1661
- $[2] = t1;
1662
- $[3] = testId;
1663
- $[4] = t2;
1664
- } else {
1665
- t2 = $[4];
1666
- }
1667
- return t2;
1668
- };
1669
- const IndexList = (t0) => {
1670
- const $ = c(10);
1671
- const {
1672
- heading,
1673
- indexes,
1674
- testId
1675
- } = t0;
1676
- let t1;
1677
- if ($[0] !== heading) {
1678
- t1 = /* @__PURE__ */ jsxDEV("p", {
1679
- className: "mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",
1680
- children: heading
1681
- }, void 0, false);
1682
- $[0] = heading;
1683
- $[1] = t1;
1684
- } else {
1685
- t1 = $[1];
1686
- }
1687
- let t2;
1688
- if ($[2] !== indexes) {
1689
- t2 = indexes.map(_temp2);
1690
- $[2] = indexes;
1691
- $[3] = t2;
1692
- } else {
1693
- t2 = $[3];
1694
- }
1695
- let t3;
1696
- if ($[4] !== t2 || $[5] !== testId) {
1697
- t3 = /* @__PURE__ */ jsxDEV("ul", {
1698
- className: "flex flex-col gap-1",
1699
- "data-testid": testId,
1700
- children: t2
1701
- }, void 0, false);
1702
- $[4] = t2;
1703
- $[5] = testId;
1704
- $[6] = t3;
1705
- } else {
1706
- t3 = $[6];
1707
- }
1708
- let t4;
1709
- if ($[7] !== t1 || $[8] !== t3) {
1710
- t4 = /* @__PURE__ */ jsxDEV("div", {
1711
- className: "pt-3",
1712
- children: [t1, t3]
1713
- }, void 0, true);
1714
- $[7] = t1;
1715
- $[8] = t3;
1716
- $[9] = t4;
1717
- } else {
1718
- t4 = $[9];
1719
- }
1720
- return t4;
1721
- };
1722
- const SchemaViewer = (t0) => {
1723
- const $ = c(126);
1724
- const {
1725
- initialShardKey,
1726
- initialTable,
1727
- schemaEditable
1728
- } = t0;
1729
- const client = useLunora();
1730
- const t = useT();
1731
- const [view, setView] = useState("list");
1732
- const [shardKey, setShardKey] = useState(initialShardKey ?? "");
1733
- const [tableFilter, setTableFilter] = useState("");
1734
- const [tables, setTables] = useState(null);
1735
- const [error, setError] = useState(null);
1736
- let t1;
1737
- if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1738
- t1 = {};
1739
- $[0] = t1;
1740
- } else {
1741
- t1 = $[0];
1742
- }
1743
- const [columns, setColumns] = useState(t1);
1744
- let t2;
1745
- if ($[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1746
- t2 = {};
1747
- $[1] = t2;
1748
- } else {
1749
- t2 = $[1];
1750
- }
1751
- const [indexes, setIndexes] = useState(t2);
1752
- const [expanded, setExpanded] = useState(null);
1753
- let t3;
1754
- if ($[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1755
- t3 = {};
1756
- $[2] = t3;
1757
- } else {
1758
- t3 = $[2];
1759
- }
1760
- const [shardColumns, setShardColumns] = useState(t3);
1761
- let t4;
1762
- if ($[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1763
- t4 = {};
1764
- $[3] = t4;
1765
- } else {
1766
- t4 = $[3];
1767
- }
1768
- const [shardColumnsError, setShardColumnsError] = useState(t4);
1769
- const [globalTables, setGlobalTables] = useState(null);
1770
- const [globalError, setGlobalError] = useState(null);
1771
- let t5;
1772
- if ($[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1773
- t5 = {};
1774
- $[4] = t5;
1775
- } else {
1776
- t5 = $[4];
1777
- }
1778
- const [globalColumns, setGlobalColumns] = useState(t5);
1779
- const [globalExpanded, setGlobalExpanded] = useState(null);
1780
- let t6;
1781
- if ($[5] !== client) {
1782
- t6 = async (shard) => {
1783
- setError(null);
1784
- try {
1785
- const result = await client.query(LIST_TABLES, {}, callOptions(shard));
1786
- recordShard(shard);
1787
- setTables(result);
1788
- setColumns({});
1789
- setIndexes({});
1790
- setExpanded(null);
1791
- setShardColumns((previous) => Object.fromEntries(Object.entries(previous).filter((t82) => {
1792
- const [cachedShard] = t82;
1793
- return cachedShard !== shard;
1794
- })));
1795
- setShardColumnsError((previous_0) => Object.fromEntries(Object.entries(previous_0).filter((t92) => {
1796
- const [cachedShard_0] = t92;
1797
- return cachedShard_0 !== shard;
1798
- })));
1799
- } catch (t72) {
1800
- const error_ = t72;
1801
- setTables(null);
1802
- setError(errorMessage(error_));
1803
- }
1804
- };
1805
- $[5] = client;
1806
- $[6] = t6;
1807
- } else {
1808
- t6 = $[6];
1809
- }
1810
- const refresh = t6;
1811
- let t7;
1812
- if ($[7] !== client) {
1813
- t7 = async () => {
1814
- setGlobalError(null);
1815
- try {
1816
- setGlobalTables(await client.listGlobalTables());
1817
- } catch (t82) {
1818
- const error__0 = t82;
1819
- setGlobalTables(null);
1820
- setGlobalError(errorMessage(error__0));
1821
- }
1822
- };
1823
- $[7] = client;
1824
- $[8] = t7;
1825
- } else {
1826
- t7 = $[8];
1827
- }
1828
- const refreshGlobal = t7;
1829
- let t8;
1830
- if ($[9] !== shardKey) {
1831
- t8 = shardKey.trim();
1832
- $[9] = shardKey;
1833
- $[10] = t8;
1834
- } else {
1835
- t8 = $[10];
1836
- }
1837
- const debouncedShard = useDebounced(t8, 400);
1838
- let t10;
1839
- let t9;
1840
- if ($[11] !== debouncedShard || $[12] !== refresh || $[13] !== refreshGlobal) {
1841
- t9 = () => {
1842
- fireAndForget(refresh(debouncedShard));
1843
- fireAndForget(refreshGlobal());
1844
- };
1845
- t10 = [refresh, refreshGlobal, debouncedShard];
1846
- $[11] = debouncedShard;
1847
- $[12] = refresh;
1848
- $[13] = refreshGlobal;
1849
- $[14] = t10;
1850
- $[15] = t9;
1851
- } else {
1852
- t10 = $[14];
1853
- t9 = $[15];
1854
- }
1855
- useEffect(t9, t10);
1856
- let t11;
1857
- if ($[16] !== client || $[17] !== columns || $[18] !== expanded || $[19] !== shardKey) {
1858
- t11 = async (table) => {
1859
- if (expanded === table) {
1860
- setExpanded(null);
1861
- return;
1862
- }
1863
- setExpanded(table);
1864
- const cacheKey = `${shardKey}:${table}`;
1865
- if (columns[cacheKey] !== void 0) {
1866
- return;
1867
- }
1868
- const [page, indexResult] = await Promise.allSettled([client.query(READ_TABLE_PAGE, {
1869
- limit: 1,
1870
- offset: 0,
1871
- table
1872
- }, callOptions(shardKey)), client.query(LIST_TABLE_INDEXES, {
1873
- table
1874
- }, callOptions(shardKey))]);
1875
- if (page.status === "fulfilled") {
1876
- setColumns((previous_1) => ({
1877
- ...previous_1,
1878
- [cacheKey]: page.value.columns
1879
- }));
1880
- } else {
1881
- setError(errorMessage(page.reason));
1882
- }
1883
- if (indexResult.status === "fulfilled") {
1884
- setIndexes((previous_2) => ({
1885
- ...previous_2,
1886
- [cacheKey]: indexResult.value.indexes
1887
- }));
1888
- }
1889
- };
1890
- $[16] = client;
1891
- $[17] = columns;
1892
- $[18] = expanded;
1893
- $[19] = shardKey;
1894
- $[20] = t11;
1895
- } else {
1896
- t11 = $[20];
1897
- }
1898
- const toggle = t11;
1899
- let t12;
1900
- if ($[21] !== client || $[22] !== globalColumns || $[23] !== globalExpanded) {
1901
- t12 = async (table_0) => {
1902
- if (globalExpanded === table_0) {
1903
- setGlobalExpanded(null);
1904
- return;
1905
- }
1906
- setGlobalExpanded(table_0);
1907
- if (globalColumns[table_0] !== void 0) {
1908
- return;
1909
- }
1910
- try {
1911
- const page_0 = await client.readGlobalTablePage({
1912
- limit: 1,
1913
- offset: 0,
1914
- table: table_0
1915
- });
1916
- setGlobalColumns((previous_3) => ({
1917
- ...previous_3,
1918
- [table_0]: page_0.columns
1919
- }));
1920
- } catch (t132) {
1921
- const error__1 = t132;
1922
- setGlobalError(errorMessage(error__1));
1923
- }
1924
- };
1925
- $[21] = client;
1926
- $[22] = globalColumns;
1927
- $[23] = globalExpanded;
1928
- $[24] = t12;
1929
- } else {
1930
- t12 = $[24];
1931
- }
1932
- const toggleGlobal = t12;
1933
- const appliedTable = useRef(void 0);
1934
- let t13;
1935
- let t14;
1936
- if ($[25] !== initialTable || $[26] !== tables || $[27] !== toggle) {
1937
- t13 = () => {
1938
- if (initialTable === void 0 || tables === null || appliedTable.current === initialTable) {
1939
- return;
1940
- }
1941
- if (tables.some((table_1) => table_1.name === initialTable)) {
1942
- appliedTable.current = initialTable;
1943
- fireAndForget(toggle(initialTable));
1944
- }
1945
- };
1946
- t14 = [initialTable, tables, toggle];
1947
- $[25] = initialTable;
1948
- $[26] = tables;
1949
- $[27] = toggle;
1950
- $[28] = t13;
1951
- $[29] = t14;
1952
- } else {
1953
- t13 = $[28];
1954
- t14 = $[29];
1955
- }
1956
- useEffect(t13, t14);
1957
- let t15;
1958
- if ($[30] !== client) {
1959
- t15 = async (shard_0, shardNames, globalNames) => {
1960
- const [described, globalPages] = await Promise.all([Promise.allSettled([client.query(DESCRIBE_TABLES, {
1961
- tables: [...shardNames, ...globalNames]
1962
- }, callOptions(shard_0))]), Promise.all(globalNames.map(async (table_2) => {
1963
- const page_1 = await Promise.allSettled([client.readGlobalTablePage({
1964
- limit: 1,
1965
- offset: 0,
1966
- table: table_2
1967
- })]);
1968
- const value = page_1[0].status === "fulfilled" ? page_1[0].value : void 0;
1969
- return {
1970
- columns: value?.columns ?? [],
1971
- refs: value?.refs ?? {},
1972
- table: table_2
1973
- };
1974
- }))]);
1975
- const typedColumns = described[0].status === "fulfilled" ? described[0].value?.columnsByTable ?? {} : {};
1976
- const columnsFailed = described[0].status === "rejected";
1977
- const globalFallback = new Map(globalPages.map(_temp3));
1978
- const resolved = [...shardNames, ...globalNames].map((table_4) => {
1979
- const typed = typedColumns[table_4] ?? [];
1980
- return [table_4, typed.length > 0 ? typed : globalFallback.get(table_4) ?? []];
1981
- });
1982
- setShardColumns((previous_4) => ({
1983
- ...previous_4,
1984
- [shard_0]: Object.fromEntries(resolved)
1985
- }));
1986
- setShardColumnsError((previous_5) => ({
1987
- ...previous_5,
1988
- [shard_0]: columnsFailed
1989
- }));
1990
- };
1991
- $[30] = client;
1992
- $[31] = t15;
1993
- } else {
1994
- t15 = $[31];
1995
- }
1996
- const probeSchema = t15;
1997
- let t16;
1998
- let t17;
1999
- if ($[32] !== globalError || $[33] !== globalTables || $[34] !== probeSchema || $[35] !== shardColumns || $[36] !== shardKey || $[37] !== tables || $[38] !== view) {
2000
- t16 = () => {
2001
- if (view !== "graph" || tables === null || globalTables === null && globalError === null || shardColumns[shardKey] !== void 0) {
2002
- return;
2003
- }
2004
- fireAndForget(probeSchema(shardKey, tables.map(_temp4), (globalTables ?? []).map(_temp5)));
2005
- };
2006
- t17 = [view, tables, globalTables, globalError, shardKey, shardColumns, probeSchema];
2007
- $[32] = globalError;
2008
- $[33] = globalTables;
2009
- $[34] = probeSchema;
2010
- $[35] = shardColumns;
2011
- $[36] = shardKey;
2012
- $[37] = tables;
2013
- $[38] = view;
2014
- $[39] = t16;
2015
- $[40] = t17;
2016
- } else {
2017
- t16 = $[39];
2018
- t17 = $[40];
2019
- }
2020
- useEffect(t16, t17);
2021
- const columnsForShard = shardColumns[shardKey] ?? EMPTY_COLUMNS;
2022
- let t18;
2023
- if ($[41] !== columnsForShard || $[42] !== globalTables || $[43] !== tables) {
2024
- let t192;
2025
- if ($[45] !== columnsForShard) {
2026
- t192 = (table_7) => ({
2027
- columns: columnsForShard[table_7.name] ?? EMPTY_COLUMN_META,
2028
- name: table_7.name,
2029
- tier: "shard"
2030
- });
2031
- $[45] = columnsForShard;
2032
- $[46] = t192;
2033
- } else {
2034
- t192 = $[46];
2035
- }
2036
- const shardOnes = (tables ?? []).map(t192);
2037
- let t202;
2038
- if ($[47] !== columnsForShard) {
2039
- t202 = (table_8) => ({
2040
- columns: columnsForShard[table_8.name] ?? EMPTY_COLUMN_META,
2041
- name: table_8.name,
2042
- tier: "global"
2043
- });
2044
- $[47] = columnsForShard;
2045
- $[48] = t202;
2046
- } else {
2047
- t202 = $[48];
2048
- }
2049
- const globalOnes = (globalTables ?? []).map(t202);
2050
- t18 = [...shardOnes, ...globalOnes];
2051
- $[41] = columnsForShard;
2052
- $[42] = globalTables;
2053
- $[43] = tables;
2054
- $[44] = t18;
2055
- } else {
2056
- t18 = $[44];
2057
- }
2058
- const diagramTables = t18;
2059
- let t19;
2060
- if ($[49] !== tableFilter || $[50] !== tables) {
2061
- const needle = tableFilter.trim().toLowerCase();
2062
- t19 = (tables ?? []).filter((table_9) => table_9.name.toLowerCase().includes(needle));
2063
- $[49] = tableFilter;
2064
- $[50] = tables;
2065
- $[51] = t19;
2066
- } else {
2067
- t19 = $[51];
2068
- }
2069
- const filteredTables = t19;
2070
- let t20;
2071
- if ($[52] !== globalTables || $[53] !== tableFilter) {
2072
- const needle_0 = tableFilter.trim().toLowerCase();
2073
- t20 = (globalTables ?? []).filter((table_10) => table_10.name.toLowerCase().includes(needle_0));
2074
- $[52] = globalTables;
2075
- $[53] = tableFilter;
2076
- $[54] = t20;
2077
- } else {
2078
- t20 = $[54];
2079
- }
2080
- const filteredGlobalTables = t20;
2081
- let t21;
2082
- if ($[55] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2083
- t21 = () => {
2084
- setView("list");
2085
- };
2086
- $[55] = t21;
2087
- } else {
2088
- t21 = $[55];
2089
- }
2090
- const showList = t21;
2091
- let t22;
2092
- if ($[56] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2093
- t22 = () => {
2094
- setView("graph");
2095
- };
2096
- $[56] = t22;
2097
- } else {
2098
- t22 = $[56];
2099
- }
2100
- const showGraph = t22;
2101
- let t23;
2102
- if ($[57] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2103
- t23 = (event) => {
2104
- setTableFilter(event.target.value);
2105
- };
2106
- $[57] = t23;
2107
- } else {
2108
- t23 = $[57];
2109
- }
2110
- const onFilterChange = t23;
2111
- let t24;
2112
- if ($[58] !== refresh || $[59] !== shardKey) {
2113
- t24 = (_tables) => {
2114
- fireAndForget(refresh(shardKey));
2115
- };
2116
- $[58] = refresh;
2117
- $[59] = shardKey;
2118
- $[60] = t24;
2119
- } else {
2120
- t24 = $[60];
2121
- }
2122
- const onSchemaApplied = t24;
2123
- let t25;
2124
- if ($[61] !== tables) {
2125
- t25 = tables ?? [];
2126
- $[61] = tables;
2127
- $[62] = t25;
2128
- } else {
2129
- t25 = $[62];
2130
- }
2131
- let t26;
2132
- if ($[63] !== t25) {
2133
- t26 = t25.map(_temp6);
2134
- $[63] = t25;
2135
- $[64] = t26;
2136
- } else {
2137
- t26 = $[64];
2138
- }
2139
- const shardTableNames = t26;
2140
- let t27;
2141
- if ($[65] !== shardKey) {
2142
- t27 = /* @__PURE__ */ jsxDEV(ShardInput, {
2143
- onChange: setShardKey,
2144
- testId: "sc-shard-input",
2145
- value: shardKey
2146
- }, void 0, false);
2147
- $[65] = shardKey;
2148
- $[66] = t27;
2149
- } else {
2150
- t27 = $[66];
2151
- }
2152
- let t28;
2153
- if ($[67] !== t) {
2154
- t28 = t("Schema view");
2155
- $[67] = t;
2156
- $[68] = t28;
2157
- } else {
2158
- t28 = $[68];
2159
- }
2160
- const t29 = view === "list";
2161
- const t30 = view === "list" ? "default" : "outline";
2162
- let t31;
2163
- if ($[69] !== t) {
2164
- t31 = t("Table list");
2165
- $[69] = t;
2166
- $[70] = t31;
2167
- } else {
2168
- t31 = $[70];
2169
- }
2170
- let t32;
2171
- if ($[71] !== t29 || $[72] !== t30 || $[73] !== t31) {
2172
- t32 = /* @__PURE__ */ jsxDEV(Button, {
2173
- "aria-pressed": t29,
2174
- "data-testid": "sc-view-list",
2175
- onClick: showList,
2176
- size: "xs",
2177
- type: "button",
2178
- variant: t30,
2179
- children: t31
2180
- }, void 0, false);
2181
- $[71] = t29;
2182
- $[72] = t30;
2183
- $[73] = t31;
2184
- $[74] = t32;
2185
- } else {
2186
- t32 = $[74];
2187
- }
2188
- const t33 = view === "graph";
2189
- const t34 = view === "graph" ? "default" : "outline";
2190
- let t35;
2191
- if ($[75] !== t) {
2192
- t35 = t("Graph");
2193
- $[75] = t;
2194
- $[76] = t35;
2195
- } else {
2196
- t35 = $[76];
2197
- }
2198
- let t36;
2199
- if ($[77] !== t33 || $[78] !== t34 || $[79] !== t35) {
2200
- t36 = /* @__PURE__ */ jsxDEV(Button, {
2201
- "aria-pressed": t33,
2202
- "data-testid": "sc-view-graph",
2203
- onClick: showGraph,
2204
- size: "xs",
2205
- type: "button",
2206
- variant: t34,
2207
- children: t35
2208
- }, void 0, false);
2209
- $[77] = t33;
2210
- $[78] = t34;
2211
- $[79] = t35;
2212
- $[80] = t36;
2213
- } else {
2214
- t36 = $[80];
2215
- }
2216
- let t37;
2217
- if ($[81] !== t28 || $[82] !== t32 || $[83] !== t36) {
2218
- t37 = /* @__PURE__ */ jsxDEV("div", {
2219
- "aria-label": t28,
2220
- className: "flex gap-1.5",
2221
- "data-testid": "sc-view-toggle",
2222
- role: "group",
2223
- children: [t32, t36]
2224
- }, void 0, true);
2225
- $[81] = t28;
2226
- $[82] = t32;
2227
- $[83] = t36;
2228
- $[84] = t37;
2229
- } else {
2230
- t37 = $[84];
2231
- }
2232
- let t38;
2233
- if ($[85] !== t27 || $[86] !== t37) {
2234
- t38 = /* @__PURE__ */ jsxDEV("div", {
2235
- className: "flex flex-wrap items-center gap-3",
2236
- children: [t27, t37]
2237
- }, void 0, true);
2238
- $[85] = t27;
2239
- $[86] = t37;
2240
- $[87] = t38;
2241
- } else {
2242
- t38 = $[87];
2243
- }
2244
- let t39;
2245
- if ($[88] !== onSchemaApplied || $[89] !== schemaEditable || $[90] !== shardTableNames) {
2246
- t39 = schemaEditable === true && /* @__PURE__ */ jsxDEV(SchemaEditorOverlay, {
2247
- onApplied: onSchemaApplied,
2248
- tableNames: shardTableNames
2249
- }, void 0, false);
2250
- $[88] = onSchemaApplied;
2251
- $[89] = schemaEditable;
2252
- $[90] = shardTableNames;
2253
- $[91] = t39;
2254
- } else {
2255
- t39 = $[91];
2256
- }
2257
- let t40;
2258
- if ($[92] !== t || $[93] !== tableFilter || $[94] !== view) {
2259
- t40 = view === "list" && /* @__PURE__ */ jsxDEV(Input, {
2260
- "aria-label": t("Filter tables"),
2261
- className: "h-8 max-w-xs",
2262
- "data-testid": "sc-filter",
2263
- onChange: onFilterChange,
2264
- placeholder: t("Filter tables"),
2265
- value: tableFilter
2266
- }, void 0, false);
2267
- $[92] = t;
2268
- $[93] = tableFilter;
2269
- $[94] = view;
2270
- $[95] = t40;
2271
- } else {
2272
- t40 = $[95];
2273
- }
2274
- let t41;
2275
- if ($[96] !== diagramTables || $[97] !== error || $[98] !== globalError || $[99] !== shardColumnsError || $[100] !== shardKey || $[101] !== view) {
2276
- t41 = view === "graph" && /* @__PURE__ */ jsxDEV("div", {
2277
- className: "flex flex-col gap-2",
2278
- "data-testid": "sc-graph-view",
2279
- children: [error !== null && /* @__PURE__ */ jsxDEV("p", {
2280
- className: "text-sm text-destructive",
2281
- "data-testid": "sc-error",
2282
- role: "alert",
2283
- children: error
2284
- }, void 0, false), globalError !== null && /* @__PURE__ */ jsxDEV("p", {
2285
- className: "text-sm text-destructive",
2286
- "data-testid": "sc-global-error",
2287
- role: "alert",
2288
- children: globalError
2289
- }, void 0, false), /* @__PURE__ */ jsxDEV(SchemaDiagram, {
2290
- columnsError: shardColumnsError[shardKey] === true,
2291
- tables: diagramTables,
2292
- testIdPrefix: "sc-graph"
2293
- }, void 0, false)]
2294
- }, void 0, true);
2295
- $[96] = diagramTables;
2296
- $[97] = error;
2297
- $[98] = globalError;
2298
- $[99] = shardColumnsError;
2299
- $[100] = shardKey;
2300
- $[101] = view;
2301
- $[102] = t41;
2302
- } else {
2303
- t41 = $[102];
2304
- }
2305
- let t42;
2306
- if ($[103] !== columns || $[104] !== error || $[105] !== expanded || $[106] !== filteredGlobalTables || $[107] !== filteredTables || $[108] !== globalColumns || $[109] !== globalError || $[110] !== globalExpanded || $[111] !== globalTables || $[112] !== indexes || $[113] !== shardKey || $[114] !== t || $[115] !== tables || $[116] !== toggle || $[117] !== toggleGlobal || $[118] !== view) {
2307
- t42 = view === "list" && /* @__PURE__ */ jsxDEV("div", {
2308
- className: "flex flex-col gap-4",
2309
- children: [/* @__PURE__ */ jsxDEV(Card, {
2310
- "data-testid": "sc-shard-section",
2311
- size: "sm",
2312
- children: [/* @__PURE__ */ jsxDEV(CardHeader, {
2313
- children: [/* @__PURE__ */ jsxDEV("div", {
2314
- className: "flex items-center gap-2",
2315
- children: [/* @__PURE__ */ jsxDEV(StorageTierBadge, {
2316
- tier: "shard"
2317
- }, void 0, false), /* @__PURE__ */ jsxDEV(CardTitle, {
2318
- children: t("Shard tables")
2319
- }, void 0, false), tables !== null && /* @__PURE__ */ jsxDEV(Badge, {
2320
- className: "ms-auto tabular-nums",
2321
- variant: "outline",
2322
- children: filteredTables.length
2323
- }, void 0, false)]
2324
- }, void 0, true), /* @__PURE__ */ jsxDEV(CardDescription, {
2325
- children: TIER_META.shard.hint
2326
- }, void 0, false)]
2327
- }, void 0, true), /* @__PURE__ */ jsxDEV(CardContent, {
2328
- children: [error !== null && /* @__PURE__ */ jsxDEV("p", {
2329
- className: "text-sm text-destructive",
2330
- "data-testid": "sc-error",
2331
- role: "alert",
2332
- children: error
2333
- }, void 0, false), tables !== null && tables.length === 0 && /* @__PURE__ */ jsxDEV("p", {
2334
- className: "text-sm text-muted-foreground",
2335
- "data-testid": "sc-empty",
2336
- children: t("No tables in this shard.")
2337
- }, void 0, false), tables !== null && tables.length > 0 && filteredTables.length === 0 && /* @__PURE__ */ jsxDEV("p", {
2338
- className: "text-sm text-muted-foreground",
2339
- "data-testid": "sc-no-match",
2340
- children: t("No tables match your filter.")
2341
- }, void 0, false), filteredTables.length > 0 && /* @__PURE__ */ jsxDEV("ul", {
2342
- className: "-mx-3 overflow-hidden border-t border-border",
2343
- "data-testid": "sc-table-list",
2344
- children: filteredTables.map((table_12) => {
2345
- const cacheKey_0 = `${shardKey}:${table_12.name}`;
2346
- const tableIndexes = indexes[cacheKey_0] ?? [];
2347
- return /* @__PURE__ */ jsxDEV(TableEntry, {
2348
- expanded: expanded === table_12.name,
2349
- name: table_12.name,
2350
- onToggle: () => {
2351
- fireAndForget(toggle(table_12.name));
2352
- },
2353
- rowCount: table_12.rowCount,
2354
- rowTestId: `sc-table-${table_12.name}`,
2355
- toggleTestId: `sc-toggle-${table_12.name}`,
2356
- children: [/* @__PURE__ */ jsxDEV(ColumnChips, {
2357
- columns: columns[cacheKey_0] ?? EMPTY_COLUMN_NAMES,
2358
- testId: `sc-columns-${table_12.name}`
2359
- }, void 0, false), tableIndexes.length > 0 && /* @__PURE__ */ jsxDEV(IndexList, {
2360
- heading: t("Indexes"),
2361
- indexes: tableIndexes,
2362
- testId: `sc-indexes-${table_12.name}`
2363
- }, void 0, false)]
2364
- }, table_12.name, true);
2365
- })
2366
- }, void 0, false)]
2367
- }, void 0, true)]
2368
- }, void 0, true), /* @__PURE__ */ jsxDEV(Card, {
2369
- "data-testid": "sc-global-section",
2370
- size: "sm",
2371
- children: [/* @__PURE__ */ jsxDEV(CardHeader, {
2372
- children: [/* @__PURE__ */ jsxDEV("div", {
2373
- className: "flex items-center gap-2",
2374
- children: [/* @__PURE__ */ jsxDEV(StorageTierBadge, {
2375
- tier: "global"
2376
- }, void 0, false), /* @__PURE__ */ jsxDEV(CardTitle, {
2377
- children: t("Global tables (D1)")
2378
- }, void 0, false), globalTables !== null && /* @__PURE__ */ jsxDEV(Badge, {
2379
- className: "ms-auto tabular-nums",
2380
- variant: "outline",
2381
- children: filteredGlobalTables.length
2382
- }, void 0, false)]
2383
- }, void 0, true), /* @__PURE__ */ jsxDEV(CardDescription, {
2384
- children: TIER_META.global.hint
2385
- }, void 0, false)]
2386
- }, void 0, true), /* @__PURE__ */ jsxDEV(CardContent, {
2387
- children: [globalError !== null && /* @__PURE__ */ jsxDEV("p", {
2388
- className: "text-sm text-destructive",
2389
- "data-testid": "sc-global-error",
2390
- role: "alert",
2391
- children: globalError
2392
- }, void 0, false), globalTables !== null && globalTables.length === 0 && /* @__PURE__ */ jsxDEV(EmptyState, {
2393
- description: TIER_META.global.hint,
2394
- testId: "sc-global-empty",
2395
- title: t("No global tables.")
2396
- }, void 0, false), globalTables !== null && globalTables.length > 0 && filteredGlobalTables.length === 0 && /* @__PURE__ */ jsxDEV("p", {
2397
- className: "text-sm text-muted-foreground",
2398
- "data-testid": "sc-global-no-match",
2399
- children: t("No tables match your filter.")
2400
- }, void 0, false), filteredGlobalTables.length > 0 && /* @__PURE__ */ jsxDEV("ul", {
2401
- className: "-mx-3 overflow-hidden border-t border-border",
2402
- "data-testid": "sc-global-table-list",
2403
- children: filteredGlobalTables.map((table_13) => /* @__PURE__ */ jsxDEV(TableEntry, {
2404
- expanded: globalExpanded === table_13.name,
2405
- name: table_13.name,
2406
- onToggle: () => {
2407
- fireAndForget(toggleGlobal(table_13.name));
2408
- },
2409
- rowCount: table_13.rowCount,
2410
- rowTestId: `sc-global-table-${table_13.name}`,
2411
- toggleTestId: `sc-global-toggle-${table_13.name}`,
2412
- children: /* @__PURE__ */ jsxDEV(ColumnChips, {
2413
- columns: globalColumns[table_13.name] ?? EMPTY_COLUMN_NAMES,
2414
- testId: `sc-global-columns-${table_13.name}`
2415
- }, void 0, false)
2416
- }, table_13.name, false))
2417
- }, void 0, false)]
2418
- }, void 0, true)]
2419
- }, void 0, true)]
2420
- }, void 0, true);
2421
- $[103] = columns;
2422
- $[104] = error;
2423
- $[105] = expanded;
2424
- $[106] = filteredGlobalTables;
2425
- $[107] = filteredTables;
2426
- $[108] = globalColumns;
2427
- $[109] = globalError;
2428
- $[110] = globalExpanded;
2429
- $[111] = globalTables;
2430
- $[112] = indexes;
2431
- $[113] = shardKey;
2432
- $[114] = t;
2433
- $[115] = tables;
2434
- $[116] = toggle;
2435
- $[117] = toggleGlobal;
2436
- $[118] = view;
2437
- $[119] = t42;
2438
- } else {
2439
- t42 = $[119];
2440
- }
2441
- let t43;
2442
- if ($[120] !== t38 || $[121] !== t39 || $[122] !== t40 || $[123] !== t41 || $[124] !== t42) {
2443
- t43 = /* @__PURE__ */ jsxDEV("div", {
2444
- className: "flex flex-col gap-4",
2445
- "data-testid": "lunora-schema",
2446
- children: [t38, t39, t40, t41, t42]
2447
- }, void 0, true);
2448
- $[120] = t38;
2449
- $[121] = t39;
2450
- $[122] = t40;
2451
- $[123] = t41;
2452
- $[124] = t42;
2453
- $[125] = t43;
2454
- } else {
2455
- t43 = $[125];
2456
- }
2457
- return t43;
2458
- };
2459
- function _temp(column) {
2460
- return /* @__PURE__ */ jsxDEV("li", {
2461
- className: "rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",
2462
- children: column
2463
- }, column, false);
2464
- }
2465
- function _temp2(index) {
2466
- return /* @__PURE__ */ jsxDEV("li", {
2467
- className: "flex flex-wrap items-center gap-1.5 text-xs",
2468
- children: [/* @__PURE__ */ jsxDEV("span", {
2469
- className: "font-mono",
2470
- children: index.name
2471
- }, void 0, false), /* @__PURE__ */ jsxDEV(Badge, {
2472
- variant: "outline",
2473
- children: index.type
2474
- }, void 0, false), index.unique === true && /* @__PURE__ */ jsxDEV(Badge, {
2475
- variant: "secondary",
2476
- children: "unique"
2477
- }, void 0, false), /* @__PURE__ */ jsxDEV("span", {
2478
- className: "text-muted-foreground",
2479
- children: index.fields.join(", ")
2480
- }, void 0, false)]
2481
- }, `${index.type}:${index.name}`, true);
2482
- }
2483
- function _temp3(t0) {
2484
- const {
2485
- columns: columnNames,
2486
- refs,
2487
- table: table_3
2488
- } = t0;
2489
- return [table_3, columnNames.map((name) => {
2490
- const ref = refs[name];
2491
- return ref === void 0 ? {
2492
- name,
2493
- optional: false,
2494
- type: ""
2495
- } : {
2496
- name,
2497
- optional: false,
2498
- ref,
2499
- type: "id"
2500
- };
2501
- })];
2502
- }
2503
- function _temp4(table_5) {
2504
- return table_5.name;
2505
- }
2506
- function _temp5(table_6) {
2507
- return table_6.name;
2508
- }
2509
- function _temp6(table_11) {
2510
- return table_11.name;
2511
- }
2512
-
2513
- export { SchemaViewer };
2
+ import{c as Y}from"react/compiler-runtime";import{useLunora as At}from"@lunora/react";import{useState as v,useRef as Ct,useEffect as Ge}from"react";import{ShardInput as qt}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as ct,d as be}from"../packem_shared/storage-tier-DznqOf-q.js";import{g as we}from"../packem_shared/badge-BbuuAio7.js";import{u as z}from"../packem_shared/button-BkCrNcAs.js";import{c as mt,n as ut,f as pt,m as ht,u as gt}from"../packem_shared/card-CIDGUN6K.js";import{E as Ut}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as Ae}from"../packem_shared/input-JHu63lTv.js";import Bt from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as Ue}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as tt}from"../packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js";import{f as M,c as Qe,e as Ye,a as at}from"../packem_shared/internal-AtZ4bTal.js";import{r as Gt}from"../packem_shared/shard-history-DMEW5VBE.js";import{c as Ke}from"../packem_shared/utils-bhneXptQ.js";import{Download01Icon as Kt}from"@hugeicons/core-free-icons";import{HugeiconsIcon as Dt}from"@hugeicons/react";import{Handle as vt,Position as yt,getNodesBounds as Ht,getViewportForBounds as Jt,useNodesState as Vt,useEdgesState as Wt,Background as Xt,Panel as ft,Controls as Zt,MiniMap as Qt,ReactFlow as Yt,useNodes as ea,useReactFlow as ta}from"@xyflow/react";import{h as aa,$ as la,b as na,N as dt}from"../packem_shared/dropdown-menu-C3RQ_HlW.js";import{jsx as n,jsxs as u}from"react/jsx-runtime";import{LunoraError as sa}from"@lunora/errors";import{toBlob as ra,toSvg as oa}from"html-to-image";import{useNavigate as ia}from"@tanstack/react-router";import{p as Ne}from"../packem_shared/label-6uP1obNF.js";function da(a){const e=Y(10);let t,o,r;e[0]!==a?({className:t,selected:r,...o}=a,e[0]=a,e[1]=t,e[2]=o,e[3]=r):(t=e[1],o=e[2],r=e[3]);const s=r===!0?"":void 0;let l;e[4]!==t?(l=Ke("rounded-md border border-border bg-card text-card-foreground shadow-sm transition-colors","data-[selected]:border-ring data-[selected]:ring-[3px] data-[selected]:ring-ring/30",t),e[4]=t,e[5]=l):l=e[5];let i;return e[6]!==o||e[7]!==s||e[8]!==l?(i=n("div",{"data-slot":"base-node","data-selected":s,className:l,...o}),e[6]=o,e[7]=s,e[8]=l,e[9]=i):i=e[9],i}function ca(a){const e=Y(8);let t,o;e[0]!==a?({className:t,...o}=a,e[0]=a,e[1]=t,e[2]=o):(t=e[1],o=e[2]);let r;e[3]!==t?(r=Ke("flex items-center gap-2 rounded-t-md bg-muted/50 px-3 py-1.5",t),e[3]=t,e[4]=r):r=e[4];let s;return e[5]!==o||e[6]!==r?(s=n("div",{"data-slot":"base-node-header",className:r,...o}),e[5]=o,e[6]=r,e[7]=s):s=e[7],s}function ma(a){const e=Y(8);let t,o;e[0]!==a?({className:t,...o}=a,e[0]=a,e[1]=t,e[2]=o):(t=e[1],o=e[2]);let r;e[3]!==t?(r=Ke("flex flex-col",t),e[3]=t,e[4]=r):r=e[4];let s;return e[5]!==o||e[6]!==r?(s=n("div",{"data-slot":"base-node-content",className:r,...o}),e[5]=o,e[6]=r,e[7]=s):s=e[7],s}const Nt=a=>{const e=a.ref===void 0?a.type:`${a.type} → ${a.ref}`;return a.optional===!0?`${e}?`:e},ua=a=>{const e=Y(22),{data:t,selected:o}=a,r=Ue();let s;e[0]!==t.label||e[1]!==t.loadError||e[2]!==r?(s=t.loadError===!0?n("span",{className:"px-3 py-1.5 text-xs text-destructive","data-testid":`sd-node-${t.label}-error`,children:r("Columns unavailable")}):n("span",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"—"}),e[0]=t.label,e[1]=t.loadError,e[2]=r,e[3]=s):s=e[3];const l=s,i=`sd-node-${t.label}`;let m;e[4]!==t.label?(m=n("span",{className:"truncate font-mono text-xs font-semibold",title:t.label,children:t.label}),e[4]=t.label,e[5]=m):m=e[5];let d;e[6]!==t.tier?(d=n("span",{className:"ms-auto",children:n(ct,{tier:t.tier})}),e[6]=t.tier,e[7]=d):d=e[7];let f;e[8]!==m||e[9]!==d?(f=u(ca,{children:[m,d]}),e[8]=m,e[9]=d,e[10]=f):f=e[10];let g;e[11]!==t.columns||e[12]!==t.label||e[13]!==l?(g=t.columns.length===0?l:t.columns.map(x=>u("div",{className:Ke("relative flex items-center gap-2 border-t border-border px-3 py-1.5 text-xs first:border-t-0",x.pk===!0&&"bg-muted/30"),"data-testid":`sd-col-${t.label}-${x.name}`,children:[n(vt,{className:"!h-2 !w-2 !-left-1 !border-border !bg-muted-foreground/70",id:x.name,isConnectable:!1,position:yt.Left,type:"target"}),n("span",{className:"truncate font-mono",title:x.name,children:x.name}),x.pk===!0&&n(we,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),x.ref!==void 0&&n(we,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),n("span",{className:"ms-auto truncate text-muted-foreground",title:Nt(x),children:Nt(x)}),n(vt,{className:"!h-2 !w-2 !-right-1 !border-border !bg-muted-foreground/70",id:x.name,isConnectable:!1,position:yt.Right,type:"source"})]},x.name)),e[11]=t.columns,e[12]=t.label,e[13]=l,e[14]=g):g=e[14];let b;e[15]!==g?(b=n(ma,{children:g}),e[15]=g,e[16]=b):b=e[16];let p;return e[17]!==o||e[18]!==i||e[19]!==f||e[20]!==b?(p=u(da,{className:"w-64 overflow-hidden","data-testid":i,selected:o,children:[f,b]}),e[17]=o,e[18]=i,e[19]=f,e[20]=b,e[21]=p):p=e[21],p},qe=1920,et=1080,Tt=32,bt=(a,e)=>{const t=globalThis.document.createElement("a");t.href=a,t.download=e,globalThis.document.body.append(t),t.click(),t.remove()},pa=(a,e,t="schema-diagram.json")=>{const o={edges:e,exportedAt:new Date().toISOString(),nodes:a},r=JSON.stringify(o,void 0,2),s=globalThis.URL.createObjectURL(new globalThis.Blob([r],{type:"application/json"}));bt(s,t),globalThis.setTimeout(()=>{globalThis.URL.revokeObjectURL(s)},0)},_t=(a,e,t,o)=>{const r=Ht(a),{x:s,y:l,zoom:i}=Jt(r,e,t,.1,2,o);return{transform:[s,l,i],zoom:i}},ha=async(a,e,t="schema-diagram.png")=>{const{transform:o}=_t(e,qe,et,Tt),[r,s,l]=o,i=await ra(a,{backgroundColor:"#ffffff",height:et,style:{transform:`translate(${r.toString()}px, ${s.toString()}px) scale(${l.toString()})`,transformOrigin:"top left",width:`${qe.toString()}px`},width:qe});if(i===null)throw new sa("INTERNAL","html-to-image produced no blob");const m=globalThis.URL.createObjectURL(i);bt(m,t),globalThis.setTimeout(()=>{globalThis.URL.revokeObjectURL(m)},0)},ga=async(a,e,t="schema-diagram.svg")=>{const{transform:o}=_t(e,qe,et,Tt),[r,s,l]=o,i=await oa(a,{backgroundColor:"#ffffff",height:et,style:{transform:`translate(${r.toString()}px, ${s.toString()}px) scale(${l.toString()})`,transformOrigin:"top left",width:`${qe.toString()}px`},width:qe});bt(i,t)},fa=a=>38+Math.max(1,a)*28,ba=(a,e)=>{const t=new Map;for(const l of a)t.set(l,[]);for(const l of e)l.to!==l.from&&t.has(l.from)&&t.has(l.to)&&t.get(l.from)?.push(l.to);const o=new Map,r=new Set,s=l=>{const i=o.get(l);if(i!==void 0)return i;if(r.has(l))return 0;r.add(l);let m=0;for(const d of t.get(l)??[])m=Math.max(m,s(d)+1);return r.delete(l),o.set(l,m),m};for(const l of a)s(l);return o},xa=(a,e,t)=>{const o=ba(a,e),r=new Map,s=[];for(const l of a){const i=o.get(l)??0,m=r.get(i)??24;s.push({name:l,x:24+i*368,y:m}),r.set(i,m+fa(t.get(l)??0)+36)}return s},va={databaseSchema:ua},It={backgroundColor:be.shard.color},zt={backgroundColor:be.global.color},ya={global:!0,shard:!0},Na=a=>{const e=a.find(t=>t.pk===!0)?.name;return e!==void 0?e:a.some(t=>t.name==="_id")?"_id":a.some(t=>t.name==="id")?"id":a[0]?.name??"_id"},Et=a=>a.flatMap(e=>e.columns.filter(t=>t.ref!==void 0).map(t=>({column:t.name,from:e.name,to:t.ref}))),wa=(a,e)=>{const t=a.map(l=>l.name),o=new Map(a.map(l=>[l.name,l.columns.length])),r=xa(t,Et(a),o),s=new Map(a.map(l=>[l.name,l]));return r.flatMap(({name:l,x:i,y:m})=>{const d=s.get(l);return d===void 0?[]:[{data:{columns:d.columns,label:l,loadError:e,tier:d.tier},id:l,position:{x:i,y:m},type:"databaseSchema"}]})},Sa=a=>{const e=new Map(a.map(t=>[t.name,t.columns]));return Et(a).flatMap(t=>{const o=e.get(t.to)??[],r=e.get(t.from)??[],s=Na(o);return!o.some(l=>l.name===s)||!r.some(l=>l.name===t.column)?[]:[{id:`${t.from}.${t.column}->${t.to}`,source:t.to,sourceHandle:s,target:t.from,targetHandle:t.column}]})},$a=()=>{const a=Y(15),e=Ue();let t;a[0]===Symbol.for("react.memo_cache_sentinel")?(t=u("span",{className:"flex items-center gap-1",children:[n("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:It}),be.shard.label]}),a[0]=t):t=a[0];let o;a[1]===Symbol.for("react.memo_cache_sentinel")?(o=u("span",{className:"flex items-center gap-1",children:[n("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:zt}),be.global.label]}),a[1]=o):o=a[1];let r;a[2]===Symbol.for("react.memo_cache_sentinel")?(r=n(we,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),a[2]=r):r=a[2];let s;a[3]!==e?(s=e("Primary key"),a[3]=e,a[4]=s):s=a[4];let l;a[5]!==s?(l=u("span",{className:"flex items-center gap-1",children:[r,s]}),a[5]=s,a[6]=l):l=a[6];let i;a[7]===Symbol.for("react.memo_cache_sentinel")?(i=n(we,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),a[7]=i):i=a[7];let m;a[8]!==e?(m=e("Foreign key"),a[8]=e,a[9]=m):m=a[9];let d;a[10]!==m?(d=u("span",{className:"flex items-center gap-1",children:[i,m]}),a[10]=m,a[11]=d):d=a[11];let f;return a[12]!==l||a[13]!==d?(f=u("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-xl border border-border bg-card/95 px-2.5 py-1.5 text-[11px] text-muted-foreground shadow-xs",children:[t,o,l,d]}),a[12]=l,a[13]=d,a[14]=f):f=a[14],f},ka=({containerRef:a,testIdPrefix:e})=>{const t=Ue(),o=ea(),{getEdges:r}=ta(),[s,l]=v(null),i=async()=>{const b=a.current?.querySelector(".react-flow__viewport");if(b){l("png");try{await ha(b,o,`${e}-schema-diagram.png`)}finally{l(null)}}},m=async()=>{const b=a.current?.querySelector(".react-flow__viewport");if(b){l("svg");try{await ga(b,o,`${e}-schema-diagram.svg`)}finally{l(null)}}},d=()=>{l("json");try{pa(o,r(),`${e}-schema-diagram.json`)}finally{l(null)}},f=()=>{M(i())},g=()=>{M(m())};return n(ft,{position:"top-right",children:u(aa,{children:[u(la,{className:"group/button inline-flex shrink-0 cursor-pointer items-center justify-center gap-1 rounded-md border border-border bg-background px-2 text-xs font-medium whitespace-nowrap hover:bg-muted disabled:pointer-events-none disabled:opacity-50","data-testid":`${e}-export-trigger`,disabled:s!==null,children:[n(Dt,{className:"size-3.5",icon:Kt,strokeWidth:2}),t("Export")]}),u(na,{align:"end",children:[n(dt,{"data-testid":`${e}-export-png`,disabled:s!==null,onClick:f,children:t("PNG")}),n(dt,{"data-testid":`${e}-export-svg`,disabled:s!==null,onClick:g,children:t("SVG")}),n(dt,{"data-testid":`${e}-export-json`,disabled:s!==null,onClick:d,children:t("JSON")})]})]})})},Ca=a=>{const e=Y(75),{columnsError:t,tables:o,testIdPrefix:r}=a,s=Ue(),[l,i]=v(ya),[m,d]=v("");let f;if(e[0]!==m||e[1]!==o||e[2]!==l){const k=m.trim().toLowerCase();f=o.filter(X=>l[X.tier]&&X.name.toLowerCase().includes(k)),e[0]=m,e[1]=o,e[2]=l,e[3]=f}else f=e[3];const g=f,b=t??!1;let p;e[4]!==b||e[5]!==g?(p=wa(g,b),e[4]=b,e[5]=g,e[6]=p):p=e[6];const x=p;let C;e[7]!==g?(C=Sa(g),e[7]=g,e[8]=C):C=e[8];const T=C,[ee,_,re]=Vt(x),[R,B,oe]=Wt(T),P=Ct(null);let O,F;e[9]!==x||e[10]!==_?(O=()=>{_(x)},F=[x,_],e[9]=x,e[10]=_,e[11]=O,e[12]=F):(O=e[11],F=e[12]),Ge(O,F);let A,ie;e[13]!==T||e[14]!==B?(A=()=>{B(T)},ie=[T,B],e[13]=T,e[14]=B,e[15]=A,e[16]=ie):(A=e[15],ie=e[16]),Ge(A,ie);let G;e[17]===Symbol.for("react.memo_cache_sentinel")?(G=k=>{d(k.target.value)},e[17]=G):G=e[17];const Se=G;let de;e[18]===Symbol.for("react.memo_cache_sentinel")?(de=()=>{i(Ta)},e[18]=de):de=e[18];const w=de;let ce;e[19]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>{i(_a)},e[19]=ce):ce=e[19];const S=ce;if(o.length===0){const k=`${r}-section`,X=`${r}-empty`;let ne;e[20]!==s?(ne=s("No tables to graph."),e[20]=s,e[21]=ne):ne=e[21];let Z;e[22]!==X||e[23]!==ne?(Z=n("p",{className:"text-sm text-muted-foreground","data-testid":X,children:ne}),e[22]=X,e[23]=ne,e[24]=Z):Z=e[24];let Q;return e[25]!==k||e[26]!==Z?(Q=n("section",{className:"flex flex-col gap-2","data-testid":k,children:Z}),e[25]=k,e[26]=Z,e[27]=Q):Q=e[27],Q}const me=`${r}-section`,te=`${r}-canvas`;let E;e[28]===Symbol.for("react.memo_cache_sentinel")?(E=n(Xt,{}),e[28]=E):E=e[28];let ae;e[29]!==s?(ae=s("Find table…"),e[29]=s,e[30]=ae):ae=e[30];const q=`${r}-find`;let K;e[31]!==s?(K=s("Find table…"),e[31]=s,e[32]=K):K=e[32];let L;e[33]!==m||e[34]!==ae||e[35]!==q||e[36]!==K?(L=n(Ae,{"aria-label":ae,className:"h-7 w-44 text-xs","data-testid":q,onChange:Se,placeholder:K,value:m}),e[33]=m,e[34]=ae,e[35]=q,e[36]=K,e[37]=L):L=e[37];let h;e[38]!==s?(h=s("Storage tiers"),e[38]=s,e[39]=h):h=e[39];const $=`${r}-tier-shard`,xe=l.shard?"default":"outline";let ue;e[40]===Symbol.for("react.memo_cache_sentinel")?(ue=n("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:It}),e[40]=ue):ue=e[40];let D;e[41]!==$||e[42]!==xe||e[43]!==l.shard?(D=u(z,{"aria-pressed":l.shard,className:"gap-1.5","data-testid":$,onClick:w,size:"xs",type:"button",variant:xe,children:[ue,be.shard.label]}),e[41]=$,e[42]=xe,e[43]=l.shard,e[44]=D):D=e[44];const ve=`${r}-tier-global`,ye=l.global?"default":"outline";let pe;e[45]===Symbol.for("react.memo_cache_sentinel")?(pe=n("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:zt}),e[45]=pe):pe=e[45];let j;e[46]!==ve||e[47]!==ye||e[48]!==l.global?(j=u(z,{"aria-pressed":l.global,className:"gap-1.5","data-testid":ve,onClick:S,size:"xs",type:"button",variant:ye,children:[pe,be.global.label]}),e[46]=ve,e[47]=ye,e[48]=l.global,e[49]=j):j=e[49];let H;e[50]!==h||e[51]!==D||e[52]!==j?(H=u("div",{"aria-label":h,className:"flex items-center gap-1.5",role:"group",children:[D,j]}),e[50]=h,e[51]=D,e[52]=j,e[53]=H):H=e[53];let le;e[54]!==L||e[55]!==H?(le=n(ft,{position:"top-left",children:u("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card/95 p-2 shadow-xs",children:[L,H]})}),e[54]=L,e[55]=H,e[56]=le):le=e[56];let $e,he,ge;e[57]===Symbol.for("react.memo_cache_sentinel")?($e=n(ft,{position:"bottom-left",children:n($a,{})}),he=n(Zt,{showInteractive:!1}),ge=n(Qt,{pannable:!0,zoomable:!0}),e[57]=$e,e[58]=he,e[59]=ge):($e=e[57],he=e[58],ge=e[59]);let J;e[60]!==r?(J=n(ka,{containerRef:P,testIdPrefix:r}),e[60]=r,e[61]=J):J=e[61];let V;e[62]!==R||e[63]!==ee||e[64]!==oe||e[65]!==re||e[66]!==le||e[67]!==J?(V=u(Yt,{edges:R,elementsSelectable:!0,fitView:!0,minZoom:.2,nodes:ee,nodesConnectable:!1,nodeTypes:va,onEdgesChange:oe,onNodesChange:re,children:[E,le,$e,he,ge,J]}),e[62]=R,e[63]=ee,e[64]=oe,e[65]=re,e[66]=le,e[67]=J,e[68]=V):V=e[68];let W;e[69]!==te||e[70]!==V?(W=n("div",{className:"h-[560px] w-full overflow-hidden rounded-xl border border-border bg-muted/20 shadow-xs","data-testid":te,ref:P,children:V}),e[69]=te,e[70]=V,e[71]=W):W=e[71];let fe;return e[72]!==me||e[73]!==W?(fe=n("section",{className:"flex flex-col gap-2","data-testid":me,children:W}),e[72]=me,e[73]=W,e[74]=fe):fe=e[74],fe};function Ta(a){return{...a,shard:!a.shard}}function _a(a){return{...a,global:!a.global}}const Ia="/__lunora/schema-edit",za=async a=>{const e=await fetch(Ia,{body:JSON.stringify(a),headers:{"Content-Type":"application/json","X-Lunora-Studio":"1"},method:"POST"}),t=await e.json();return t.needsMigration===!0?{kind:"needs-migration",message:t.message??"This edit needs a migration."}:e.ok&&t.tables!==void 0?{diagnostics:t.diagnostics??[],kind:"ok",tables:t.tables}:{kind:"error",message:t.error??`schema edit failed (${String(e.status)})`}},Ea=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.int64()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],ja="v.string()",Oa=a=>a.split(",").map(e=>e.trim()).filter(e=>e!==""),Fa=({onApplied:a,tableNames:e})=>{const t=Ue(),o=ia(),[r,s]=v(null),[l,i]=v(!1),[m,d]=v(null),[f,g]=v(""),[b,p]=v(""),[x,C]=v(ja),[T,ee]=v(e[0]??""),[_,re]=v(""),[R,B]=v(""),[oe,P]=v(!1),O=()=>{s(null),g(""),p(""),re(""),B(""),P(!1)},F=async h=>{i(!0),d(null);try{const $=await za(h);d($),$.kind==="ok"&&(a($.tables),O())}catch($){d({kind:"error",message:$ instanceof Error?$.message:String($)})}finally{i(!1)}},A=()=>{M(F({kind:"addTable",table:f.trim()}))},ie=()=>{M(F({column:b.trim(),kind:"addOptionalColumn",table:T,validator:x}))},G=()=>{M(F({fields:Oa(R),kind:"addIndex",name:_.trim(),table:T,unique:oe}))},Se=()=>{d(null),s("addTable")},de=()=>{d(null),s("addColumn")},w=()=>{d(null),s("addIndex")},ce=()=>{s("destructive"),d({kind:"needs-migration",message:t("This edit changes stored data and must go through a migration. Review the migration before applying.")})},S=h=>{g(h.target.value)},me=h=>{p(h.target.value)},te=h=>{C(h.target.value)},E=h=>{ee(h.target.value)},ae=h=>{re(h.target.value)},q=h=>{B(h.target.value)},K=h=>{P(h.target.checked)},L=()=>{M(o({to:"/migrations"}))};return u(mt,{"data-testid":"sc-editor",size:"sm",children:[u(ut,{children:[n(pt,{children:t("Edit schema")}),n(ht,{children:t("Adds a table, column, or index to lunora/schema.ts and reruns codegen.")})]}),u(gt,{children:[u("div",{className:"flex flex-wrap gap-2",children:[n(z,{"data-testid":"sc-editor-add-table",onClick:Se,size:"xs",type:"button",variant:r==="addTable"?"default":"outline",children:t("Add table")}),n(z,{"data-testid":"sc-editor-add-column",disabled:e.length===0,onClick:de,size:"xs",type:"button",variant:r==="addColumn"?"default":"outline",children:t("Add column")}),n(z,{"data-testid":"sc-editor-add-index",disabled:e.length===0,onClick:w,size:"xs",type:"button",variant:r==="addIndex"?"default":"outline",children:t("Add index")}),n(z,{"data-testid":"sc-editor-destructive",disabled:e.length===0,onClick:ce,size:"xs",type:"button",variant:r==="destructive"?"default":"ghost",children:t("Rename / drop / change type…")})]}),r==="addTable"&&u("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-table-name",children:t("Table name")}),n(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:S,value:f})]}),n(z,{"data-testid":"sc-editor-table-apply",disabled:l||f.trim()==="",onClick:A,size:"xs",type:"button",children:t(l?"Applying…":"Apply")}),n(z,{onClick:O,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),r==="addColumn"&&u("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-column-table",children:t("Table name")}),n("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:E,value:T,children:e.map(h=>n("option",{value:h,children:h},h))})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-column-name",children:t("Column name")}),n(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:me,value:b})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-column-type",children:t("Column type")}),n("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:te,value:x,children:Ea.map(h=>n("option",{value:h.validator,children:h.label},h.validator))})]}),n("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),n(z,{"data-testid":"sc-editor-column-apply",disabled:l||b.trim()===""||T==="",onClick:ie,size:"xs",type:"button",children:t(l?"Applying…":"Apply")}),n(z,{onClick:O,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),r==="addIndex"&&u("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-index-table",children:t("Table name")}),n("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:E,value:T,children:e.map(h=>n("option",{value:h,children:h},h))})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-index-name",children:t("Index name")}),n(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:ae,value:_})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),n(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:q,value:R})]}),u(Ne,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[n("input",{checked:oe,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:K,type:"checkbox"}),n("span",{className:"text-muted-foreground",children:t("Unique")})]}),n(z,{"data-testid":"sc-editor-index-apply",disabled:l||_.trim()===""||R.trim()==="",onClick:G,size:"xs",type:"button",children:t(l?"Applying…":"Apply")}),n(z,{onClick:O,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),m?.kind==="error"&&n("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:m.message}),m?.kind==="needs-migration"&&u("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[n("p",{className:"text-sm text-warning",role:"alert",children:t("This edit changes stored data and must go through a migration. Review the migration before applying.")}),n(z,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:L,size:"xs",type:"button",variant:"outline",children:t("Open Migrations")})]}),m?.kind==="ok"&&m.diagnostics.length>0&&u("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[n("p",{className:"text-sm text-destructive",role:"alert",children:t("Codegen reported diagnostics:")}),n("ul",{className:"flex flex-col gap-0.5",children:m.diagnostics.map(h=>n("li",{className:"font-mono text-[11px] text-destructive",children:h},h))})]})]})]})},La=at(tt.listTables),Ma=at(tt.listTableIndexes),Ra=at(tt.readTablePage),Pa=at(tt.describeTables),Aa={},wt=[],St=[],qa=a=>{const e=Y(5),{open:t}=a,o=t&&"rotate-90";let r;e[0]!==o?(r=Ke("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",o),e[0]=o,e[1]=r):r=e[1];let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=n("path",{d:"m9 6 6 6-6 6"}),e[2]=s):s=e[2];let l;return e[3]!==r?(l=n("svg",{"aria-hidden":"true",className:r,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:s}),e[3]=r,e[4]=l):l=e[4],l},$t=a=>{const e=Y(20),{children:t,expanded:o,name:r,onToggle:s,rowCount:l,rowTestId:i,toggleTestId:m}=a;let d;e[0]!==o?(d=n(qa,{open:o}),e[0]=o,e[1]=d):d=e[1];let f;e[2]!==r?(f=n("span",{className:"truncate font-mono text-xs text-foreground",title:r,children:r}),e[2]=r,e[3]=f):f=e[3];let g;e[4]!==l?(g=u("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",l,")"]}),e[4]=l,e[5]=g):g=e[5];let b;e[6]!==o||e[7]!==s||e[8]!==d||e[9]!==f||e[10]!==g||e[11]!==m?(b=u("button",{"aria-expanded":o,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":m,onClick:s,type:"button",children:[d,f," ",g]}),e[6]=o,e[7]=s,e[8]=d,e[9]=f,e[10]=g,e[11]=m,e[12]=b):b=e[12];let p;e[13]!==t||e[14]!==o?(p=o&&n("div",{className:"px-3 pb-3 ps-8",children:t}),e[13]=t,e[14]=o,e[15]=p):p=e[15];let x;return e[16]!==i||e[17]!==b||e[18]!==p?(x=u("li",{className:"border-t border-border/60 first:border-t-0","data-testid":i,children:[b,p]}),e[16]=i,e[17]=b,e[18]=p,e[19]=x):x=e[19],x},kt=a=>{const e=Y(5),{columns:t,testId:o}=a;let r;e[0]!==t?(r=t.map(Ba),e[0]=t,e[1]=r):r=e[1];let s;return e[2]!==r||e[3]!==o?(s=n("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":o,children:r}),e[2]=r,e[3]=o,e[4]=s):s=e[4],s},Ua=a=>{const e=Y(10),{heading:t,indexes:o,testId:r}=a;let s;e[0]!==t?(s=n("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:t}),e[0]=t,e[1]=s):s=e[1];let l;e[2]!==o?(l=o.map(Ga),e[2]=o,e[3]=l):l=e[3];let i;e[4]!==l||e[5]!==r?(i=n("ul",{className:"flex flex-col gap-1","data-testid":r,children:l}),e[4]=l,e[5]=r,e[6]=i):i=e[6];let m;return e[7]!==s||e[8]!==i?(m=u("div",{className:"pt-3",children:[s,i]}),e[7]=s,e[8]=i,e[9]=m):m=e[9],m},vl=a=>{const e=Y(126),{initialShardKey:t,initialTable:o,schemaEditable:r}=a,s=At(),l=Ue(),[i,m]=v("list"),[d,f]=v(t??""),[g,b]=v(""),[p,x]=v(null),[C,T]=v(null);let ee;e[0]===Symbol.for("react.memo_cache_sentinel")?(ee={},e[0]=ee):ee=e[0];const[_,re]=v(ee);let R;e[1]===Symbol.for("react.memo_cache_sentinel")?(R={},e[1]=R):R=e[1];const[B,oe]=v(R),[P,O]=v(null);let F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={},e[2]=F):F=e[2];const[A,ie]=v(F);let G;e[3]===Symbol.for("react.memo_cache_sentinel")?(G={},e[3]=G):G=e[3];const[Se,de]=v(G),[w,ce]=v(null),[S,me]=v(null);let te;e[4]===Symbol.for("react.memo_cache_sentinel")?(te={},e[4]=te):te=e[4];const[E,ae]=v(te),[q,K]=v(null);let L;e[5]!==s?(L=async c=>{T(null);try{const y=await s.query(La,{},Qe(c));Gt(c),x(y),re({}),oe({}),O(null),ie(N=>Object.fromEntries(Object.entries(N).filter(U=>{const[I]=U;return I!==c}))),de(N=>Object.fromEntries(Object.entries(N).filter(U=>{const[I]=U;return I!==c})))}catch(y){const N=y;x(null),T(Ye(N))}},e[5]=s,e[6]=L):L=e[6];const h=L;let $;e[7]!==s?($=async()=>{me(null);try{ce(await s.listGlobalTables())}catch(c){const y=c;ce(null),me(Ye(y))}},e[7]=s,e[8]=$):$=e[8];const xe=$;let ue;e[9]!==d?(ue=d.trim(),e[9]=d,e[10]=ue):ue=e[10];const D=Bt(ue,400);let ve,ye;e[11]!==D||e[12]!==h||e[13]!==xe?(ye=()=>{M(h(D)),M(xe())},ve=[h,xe,D],e[11]=D,e[12]=h,e[13]=xe,e[14]=ve,e[15]=ye):(ve=e[14],ye=e[15]),Ge(ye,ve);let pe;e[16]!==s||e[17]!==_||e[18]!==P||e[19]!==d?(pe=async c=>{if(P===c){O(null);return}O(c);const y=`${d}:${c}`;if(_[y]!==void 0)return;const[N,U]=await Promise.allSettled([s.query(Ra,{limit:1,offset:0,table:c},Qe(d)),s.query(Ma,{table:c},Qe(d))]);N.status==="fulfilled"?re(I=>({...I,[y]:N.value.columns})):T(Ye(N.reason)),U.status==="fulfilled"&&oe(I=>({...I,[y]:U.value.indexes}))},e[16]=s,e[17]=_,e[18]=P,e[19]=d,e[20]=pe):pe=e[20];const j=pe;let H;e[21]!==s||e[22]!==E||e[23]!==q?(H=async c=>{if(q===c){K(null);return}if(K(c),E[c]===void 0)try{const y=await s.readGlobalTablePage({limit:1,offset:0,table:c});ae(N=>({...N,[c]:y.columns}))}catch(y){me(Ye(y))}},e[21]=s,e[22]=E,e[23]=q,e[24]=H):H=e[24];const le=H,$e=Ct(void 0);let he,ge;e[25]!==o||e[26]!==p||e[27]!==j?(he=()=>{o===void 0||p===null||$e.current===o||p.some(c=>c.name===o)&&($e.current=o,M(j(o)))},ge=[o,p,j],e[25]=o,e[26]=p,e[27]=j,e[28]=he,e[29]=ge):(he=e[28],ge=e[29]),Ge(he,ge);let J;e[30]!==s?(J=async(c,y,N)=>{const[U,I]=await Promise.all([Promise.allSettled([s.query(Pa,{tables:[...y,...N]},Qe(c))]),Promise.all(N.map(async se=>{const Be=await Promise.allSettled([s.readGlobalTablePage({limit:1,offset:0,table:se})]),xt=Be[0].status==="fulfilled"?Be[0].value:void 0;return{columns:xt?.columns??[],refs:xt?.refs??{},table:se}}))]),Lt=U[0].status==="fulfilled"?U[0].value?.columnsByTable??{}:{},Mt=U[0].status==="rejected",Rt=new Map(I.map(Ka)),Pt=[...y,...N].map(se=>{const Be=Lt[se]??[];return[se,Be.length>0?Be:Rt.get(se)??[]]});ie(se=>({...se,[c]:Object.fromEntries(Pt)})),de(se=>({...se,[c]:Mt}))},e[30]=s,e[31]=J):J=e[31];const V=J;let W,fe;e[32]!==S||e[33]!==w||e[34]!==V||e[35]!==A||e[36]!==d||e[37]!==p||e[38]!==i?(W=()=>{i!=="graph"||p===null||w===null&&S===null||A[d]!==void 0||M(V(d,p.map(Da),(w??[]).map(Ha)))},fe=[i,p,w,S,d,A,V],e[32]=S,e[33]=w,e[34]=V,e[35]=A,e[36]=d,e[37]=p,e[38]=i,e[39]=W,e[40]=fe):(W=e[39],fe=e[40]),Ge(W,fe);const k=A[d]??Aa;let X;if(e[41]!==k||e[42]!==w||e[43]!==p){let c;e[45]!==k?(c=I=>({columns:k[I.name]??St,name:I.name,tier:"shard"}),e[45]=k,e[46]=c):c=e[46];const y=(p??[]).map(c);let N;e[47]!==k?(N=I=>({columns:k[I.name]??St,name:I.name,tier:"global"}),e[47]=k,e[48]=N):N=e[48];const U=(w??[]).map(N);X=[...y,...U],e[41]=k,e[42]=w,e[43]=p,e[44]=X}else X=e[44];const ne=X;let Z;if(e[49]!==g||e[50]!==p){const c=g.trim().toLowerCase();Z=(p??[]).filter(y=>y.name.toLowerCase().includes(c)),e[49]=g,e[50]=p,e[51]=Z}else Z=e[51];const Q=Z;let De;if(e[52]!==w||e[53]!==g){const c=g.trim().toLowerCase();De=(w??[]).filter(y=>y.name.toLowerCase().includes(c)),e[52]=w,e[53]=g,e[54]=De}else De=e[54];const ke=De;let He;e[55]===Symbol.for("react.memo_cache_sentinel")?(He=()=>{m("list")},e[55]=He):He=e[55];const jt=He;let Je;e[56]===Symbol.for("react.memo_cache_sentinel")?(Je=()=>{m("graph")},e[56]=Je):Je=e[56];const Ot=Je;let Ve;e[57]===Symbol.for("react.memo_cache_sentinel")?(Ve=c=>{b(c.target.value)},e[57]=Ve):Ve=e[57];const Ft=Ve;let We;e[58]!==h||e[59]!==d?(We=c=>{M(h(d))},e[58]=h,e[59]=d,e[60]=We):We=e[60];const lt=We;let Ce;e[61]!==p?(Ce=p??[],e[61]=p,e[62]=Ce):Ce=e[62];let Xe;e[63]!==Ce?(Xe=Ce.map(Ja),e[63]=Ce,e[64]=Xe):Xe=e[64];const nt=Xe;let Te;e[65]!==d?(Te=n(qt,{onChange:f,testId:"sc-shard-input",value:d}),e[65]=d,e[66]=Te):Te=e[66];let _e;e[67]!==l?(_e=l("Schema view"),e[67]=l,e[68]=_e):_e=e[68];const st=i==="list",rt=i==="list"?"default":"outline";let Ie;e[69]!==l?(Ie=l("Table list"),e[69]=l,e[70]=Ie):Ie=e[70];let ze;e[71]!==st||e[72]!==rt||e[73]!==Ie?(ze=n(z,{"aria-pressed":st,"data-testid":"sc-view-list",onClick:jt,size:"xs",type:"button",variant:rt,children:Ie}),e[71]=st,e[72]=rt,e[73]=Ie,e[74]=ze):ze=e[74];const ot=i==="graph",it=i==="graph"?"default":"outline";let Ee;e[75]!==l?(Ee=l("Graph"),e[75]=l,e[76]=Ee):Ee=e[76];let je;e[77]!==ot||e[78]!==it||e[79]!==Ee?(je=n(z,{"aria-pressed":ot,"data-testid":"sc-view-graph",onClick:Ot,size:"xs",type:"button",variant:it,children:Ee}),e[77]=ot,e[78]=it,e[79]=Ee,e[80]=je):je=e[80];let Oe;e[81]!==_e||e[82]!==ze||e[83]!==je?(Oe=u("div",{"aria-label":_e,className:"flex gap-1.5","data-testid":"sc-view-toggle",role:"group",children:[ze,je]}),e[81]=_e,e[82]=ze,e[83]=je,e[84]=Oe):Oe=e[84];let Fe;e[85]!==Te||e[86]!==Oe?(Fe=u("div",{className:"flex flex-wrap items-center gap-3",children:[Te,Oe]}),e[85]=Te,e[86]=Oe,e[87]=Fe):Fe=e[87];let Le;e[88]!==lt||e[89]!==r||e[90]!==nt?(Le=r===!0&&n(Fa,{onApplied:lt,tableNames:nt}),e[88]=lt,e[89]=r,e[90]=nt,e[91]=Le):Le=e[91];let Me;e[92]!==l||e[93]!==g||e[94]!==i?(Me=i==="list"&&n(Ae,{"aria-label":l("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Ft,placeholder:l("Filter tables"),value:g}),e[92]=l,e[93]=g,e[94]=i,e[95]=Me):Me=e[95];let Re;e[96]!==ne||e[97]!==C||e[98]!==S||e[99]!==Se||e[100]!==d||e[101]!==i?(Re=i==="graph"&&u("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[C!==null&&n("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:C}),S!==null&&n("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:S}),n(Ca,{columnsError:Se[d]===!0,tables:ne,testIdPrefix:"sc-graph"})]}),e[96]=ne,e[97]=C,e[98]=S,e[99]=Se,e[100]=d,e[101]=i,e[102]=Re):Re=e[102];let Pe;e[103]!==_||e[104]!==C||e[105]!==P||e[106]!==ke||e[107]!==Q||e[108]!==E||e[109]!==S||e[110]!==q||e[111]!==w||e[112]!==B||e[113]!==d||e[114]!==l||e[115]!==p||e[116]!==j||e[117]!==le||e[118]!==i?(Pe=i==="list"&&u("div",{className:"flex flex-col gap-4",children:[u(mt,{"data-testid":"sc-shard-section",size:"sm",children:[u(ut,{children:[u("div",{className:"flex items-center gap-2",children:[n(ct,{tier:"shard"}),n(pt,{children:l("Shard tables")}),p!==null&&n(we,{className:"ms-auto tabular-nums",variant:"outline",children:Q.length})]}),n(ht,{children:be.shard.hint})]}),u(gt,{children:[C!==null&&n("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:C}),p!==null&&p.length===0&&n("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:l("No tables in this shard.")}),p!==null&&p.length>0&&Q.length===0&&n("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:l("No tables match your filter.")}),Q.length>0&&n("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:Q.map(c=>{const y=`${d}:${c.name}`,N=B[y]??[];return u($t,{expanded:P===c.name,name:c.name,onToggle:()=>{M(j(c.name))},rowCount:c.rowCount,rowTestId:`sc-table-${c.name}`,toggleTestId:`sc-toggle-${c.name}`,children:[n(kt,{columns:_[y]??wt,testId:`sc-columns-${c.name}`}),N.length>0&&n(Ua,{heading:l("Indexes"),indexes:N,testId:`sc-indexes-${c.name}`})]},c.name)})})]})]}),u(mt,{"data-testid":"sc-global-section",size:"sm",children:[u(ut,{children:[u("div",{className:"flex items-center gap-2",children:[n(ct,{tier:"global"}),n(pt,{children:l("Global tables (D1)")}),w!==null&&n(we,{className:"ms-auto tabular-nums",variant:"outline",children:ke.length})]}),n(ht,{children:be.global.hint})]}),u(gt,{children:[S!==null&&n("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:S}),w!==null&&w.length===0&&n(Ut,{description:be.global.hint,testId:"sc-global-empty",title:l("No global tables.")}),w!==null&&w.length>0&&ke.length===0&&n("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:l("No tables match your filter.")}),ke.length>0&&n("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:ke.map(c=>n($t,{expanded:q===c.name,name:c.name,onToggle:()=>{M(le(c.name))},rowCount:c.rowCount,rowTestId:`sc-global-table-${c.name}`,toggleTestId:`sc-global-toggle-${c.name}`,children:n(kt,{columns:E[c.name]??wt,testId:`sc-global-columns-${c.name}`})},c.name))})]})]})]}),e[103]=_,e[104]=C,e[105]=P,e[106]=ke,e[107]=Q,e[108]=E,e[109]=S,e[110]=q,e[111]=w,e[112]=B,e[113]=d,e[114]=l,e[115]=p,e[116]=j,e[117]=le,e[118]=i,e[119]=Pe):Pe=e[119];let Ze;return e[120]!==Fe||e[121]!==Le||e[122]!==Me||e[123]!==Re||e[124]!==Pe?(Ze=u("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[Fe,Le,Me,Re,Pe]}),e[120]=Fe,e[121]=Le,e[122]=Me,e[123]=Re,e[124]=Pe,e[125]=Ze):Ze=e[125],Ze};function Ba(a){return n("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:a},a)}function Ga(a){return u("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[n("span",{className:"font-mono",children:a.name}),n(we,{variant:"outline",children:a.type}),a.unique===!0&&n(we,{variant:"secondary",children:"unique"}),n("span",{className:"text-muted-foreground",children:a.fields.join(", ")})]},`${a.type}:${a.name}`)}function Ka(a){const{columns:e,refs:t,table:o}=a;return[o,e.map(r=>{const s=t[r];return s===void 0?{name:r,optional:!1,type:""}:{name:r,optional:!1,ref:s,type:"id"}})]}function Da(a){return a.name}function Ha(a){return a.name}function Ja(a){return a.name}export{vl as SchemaViewer};