@rebasepro/studio 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (378) hide show
  1. package/README.md +73 -140
  2. package/dist/ApiExplorer-CdIwR9Ga.js +963 -0
  3. package/dist/ApiExplorer-CdIwR9Ga.js.map +1 -0
  4. package/dist/AuthSimulationSelector-iEZ-Or_1.js +56 -0
  5. package/dist/AuthSimulationSelector-iEZ-Or_1.js.map +1 -0
  6. package/dist/BranchesView-DncIRcZt.js +461 -0
  7. package/dist/BranchesView-DncIRcZt.js.map +1 -0
  8. package/dist/CronJobsView-4gdtJvoe.js +500 -0
  9. package/dist/CronJobsView-4gdtJvoe.js.map +1 -0
  10. package/dist/JSEditor-BhAbEjCP.js +1573 -0
  11. package/dist/JSEditor-BhAbEjCP.js.map +1 -0
  12. package/dist/LogsExplorer-CqtKILj8.js +240 -0
  13. package/dist/LogsExplorer-CqtKILj8.js.map +1 -0
  14. package/dist/MonacoEditor-COZqrIJ1.js +246 -0
  15. package/dist/MonacoEditor-COZqrIJ1.js.map +1 -0
  16. package/dist/RLSEditor-CTxYbBdW.js +1362 -0
  17. package/dist/RLSEditor-CTxYbBdW.js.map +1 -0
  18. package/dist/SQLEditor-BLuq_zDM.js +1964 -0
  19. package/dist/SQLEditor-BLuq_zDM.js.map +1 -0
  20. package/dist/SchemaVisualizer-BJK2u3C0.js +1068 -0
  21. package/dist/SchemaVisualizer-BJK2u3C0.js.map +1 -0
  22. package/dist/StorageView-nDaC2foF.js +1382 -0
  23. package/dist/StorageView-nDaC2foF.js.map +1 -0
  24. package/dist/{studio/src/components → components}/ApiExplorer/ApiExplorer.d.ts +2 -1
  25. package/dist/{studio/src/components → components}/ApiExplorer/EndpointDetail.d.ts +2 -1
  26. package/dist/{studio/src/components → components}/ApiExplorer/TryItPanel.d.ts +2 -1
  27. package/dist/{studio/src/components → components}/AuthSimulationSelector.d.ts +2 -1
  28. package/dist/components/Branches/BranchesView.d.ts +2 -0
  29. package/dist/components/CronJobs/CronJobsView.d.ts +2 -0
  30. package/dist/components/JSEditor/JSEditor.d.ts +2 -0
  31. package/dist/{studio/src/components → components}/JSEditor/JSEditorSidebar.d.ts +2 -1
  32. package/dist/{studio/src/components → components}/JSEditor/JSMonacoEditor.d.ts +2 -1
  33. package/dist/components/LogsExplorer/LogsExplorer.d.ts +2 -0
  34. package/dist/{studio/src/components → components}/RLSEditor/PolicyEditor.d.ts +2 -1
  35. package/dist/{studio/src/components → components}/RLSEditor/RLSEditor.d.ts +2 -7
  36. package/dist/{studio/src/components → components}/SQLEditor/MonacoEditor.d.ts +2 -1
  37. package/dist/{studio/src/components → components}/SQLEditor/SQLEditor.d.ts +2 -1
  38. package/dist/{studio/src/components → components}/SQLEditor/SQLEditorSidebar.d.ts +2 -1
  39. package/dist/{studio/src/components → components}/SQLEditor/SchemaBrowser.d.ts +2 -1
  40. package/dist/{studio/src/components → components}/SchemaVisualizer/RelationEdge.d.ts +1 -1
  41. package/dist/components/SchemaVisualizer/SchemaVisualizer.d.ts +3 -0
  42. package/dist/{studio/src/components → components}/SchemaVisualizer/TableNode.d.ts +1 -1
  43. package/dist/{studio/src/components → components}/SchemaVisualizer/schema-visualizer.utils.d.ts +0 -8
  44. package/dist/components/StorageView/StorageView.d.ts +2 -0
  45. package/dist/{studio/src/components → components}/StudioHomePage.d.ts +1 -1
  46. package/dist/index.es.js +688 -746
  47. package/dist/index.es.js.map +1 -1
  48. package/dist/index.umd.js +10303 -9572
  49. package/dist/index.umd.js.map +1 -1
  50. package/dist/{studio/src/utils → utils}/pgColumnToProperty.d.ts +1 -1
  51. package/package.json +22 -22
  52. package/src/components/ApiExplorer/TryItPanel.tsx +15 -18
  53. package/src/components/CronJobs/CronJobsView.tsx +1 -1
  54. package/src/components/JSEditor/JSEditor.tsx +10 -15
  55. package/src/components/LogsExplorer/LogsExplorer.tsx +6 -3
  56. package/src/components/RLSEditor/PolicyEditor.tsx +0 -1
  57. package/src/components/RLSEditor/RLSEditor.tsx +1 -1
  58. package/src/components/SQLEditor/SQLEditor.tsx +40 -30
  59. package/src/components/SchemaVisualizer/schema-visualizer.utils.ts +3 -3
  60. package/src/components/SchemaVisualizer/useSchemaGraph.ts +2 -2
  61. package/src/components/StorageView/StorageView.tsx +22 -11
  62. package/src/components/StudioHomePage.tsx +51 -15
  63. package/src/utils/parseSpec.test.ts +41 -20
  64. package/src/utils/pgColumnToProperty.ts +23 -20
  65. package/src/utils/sql_utils.ts +1 -1
  66. package/dist/ApiExplorer-CGHEF1uL.js +0 -1052
  67. package/dist/ApiExplorer-CGHEF1uL.js.map +0 -1
  68. package/dist/AuthSimulationSelector-DGoXkWSg.js +0 -105
  69. package/dist/AuthSimulationSelector-DGoXkWSg.js.map +0 -1
  70. package/dist/BranchesView-BiTEwIhd.js +0 -291
  71. package/dist/BranchesView-BiTEwIhd.js.map +0 -1
  72. package/dist/CronJobsView-3PM_qR8v.js +0 -472
  73. package/dist/CronJobsView-3PM_qR8v.js.map +0 -1
  74. package/dist/JSEditor-BCSoElPg.js +0 -1297
  75. package/dist/JSEditor-BCSoElPg.js.map +0 -1
  76. package/dist/LogsExplorer-_4sZadKn.js +0 -162
  77. package/dist/LogsExplorer-_4sZadKn.js.map +0 -1
  78. package/dist/MonacoEditor-CMYEjiRf.js +0 -161
  79. package/dist/MonacoEditor-CMYEjiRf.js.map +0 -1
  80. package/dist/RLSEditor-CHEExeSB.js +0 -1871
  81. package/dist/RLSEditor-CHEExeSB.js.map +0 -1
  82. package/dist/SQLEditor-BC0IOUQu.js +0 -1797
  83. package/dist/SQLEditor-BC0IOUQu.js.map +0 -1
  84. package/dist/SchemaVisualizer-BGpmzyXT.js +0 -1069
  85. package/dist/SchemaVisualizer-BGpmzyXT.js.map +0 -1
  86. package/dist/StorageView-B7AsN2qX.js +0 -869
  87. package/dist/StorageView-B7AsN2qX.js.map +0 -1
  88. package/dist/common/src/collections/CollectionRegistry.d.ts +0 -56
  89. package/dist/common/src/collections/default-collections.d.ts +0 -9
  90. package/dist/common/src/collections/index.d.ts +0 -2
  91. package/dist/common/src/data/buildRebaseData.d.ts +0 -14
  92. package/dist/common/src/data/query_builder.d.ts +0 -55
  93. package/dist/common/src/index.d.ts +0 -4
  94. package/dist/common/src/util/builders.d.ts +0 -57
  95. package/dist/common/src/util/callbacks.d.ts +0 -6
  96. package/dist/common/src/util/collections.d.ts +0 -11
  97. package/dist/common/src/util/common.d.ts +0 -2
  98. package/dist/common/src/util/conditions.d.ts +0 -26
  99. package/dist/common/src/util/entities.d.ts +0 -58
  100. package/dist/common/src/util/enums.d.ts +0 -3
  101. package/dist/common/src/util/index.d.ts +0 -16
  102. package/dist/common/src/util/navigation_from_path.d.ts +0 -34
  103. package/dist/common/src/util/navigation_utils.d.ts +0 -20
  104. package/dist/common/src/util/parent_references_from_path.d.ts +0 -6
  105. package/dist/common/src/util/paths.d.ts +0 -14
  106. package/dist/common/src/util/permissions.d.ts +0 -6
  107. package/dist/common/src/util/references.d.ts +0 -2
  108. package/dist/common/src/util/relations.d.ts +0 -22
  109. package/dist/common/src/util/resolutions.d.ts +0 -72
  110. package/dist/common/src/util/storage.d.ts +0 -24
  111. package/dist/core/src/components/AIIcon.d.ts +0 -16
  112. package/dist/core/src/components/BootstrapAdminBanner.d.ts +0 -4
  113. package/dist/core/src/components/ConfirmationDialog.d.ts +0 -9
  114. package/dist/core/src/components/Debug/UIReferenceView.d.ts +0 -1
  115. package/dist/core/src/components/Debug/UIStyleGuide.d.ts +0 -1
  116. package/dist/core/src/components/ErrorTooltip.d.ts +0 -2
  117. package/dist/core/src/components/ErrorView.d.ts +0 -21
  118. package/dist/core/src/components/LanguageToggle.d.ts +0 -1
  119. package/dist/core/src/components/LoginView/LoginView.d.ts +0 -109
  120. package/dist/core/src/components/LoginView/index.d.ts +0 -2
  121. package/dist/core/src/components/NotFoundPage.d.ts +0 -1
  122. package/dist/core/src/components/RebaseAuth.d.ts +0 -10
  123. package/dist/core/src/components/RebaseLogo.d.ts +0 -7
  124. package/dist/core/src/components/UnsavedChangesDialog.d.ts +0 -9
  125. package/dist/core/src/components/UserDisplay.d.ts +0 -7
  126. package/dist/core/src/components/UserSelectPopover.d.ts +0 -62
  127. package/dist/core/src/components/UserSettingsView.d.ts +0 -1
  128. package/dist/core/src/components/common/index.d.ts +0 -6
  129. package/dist/core/src/components/common/table_height.d.ts +0 -5
  130. package/dist/core/src/components/common/types.d.ts +0 -66
  131. package/dist/core/src/components/common/useColumnsIds.d.ts +0 -9
  132. package/dist/core/src/components/common/useDataTableController.d.ts +0 -45
  133. package/dist/core/src/components/common/useDebouncedData.d.ts +0 -9
  134. package/dist/core/src/components/common/useScrollRestoration.d.ts +0 -14
  135. package/dist/core/src/components/index.d.ts +0 -17
  136. package/dist/core/src/contexts/AdminModeController.d.ts +0 -4
  137. package/dist/core/src/contexts/AnalyticsContext.d.ts +0 -3
  138. package/dist/core/src/contexts/AuthControllerContext.d.ts +0 -3
  139. package/dist/core/src/contexts/CustomizationControllerContext.d.ts +0 -3
  140. package/dist/core/src/contexts/DataDriverContext.d.ts +0 -3
  141. package/dist/core/src/contexts/DatabaseAdminContext.d.ts +0 -3
  142. package/dist/core/src/contexts/DialogsProvider.d.ts +0 -4
  143. package/dist/core/src/contexts/EffectiveRoleController.d.ts +0 -4
  144. package/dist/core/src/contexts/InternalUserManagementContext.d.ts +0 -3
  145. package/dist/core/src/contexts/ModeController.d.ts +0 -4
  146. package/dist/core/src/contexts/RebaseClientInstanceContext.d.ts +0 -6
  147. package/dist/core/src/contexts/RebaseDataContext.d.ts +0 -3
  148. package/dist/core/src/contexts/SnackbarProvider.d.ts +0 -2
  149. package/dist/core/src/contexts/StorageSourceContext.d.ts +0 -3
  150. package/dist/core/src/contexts/UserConfigurationPersistenceContext.d.ts +0 -3
  151. package/dist/core/src/contexts/index.d.ts +0 -13
  152. package/dist/core/src/core/PluginLifecycleManager.d.ts +0 -17
  153. package/dist/core/src/core/PluginProviderStack.d.ts +0 -21
  154. package/dist/core/src/core/Rebase.d.ts +0 -14
  155. package/dist/core/src/core/RebaseProps.d.ts +0 -147
  156. package/dist/core/src/core/RebaseRouter.d.ts +0 -4
  157. package/dist/core/src/core/RebaseRoutes.d.ts +0 -17
  158. package/dist/core/src/core/index.d.ts +0 -4
  159. package/dist/core/src/hooks/ApiConfigContext.d.ts +0 -24
  160. package/dist/core/src/hooks/data/delete.d.ts +0 -31
  161. package/dist/core/src/hooks/data/save.d.ts +0 -34
  162. package/dist/core/src/hooks/data/useCollectionFetch.d.ts +0 -62
  163. package/dist/core/src/hooks/data/useData.d.ts +0 -13
  164. package/dist/core/src/hooks/data/useDataOrder.d.ts +0 -12
  165. package/dist/core/src/hooks/data/useEntityFetch.d.ts +0 -43
  166. package/dist/core/src/hooks/data/useRelationSelector.d.ts +0 -52
  167. package/dist/core/src/hooks/data/useUserSelector.d.ts +0 -31
  168. package/dist/core/src/hooks/index.d.ts +0 -37
  169. package/dist/core/src/hooks/useAdminModeController.d.ts +0 -19
  170. package/dist/core/src/hooks/useAnalyticsController.d.ts +0 -5
  171. package/dist/core/src/hooks/useAuthController.d.ts +0 -11
  172. package/dist/core/src/hooks/useAuthSubscription.d.ts +0 -2
  173. package/dist/core/src/hooks/useBackendStorageSource.d.ts +0 -30
  174. package/dist/core/src/hooks/useBridgeRegistration.d.ts +0 -18
  175. package/dist/core/src/hooks/useBrowserTitleAndIcon.d.ts +0 -6
  176. package/dist/core/src/hooks/useBuildAdminModeController.d.ts +0 -6
  177. package/dist/core/src/hooks/useBuildEffectiveRoleController.d.ts +0 -8
  178. package/dist/core/src/hooks/useBuildLocalConfigurationPersistence.d.ts +0 -2
  179. package/dist/core/src/hooks/useBuildModeController.d.ts +0 -6
  180. package/dist/core/src/hooks/useClipboard.d.ts +0 -57
  181. package/dist/core/src/hooks/useCollapsedGroups.d.ts +0 -27
  182. package/dist/core/src/hooks/useCustomizationController.d.ts +0 -11
  183. package/dist/core/src/hooks/useDialogsController.d.ts +0 -11
  184. package/dist/core/src/hooks/useEffectiveRoleController.d.ts +0 -7
  185. package/dist/core/src/hooks/useInternalUserManagementController.d.ts +0 -12
  186. package/dist/core/src/hooks/useLargeLayout.d.ts +0 -1
  187. package/dist/core/src/hooks/useModeController.d.ts +0 -19
  188. package/dist/core/src/hooks/usePermissions.d.ts +0 -12
  189. package/dist/core/src/hooks/useRebaseClient.d.ts +0 -5
  190. package/dist/core/src/hooks/useRebaseContext.d.ts +0 -11
  191. package/dist/core/src/hooks/useRebaseRegistry.d.ts +0 -34
  192. package/dist/core/src/hooks/useResolvedComponent.d.ts +0 -47
  193. package/dist/core/src/hooks/useSlot.d.ts +0 -18
  194. package/dist/core/src/hooks/useSnackbarController.d.ts +0 -20
  195. package/dist/core/src/hooks/useStorageSource.d.ts +0 -7
  196. package/dist/core/src/hooks/useStudioBridge.d.ts +0 -91
  197. package/dist/core/src/hooks/useTranslation.d.ts +0 -17
  198. package/dist/core/src/hooks/useUnsavedChangesDialog.d.ts +0 -12
  199. package/dist/core/src/hooks/useUserConfigurationPersistence.d.ts +0 -8
  200. package/dist/core/src/i18n/RebaseI18nProvider.d.ts +0 -33
  201. package/dist/core/src/index.d.ts +0 -15
  202. package/dist/core/src/internal/common.d.ts +0 -3
  203. package/dist/core/src/internal/useRestoreScroll.d.ts +0 -6
  204. package/dist/core/src/locales/de.d.ts +0 -2
  205. package/dist/core/src/locales/en.d.ts +0 -10
  206. package/dist/core/src/locales/es.d.ts +0 -10
  207. package/dist/core/src/locales/fr.d.ts +0 -2
  208. package/dist/core/src/locales/hi.d.ts +0 -2
  209. package/dist/core/src/locales/it.d.ts +0 -2
  210. package/dist/core/src/locales/pt.d.ts +0 -7
  211. package/dist/core/src/util/constants.d.ts +0 -1
  212. package/dist/core/src/util/createFormexStub.d.ts +0 -2
  213. package/dist/core/src/util/entity_cache.d.ts +0 -22
  214. package/dist/core/src/util/enums.d.ts +0 -5
  215. package/dist/core/src/util/icon_list.d.ts +0 -5
  216. package/dist/core/src/util/icons.d.ts +0 -20
  217. package/dist/core/src/util/index.d.ts +0 -8
  218. package/dist/core/src/util/previews.d.ts +0 -4
  219. package/dist/core/src/util/useStorageUploadController.d.ts +0 -38
  220. package/dist/formex/src/Field.d.ts +0 -52
  221. package/dist/formex/src/Formex.d.ts +0 -7
  222. package/dist/formex/src/index.d.ts +0 -5
  223. package/dist/formex/src/types.d.ts +0 -40
  224. package/dist/formex/src/useCreateFormex.d.ts +0 -14
  225. package/dist/formex/src/utils.d.ts +0 -16
  226. package/dist/studio/src/components/Branches/BranchesView.d.ts +0 -1
  227. package/dist/studio/src/components/CronJobs/CronJobsView.d.ts +0 -1
  228. package/dist/studio/src/components/JSEditor/JSEditor.d.ts +0 -1
  229. package/dist/studio/src/components/LogsExplorer/LogsExplorer.d.ts +0 -1
  230. package/dist/studio/src/components/SchemaVisualizer/SchemaVisualizer.d.ts +0 -2
  231. package/dist/studio/src/components/SchemaVisualizer/index.d.ts +0 -5
  232. package/dist/studio/src/components/StorageView/StorageView.d.ts +0 -1
  233. package/dist/studio/src/utils/entities.d.ts +0 -0
  234. package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
  235. package/dist/types/src/controllers/auth.d.ts +0 -104
  236. package/dist/types/src/controllers/client.d.ts +0 -168
  237. package/dist/types/src/controllers/collection_registry.d.ts +0 -46
  238. package/dist/types/src/controllers/customization_controller.d.ts +0 -60
  239. package/dist/types/src/controllers/data.d.ts +0 -207
  240. package/dist/types/src/controllers/data_driver.d.ts +0 -218
  241. package/dist/types/src/controllers/database_admin.d.ts +0 -11
  242. package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
  243. package/dist/types/src/controllers/effective_role.d.ts +0 -4
  244. package/dist/types/src/controllers/email.d.ts +0 -36
  245. package/dist/types/src/controllers/index.d.ts +0 -18
  246. package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
  247. package/dist/types/src/controllers/navigation.d.ts +0 -225
  248. package/dist/types/src/controllers/registry.d.ts +0 -63
  249. package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
  250. package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
  251. package/dist/types/src/controllers/snackbar.d.ts +0 -24
  252. package/dist/types/src/controllers/storage.d.ts +0 -171
  253. package/dist/types/src/index.d.ts +0 -4
  254. package/dist/types/src/rebase_context.d.ts +0 -122
  255. package/dist/types/src/types/auth_adapter.d.ts +0 -301
  256. package/dist/types/src/types/backend.d.ts +0 -536
  257. package/dist/types/src/types/backend_hooks.d.ts +0 -172
  258. package/dist/types/src/types/builders.d.ts +0 -15
  259. package/dist/types/src/types/chips.d.ts +0 -5
  260. package/dist/types/src/types/collections.d.ts +0 -941
  261. package/dist/types/src/types/component_ref.d.ts +0 -47
  262. package/dist/types/src/types/cron.d.ts +0 -102
  263. package/dist/types/src/types/data_source.d.ts +0 -64
  264. package/dist/types/src/types/database_adapter.d.ts +0 -94
  265. package/dist/types/src/types/entities.d.ts +0 -145
  266. package/dist/types/src/types/entity_actions.d.ts +0 -104
  267. package/dist/types/src/types/entity_callbacks.d.ts +0 -173
  268. package/dist/types/src/types/entity_link_builder.d.ts +0 -7
  269. package/dist/types/src/types/entity_overrides.d.ts +0 -10
  270. package/dist/types/src/types/entity_views.d.ts +0 -87
  271. package/dist/types/src/types/export_import.d.ts +0 -21
  272. package/dist/types/src/types/formex.d.ts +0 -40
  273. package/dist/types/src/types/index.d.ts +0 -28
  274. package/dist/types/src/types/locales.d.ts +0 -4
  275. package/dist/types/src/types/modify_collections.d.ts +0 -5
  276. package/dist/types/src/types/plugins.d.ts +0 -282
  277. package/dist/types/src/types/properties.d.ts +0 -1181
  278. package/dist/types/src/types/property_config.d.ts +0 -74
  279. package/dist/types/src/types/relations.d.ts +0 -336
  280. package/dist/types/src/types/slots.d.ts +0 -262
  281. package/dist/types/src/types/translations.d.ts +0 -900
  282. package/dist/types/src/types/user_management_delegate.d.ts +0 -86
  283. package/dist/types/src/types/websockets.d.ts +0 -78
  284. package/dist/types/src/users/index.d.ts +0 -1
  285. package/dist/types/src/users/user.d.ts +0 -50
  286. package/dist/ui/src/components/Alert.d.ts +0 -12
  287. package/dist/ui/src/components/Autocomplete.d.ts +0 -21
  288. package/dist/ui/src/components/Avatar.d.ts +0 -11
  289. package/dist/ui/src/components/Badge.d.ts +0 -8
  290. package/dist/ui/src/components/BooleanSwitch.d.ts +0 -14
  291. package/dist/ui/src/components/BooleanSwitchWithLabel.d.ts +0 -17
  292. package/dist/ui/src/components/Button.d.ts +0 -14
  293. package/dist/ui/src/components/Card.d.ts +0 -8
  294. package/dist/ui/src/components/CenteredView.d.ts +0 -9
  295. package/dist/ui/src/components/Checkbox.d.ts +0 -13
  296. package/dist/ui/src/components/Chip.d.ts +0 -26
  297. package/dist/ui/src/components/CircularProgress.d.ts +0 -5
  298. package/dist/ui/src/components/CircularProgressCenter.d.ts +0 -11
  299. package/dist/ui/src/components/Collapse.d.ts +0 -9
  300. package/dist/ui/src/components/ColorPicker.d.ts +0 -30
  301. package/dist/ui/src/components/Container.d.ts +0 -8
  302. package/dist/ui/src/components/DateTimeField.d.ts +0 -24
  303. package/dist/ui/src/components/DebouncedTextField.d.ts +0 -2
  304. package/dist/ui/src/components/Dialog.d.ts +0 -39
  305. package/dist/ui/src/components/DialogActions.d.ts +0 -7
  306. package/dist/ui/src/components/DialogContent.d.ts +0 -7
  307. package/dist/ui/src/components/DialogTitle.d.ts +0 -10
  308. package/dist/ui/src/components/ErrorBoundary.d.ts +0 -33
  309. package/dist/ui/src/components/ExpandablePanel.d.ts +0 -12
  310. package/dist/ui/src/components/FileUpload.d.ts +0 -23
  311. package/dist/ui/src/components/FilterChip.d.ts +0 -34
  312. package/dist/ui/src/components/IconButton.d.ts +0 -12
  313. package/dist/ui/src/components/InfoLabel.d.ts +0 -5
  314. package/dist/ui/src/components/InputLabel.d.ts +0 -11
  315. package/dist/ui/src/components/Label.d.ts +0 -7
  316. package/dist/ui/src/components/LoadingButton.d.ts +0 -7
  317. package/dist/ui/src/components/Markdown.d.ts +0 -10
  318. package/dist/ui/src/components/Menu.d.ts +0 -23
  319. package/dist/ui/src/components/Menubar.d.ts +0 -80
  320. package/dist/ui/src/components/MultiSelect.d.ts +0 -48
  321. package/dist/ui/src/components/Paper.d.ts +0 -6
  322. package/dist/ui/src/components/Popover.d.ts +0 -24
  323. package/dist/ui/src/components/RadioGroup.d.ts +0 -28
  324. package/dist/ui/src/components/ResizablePanels.d.ts +0 -18
  325. package/dist/ui/src/components/SearchBar.d.ts +0 -26
  326. package/dist/ui/src/components/Select.d.ts +0 -43
  327. package/dist/ui/src/components/Separator.d.ts +0 -5
  328. package/dist/ui/src/components/Sheet.d.ts +0 -22
  329. package/dist/ui/src/components/Skeleton.d.ts +0 -6
  330. package/dist/ui/src/components/Slider.d.ts +0 -21
  331. package/dist/ui/src/components/Table.d.ts +0 -34
  332. package/dist/ui/src/components/Tabs.d.ts +0 -19
  333. package/dist/ui/src/components/TextField.d.ts +0 -58
  334. package/dist/ui/src/components/TextareaAutosize.d.ts +0 -43
  335. package/dist/ui/src/components/ToggleButtonGroup.d.ts +0 -30
  336. package/dist/ui/src/components/Tooltip.d.ts +0 -19
  337. package/dist/ui/src/components/Typography.d.ts +0 -36
  338. package/dist/ui/src/components/VirtualTable/VirtualTable.d.ts +0 -11
  339. package/dist/ui/src/components/VirtualTable/VirtualTableCell.d.ts +0 -21
  340. package/dist/ui/src/components/VirtualTable/VirtualTableHeader.d.ts +0 -29
  341. package/dist/ui/src/components/VirtualTable/VirtualTableHeaderRow.d.ts +0 -2
  342. package/dist/ui/src/components/VirtualTable/VirtualTableProps.d.ts +0 -249
  343. package/dist/ui/src/components/VirtualTable/VirtualTableRow.d.ts +0 -3
  344. package/dist/ui/src/components/VirtualTable/index.d.ts +0 -3
  345. package/dist/ui/src/components/VirtualTable/types.d.ts +0 -38
  346. package/dist/ui/src/components/common/SelectInputLabel.d.ts +0 -5
  347. package/dist/ui/src/components/index.d.ts +0 -58
  348. package/dist/ui/src/hooks/PortalContainerContext.d.ts +0 -31
  349. package/dist/ui/src/hooks/index.d.ts +0 -6
  350. package/dist/ui/src/hooks/useDebounceCallback.d.ts +0 -1
  351. package/dist/ui/src/hooks/useDebounceValue.d.ts +0 -1
  352. package/dist/ui/src/hooks/useDebouncedCallback.d.ts +0 -1
  353. package/dist/ui/src/hooks/useInjectStyles.d.ts +0 -7
  354. package/dist/ui/src/hooks/useOutsideAlerter.d.ts +0 -5
  355. package/dist/ui/src/icons/GitHubIcon.d.ts +0 -2
  356. package/dist/ui/src/icons/HandleIcon.d.ts +0 -1
  357. package/dist/ui/src/icons/Icon.d.ts +0 -20
  358. package/dist/ui/src/icons/cool_icon_keys.d.ts +0 -1
  359. package/dist/ui/src/icons/icon_keys.d.ts +0 -1
  360. package/dist/ui/src/icons/index.d.ts +0 -8
  361. package/dist/ui/src/index.d.ts +0 -5
  362. package/dist/ui/src/styles.d.ts +0 -12
  363. package/dist/ui/src/util/chip_colors.d.ts +0 -4
  364. package/dist/ui/src/util/cls.d.ts +0 -2
  365. package/dist/ui/src/util/debounce.d.ts +0 -10
  366. package/dist/ui/src/util/hash.d.ts +0 -1
  367. package/dist/ui/src/util/index.d.ts +0 -4
  368. package/dist/ui/src/util/key_to_icon_component.d.ts +0 -1
  369. package/src/components/SchemaVisualizer/index.ts +0 -5
  370. package/src/utils/entities.ts +0 -2
  371. /package/dist/{studio/src/components → components}/ApiExplorer/parseSpec.d.ts +0 -0
  372. /package/dist/{studio/src/components → components}/ApiExplorer/types.d.ts +0 -0
  373. /package/dist/{studio/src/components → components}/RLSEditor/index.d.ts +0 -0
  374. /package/dist/{studio/src/components → components}/RebaseStudio.d.ts +0 -0
  375. /package/dist/{studio/src/components → components}/SQLEditor/ExplainVisualizer.d.ts +0 -0
  376. /package/dist/{studio/src/components → components}/SchemaVisualizer/useSchemaGraph.d.ts +0 -0
  377. /package/dist/{studio/src/index.d.ts → index.d.ts} +0 -0
  378. /package/dist/{studio/src/utils → utils}/sql_utils.d.ts +0 -0
@@ -0,0 +1,1068 @@
1
+ import { IconForView, useStudioCollectionRegistry } from "@rebasepro/core";
2
+ import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
3
+ import { Button, Chip, CircularProgress, IconButton, ResizablePanels, SearchBar, Tooltip, Typography, cls, defaultBorderMixin } from "@rebasepro/ui";
4
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ import { isPostgresCollection } from "@rebasepro/types";
6
+ import { Background, BackgroundVariant, BaseEdge, Controls, EdgeLabelRenderer, Handle, MarkerType, MiniMap, Position, ReactFlow, ReactFlowProvider, applyEdgeChanges, applyNodeChanges, getSmoothStepPath, useReactFlow } from "@xyflow/react";
7
+ import "@xyflow/react/dist/style.css";
8
+ import { resolveCollectionRelations } from "@rebasepro/common";
9
+ import dagre from "dagre";
10
+ /** Header with a single line of text (junction tables or tableName === collectionName). */
11
+ var HEADER_HEIGHT_SINGLE = 33;
12
+ /** Header with two lines (name + subtitle when collectionName !== tableName). */
13
+ var HEADER_HEIGHT_DOUBLE = 47;
14
+ var ROW_HEIGHT = 28;
15
+ /**
16
+ * Compute the correct header height for a table node.
17
+ */
18
+ var getHeaderHeight = (opts) => {
19
+ if (opts.isJunction) return HEADER_HEIGHT_SINGLE;
20
+ return opts.collectionName !== opts.tableName ? HEADER_HEIGHT_DOUBLE : HEADER_HEIGHT_SINGLE;
21
+ };
22
+ /**
23
+ * Estimate the pixel height of a table node based on column count.
24
+ */
25
+ var estimateNodeHeight = (columnCount, headerHeight = HEADER_HEIGHT_DOUBLE) => headerHeight + Math.max(columnCount, 1) * ROW_HEIGHT + 4;
26
+ /**
27
+ * Get the vertical center Y of a specific column row (0-indexed)
28
+ * relative to the top of the node.
29
+ */
30
+ var getColumnRowY = (rowIndex, headerHeight = HEADER_HEIGHT_DOUBLE) => headerHeight + rowIndex * ROW_HEIGHT + ROW_HEIGHT / 2;
31
+ /**
32
+ * Compute node positions using the dagre graph layout engine.
33
+ * Returns a new array of nodes with updated `position`.
34
+ */
35
+ var getLayoutedElements = (nodes, edges, direction = "LR") => {
36
+ const g = new dagre.graphlib.Graph();
37
+ g.setGraph({
38
+ rankdir: direction,
39
+ nodesep: 100,
40
+ ranksep: 180,
41
+ edgesep: 60,
42
+ marginx: 60,
43
+ marginy: 60
44
+ });
45
+ g.setDefaultEdgeLabel(() => ({}));
46
+ const nodeHeights = /* @__PURE__ */ new Map();
47
+ nodes.forEach((node) => {
48
+ const data = node.data;
49
+ const h = estimateNodeHeight(data.columns?.length ?? 3, getHeaderHeight({
50
+ isJunction: Boolean(data.isJunction),
51
+ collectionName: data.collectionName ?? "",
52
+ tableName: data.tableName ?? ""
53
+ }));
54
+ nodeHeights.set(node.id, h);
55
+ g.setNode(node.id, {
56
+ width: 280,
57
+ height: h
58
+ });
59
+ });
60
+ edges.forEach((edge) => {
61
+ g.setEdge(edge.source, edge.target);
62
+ });
63
+ dagre.layout(g);
64
+ return {
65
+ nodes: nodes.map((node) => {
66
+ const nodeWithPosition = g.node(node.id);
67
+ const h = nodeHeights.get(node.id) ?? estimateNodeHeight(3);
68
+ return {
69
+ ...node,
70
+ data: {
71
+ ...node.data,
72
+ layoutDirection: direction
73
+ },
74
+ position: {
75
+ x: nodeWithPosition.x - 280 / 2,
76
+ y: nodeWithPosition.y - h / 2
77
+ }
78
+ };
79
+ }),
80
+ edges
81
+ };
82
+ };
83
+ var TYPE_LABELS = {
84
+ string: "varchar",
85
+ number: "integer",
86
+ boolean: "boolean",
87
+ date: "timestamp",
88
+ map: "jsonb",
89
+ array: "jsonb",
90
+ relation: "FK"
91
+ };
92
+ var getTypeLabel = (type) => TYPE_LABELS[type] ?? type;
93
+ var getCardinalityLabel = (cardinality, direction) => {
94
+ if (cardinality === "many") return "M:N";
95
+ if (direction === "inverse") return "1:1 ←";
96
+ return "N:1";
97
+ };
98
+ //#endregion
99
+ //#region src/components/SchemaVisualizer/useSchemaGraph.ts
100
+ var extractColumns = (collection) => {
101
+ const columns = [];
102
+ const properties = collection.properties ?? {};
103
+ for (const [propName, prop] of Object.entries(properties)) {
104
+ if (prop.type === "relation") continue;
105
+ const isPk = "isId" in prop && Boolean(prop.isId) || !Object.values(properties).some((p) => "isId" in p && Boolean(p.isId)) && propName === "id";
106
+ const isEnum = prop.type === "string" && "enum" in prop && Boolean(prop.enum);
107
+ let enumValues;
108
+ if (isEnum && "enum" in prop && prop.enum) {
109
+ const enumProp = prop.enum;
110
+ if (Array.isArray(enumProp)) enumValues = enumProp.map((v) => typeof v === "string" ? v : String(v?.id ?? v));
111
+ else if (typeof enumProp === "object" && enumProp !== null) enumValues = Object.keys(enumProp);
112
+ }
113
+ columns.push({
114
+ name: propName,
115
+ type: prop.type,
116
+ typeLabel: getTypeLabel(prop.type),
117
+ isPrimaryKey: isPk,
118
+ isForeignKey: false,
119
+ isRequired: Boolean(prop.validation?.required),
120
+ isEnum,
121
+ enumValues
122
+ });
123
+ }
124
+ if (isPostgresCollection(collection)) try {
125
+ const resolvedRelations = resolveCollectionRelations(collection);
126
+ for (const rel of Object.values(resolvedRelations)) if (rel.direction === "owning" && rel.cardinality === "one" && rel.localKey) if (!columns.some((c) => c.name === rel.localKey)) columns.push({
127
+ name: rel.localKey,
128
+ type: "number",
129
+ typeLabel: "FK",
130
+ isPrimaryKey: false,
131
+ isForeignKey: true,
132
+ isRequired: false,
133
+ isEnum: false,
134
+ relationName: rel.relationName
135
+ });
136
+ else {
137
+ const existing = columns.find((c) => c.name === rel.localKey);
138
+ if (existing) {
139
+ existing.isForeignKey = true;
140
+ existing.relationName = rel.relationName;
141
+ }
142
+ }
143
+ } catch {}
144
+ return columns;
145
+ };
146
+ var buildGraph = (collections, direction) => {
147
+ const nodes = [];
148
+ const edges = [];
149
+ const tableToNodeId = /* @__PURE__ */ new Map();
150
+ const nodeColumns = /* @__PURE__ */ new Map();
151
+ const getPkHandle = (nodeId) => {
152
+ const pk = nodeColumns.get(nodeId)?.find((c) => c.isPrimaryKey);
153
+ return pk ? `target-${pk.name}` : "target-default";
154
+ };
155
+ const getFkHandle = (nodeId, localKey) => {
156
+ if (!localKey) return "source-default";
157
+ const fk = nodeColumns.get(nodeId)?.find((c) => c.name === localKey);
158
+ return fk ? `source-${fk.name}` : "source-default";
159
+ };
160
+ for (const collection of collections) {
161
+ if (!isPostgresCollection(collection)) continue;
162
+ const tableName = collection.table ?? collection.slug;
163
+ const nodeId = `table-${tableName}`;
164
+ tableToNodeId.set(tableName, nodeId);
165
+ const columns = extractColumns(collection);
166
+ nodeColumns.set(nodeId, columns);
167
+ const nodeData = {
168
+ tableName,
169
+ collectionName: collection.name,
170
+ slug: collection.slug,
171
+ columns,
172
+ isJunction: false,
173
+ isUnmanaged: false,
174
+ rlsEnabled: Boolean(collection.securityRules && collection.securityRules.length > 0),
175
+ historyEnabled: Boolean(collection.history),
176
+ icon: typeof collection.icon === "string" ? collection.icon : void 0
177
+ };
178
+ nodes.push({
179
+ id: nodeId,
180
+ type: "tableNode",
181
+ position: {
182
+ x: 0,
183
+ y: 0
184
+ },
185
+ data: nodeData
186
+ });
187
+ }
188
+ const processedJunctions = /* @__PURE__ */ new Set();
189
+ for (const collection of collections) {
190
+ if (!isPostgresCollection(collection)) continue;
191
+ const tableName = collection.table ?? collection.slug;
192
+ const sourceNodeId = tableToNodeId.get(tableName);
193
+ if (!sourceNodeId) continue;
194
+ let resolvedRelations;
195
+ try {
196
+ resolvedRelations = resolveCollectionRelations(collection);
197
+ } catch {
198
+ continue;
199
+ }
200
+ for (const [relationKey, rel] of Object.entries(resolvedRelations)) {
201
+ let targetCollection;
202
+ try {
203
+ targetCollection = rel.target();
204
+ } catch {
205
+ continue;
206
+ }
207
+ if (!isPostgresCollection(targetCollection)) continue;
208
+ const targetTable = targetCollection.table ?? targetCollection.slug;
209
+ const targetNodeId = tableToNodeId.get(targetTable);
210
+ if (!targetNodeId) continue;
211
+ if (rel.direction === "inverse") continue;
212
+ const edgeData = {
213
+ cardinality: rel.cardinality,
214
+ direction: rel.direction ?? "owning",
215
+ relationName: rel.relationName ?? relationKey,
216
+ hasJunction: Boolean(rel.through),
217
+ hasJoinPath: Boolean(rel.joinPath),
218
+ label: getCardinalityLabel(rel.cardinality, rel.direction ?? "owning")
219
+ };
220
+ if (rel.through && !processedJunctions.has(rel.through.table)) {
221
+ processedJunctions.add(rel.through.table);
222
+ const junctionNodeId = `junction-${rel.through.table}`;
223
+ const junctionColumns = [{
224
+ name: rel.through.sourceColumn,
225
+ type: "number",
226
+ typeLabel: "FK",
227
+ isPrimaryKey: true,
228
+ isForeignKey: true,
229
+ isRequired: true,
230
+ isEnum: false
231
+ }, {
232
+ name: rel.through.targetColumn,
233
+ type: "number",
234
+ typeLabel: "FK",
235
+ isPrimaryKey: true,
236
+ isForeignKey: true,
237
+ isRequired: true,
238
+ isEnum: false
239
+ }];
240
+ nodeColumns.set(junctionNodeId, junctionColumns);
241
+ nodes.push({
242
+ id: junctionNodeId,
243
+ type: "tableNode",
244
+ position: {
245
+ x: 0,
246
+ y: 0
247
+ },
248
+ data: {
249
+ tableName: rel.through.table,
250
+ collectionName: rel.through.table,
251
+ slug: rel.through.table,
252
+ columns: junctionColumns,
253
+ isJunction: true,
254
+ isUnmanaged: false,
255
+ rlsEnabled: false,
256
+ historyEnabled: false
257
+ }
258
+ });
259
+ const sourcePk = nodeColumns.get(sourceNodeId)?.find((c) => c.isPrimaryKey);
260
+ edges.push({
261
+ id: `edge-${sourceNodeId}-${junctionNodeId}`,
262
+ source: sourceNodeId,
263
+ target: junctionNodeId,
264
+ sourceHandle: sourcePk ? `source-${sourcePk.name}` : "source-default",
265
+ targetHandle: `target-${rel.through.sourceColumn}`,
266
+ type: "relationEdge",
267
+ data: {
268
+ ...edgeData,
269
+ label: "1:N"
270
+ },
271
+ markerEnd: {
272
+ type: MarkerType.ArrowClosed,
273
+ width: 16,
274
+ height: 16
275
+ }
276
+ });
277
+ edges.push({
278
+ id: `edge-${junctionNodeId}-${targetNodeId}`,
279
+ source: junctionNodeId,
280
+ target: targetNodeId,
281
+ sourceHandle: `source-${rel.through.targetColumn}`,
282
+ targetHandle: getPkHandle(targetNodeId),
283
+ type: "relationEdge",
284
+ data: {
285
+ ...edgeData,
286
+ label: "N:1"
287
+ },
288
+ markerEnd: {
289
+ type: MarkerType.ArrowClosed,
290
+ width: 16,
291
+ height: 16
292
+ }
293
+ });
294
+ } else if (!rel.through) edges.push({
295
+ id: `edge-${sourceNodeId}-${targetNodeId}-${relationKey}`,
296
+ source: sourceNodeId,
297
+ target: targetNodeId,
298
+ sourceHandle: getFkHandle(sourceNodeId, rel.localKey),
299
+ targetHandle: getPkHandle(targetNodeId),
300
+ type: "relationEdge",
301
+ data: { ...edgeData },
302
+ markerEnd: {
303
+ type: MarkerType.ArrowClosed,
304
+ width: 16,
305
+ height: 16
306
+ }
307
+ });
308
+ }
309
+ }
310
+ const layoutResult = getLayoutedElements(nodes, edges, direction);
311
+ const nodePositions = /* @__PURE__ */ new Map();
312
+ for (const node of layoutResult.nodes) nodePositions.set(node.id, { x: node.position.x });
313
+ for (const edge of layoutResult.edges) {
314
+ const srcPos = nodePositions.get(edge.source);
315
+ const tgtPos = nodePositions.get(edge.target);
316
+ const srcBaseHandle = edge.sourceHandle ?? "source-default";
317
+ const tgtBaseHandle = edge.targetHandle ?? "target-default";
318
+ if (srcPos && tgtPos) {
319
+ const sourceIsLeft = srcPos.x + 280 / 2 <= tgtPos.x + 280 / 2;
320
+ edge.sourceHandle = `${srcBaseHandle}-${sourceIsLeft ? "right" : "left"}`;
321
+ edge.targetHandle = `${tgtBaseHandle}-${sourceIsLeft ? "left" : "right"}`;
322
+ } else {
323
+ edge.sourceHandle = `${srcBaseHandle}-right`;
324
+ edge.targetHandle = `${tgtBaseHandle}-left`;
325
+ }
326
+ }
327
+ return layoutResult;
328
+ };
329
+ var useSchemaGraph = (collections) => {
330
+ const [direction, setDirection] = useState("LR");
331
+ const [version, setVersion] = useState(0);
332
+ const relayout = useCallback(() => setVersion((v) => v + 1), []);
333
+ useEffect(() => {
334
+ setVersion((v) => v + 1);
335
+ }, [direction]);
336
+ const { nodes, edges, tableCount, relationCount } = useMemo(() => {
337
+ if (!collections || collections.length === 0) return {
338
+ nodes: [],
339
+ edges: [],
340
+ tableCount: 0,
341
+ relationCount: 0
342
+ };
343
+ const result = buildGraph(collections, direction);
344
+ return {
345
+ ...result,
346
+ tableCount: result.nodes.length,
347
+ relationCount: result.edges.length
348
+ };
349
+ }, [
350
+ collections,
351
+ direction,
352
+ version
353
+ ]);
354
+ return {
355
+ nodes,
356
+ edges,
357
+ direction,
358
+ setDirection,
359
+ relayout,
360
+ isLoading: !collections,
361
+ tableCount,
362
+ relationCount
363
+ };
364
+ };
365
+ //#endregion
366
+ //#region src/components/SchemaVisualizer/TableNode.tsx
367
+ /**
368
+ * Custom React Flow node that renders a database table as a card.
369
+ *
370
+ * Every PK and FK column renders handles on BOTH Left and Right sides.
371
+ * The edge builder picks which side to use based on relative node position.
372
+ */
373
+ var TableNodeInner = ({ data, selected }) => {
374
+ const { tableName, collectionName, columns, isJunction, rlsEnabled, historyEnabled, icon } = data;
375
+ const handles = useMemo(() => {
376
+ const result = [];
377
+ const cols = columns;
378
+ const headerH = getHeaderHeight({
379
+ isJunction: Boolean(isJunction),
380
+ collectionName,
381
+ tableName
382
+ });
383
+ const midY = cols.length > 0 ? getColumnRowY(Math.floor(cols.length / 2), headerH) : 30;
384
+ cols.forEach((col, idx) => {
385
+ const y = getColumnRowY(idx, headerH);
386
+ if (col.isForeignKey && !col.isPrimaryKey) {
387
+ result.push({
388
+ id: `source-${col.name}-right`,
389
+ type: "source",
390
+ position: Position.Right,
391
+ top: y
392
+ });
393
+ result.push({
394
+ id: `source-${col.name}-left`,
395
+ type: "source",
396
+ position: Position.Left,
397
+ top: y
398
+ });
399
+ }
400
+ if (col.isPrimaryKey) {
401
+ result.push({
402
+ id: `target-${col.name}-right`,
403
+ type: "target",
404
+ position: Position.Right,
405
+ top: y
406
+ });
407
+ result.push({
408
+ id: `target-${col.name}-left`,
409
+ type: "target",
410
+ position: Position.Left,
411
+ top: y
412
+ });
413
+ result.push({
414
+ id: `source-${col.name}-right`,
415
+ type: "source",
416
+ position: Position.Right,
417
+ top: y
418
+ });
419
+ result.push({
420
+ id: `source-${col.name}-left`,
421
+ type: "source",
422
+ position: Position.Left,
423
+ top: y
424
+ });
425
+ }
426
+ });
427
+ result.push({
428
+ id: "target-default-right",
429
+ type: "target",
430
+ position: Position.Right,
431
+ top: midY
432
+ });
433
+ result.push({
434
+ id: "target-default-left",
435
+ type: "target",
436
+ position: Position.Left,
437
+ top: midY
438
+ });
439
+ result.push({
440
+ id: "source-default-right",
441
+ type: "source",
442
+ position: Position.Right,
443
+ top: midY
444
+ });
445
+ result.push({
446
+ id: "source-default-left",
447
+ type: "source",
448
+ position: Position.Left,
449
+ top: midY
450
+ });
451
+ return result;
452
+ }, [
453
+ columns,
454
+ isJunction,
455
+ collectionName,
456
+ tableName
457
+ ]);
458
+ return /* @__PURE__ */ jsxs("div", {
459
+ className: cls("relative rounded-lg border bg-white dark:bg-surface-900 shadow-sm transition-all duration-200 min-w-[240px] max-w-[320px]", selected ? "border-primary ring-2 ring-primary/20 shadow-md" : "border-surface-200/40 dark:border-surface-700/40 hover:shadow-md hover:border-surface-300 dark:hover:border-surface-600", isJunction && "border-dashed"),
460
+ children: [
461
+ /* @__PURE__ */ jsxs("div", {
462
+ className: cls("flex items-center gap-2 px-3 py-2 border-b rounded-t-lg", isJunction ? "bg-surface-50 dark:bg-surface-950/50 border-surface-200/30 dark:border-surface-700/30" : "bg-surface-50 dark:bg-surface-950 border-surface-200/40 dark:border-surface-700/40"),
463
+ children: [
464
+ icon && !isJunction && /* @__PURE__ */ jsx("div", {
465
+ className: "text-primary shrink-0",
466
+ children: /* @__PURE__ */ jsx(IconForView, {
467
+ collectionOrView: {
468
+ slug: tableName,
469
+ name: collectionName,
470
+ icon
471
+ },
472
+ size: "smallest"
473
+ })
474
+ }),
475
+ isJunction && /* @__PURE__ */ jsx("svg", {
476
+ className: "w-3.5 h-3.5 text-text-disabled dark:text-text-disabled-dark shrink-0",
477
+ fill: "none",
478
+ stroke: "currentColor",
479
+ viewBox: "0 0 24 24",
480
+ children: /* @__PURE__ */ jsx("path", {
481
+ strokeLinecap: "round",
482
+ strokeLinejoin: "round",
483
+ strokeWidth: 2,
484
+ d: "M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"
485
+ })
486
+ }),
487
+ /* @__PURE__ */ jsxs("div", {
488
+ className: "flex flex-col min-w-0",
489
+ children: [/* @__PURE__ */ jsx(Typography, {
490
+ variant: "caption",
491
+ className: cls("font-semibold truncate text-[12px]", isJunction ? "text-text-secondary dark:text-text-secondary-dark" : "text-text-primary dark:text-text-primary-dark"),
492
+ children: tableName
493
+ }), collectionName !== tableName && !isJunction && /* @__PURE__ */ jsx(Typography, {
494
+ variant: "caption",
495
+ className: "text-[10px] text-text-disabled dark:text-text-disabled-dark truncate",
496
+ children: collectionName
497
+ })]
498
+ }),
499
+ /* @__PURE__ */ jsxs("div", {
500
+ className: "ml-auto flex items-center gap-1 shrink-0",
501
+ children: [rlsEnabled && /* @__PURE__ */ jsx(Tooltip, {
502
+ title: "RLS enabled",
503
+ children: /* @__PURE__ */ jsx("div", { className: "w-1.5 h-1.5 rounded-full bg-green-500" })
504
+ }), historyEnabled && /* @__PURE__ */ jsx(Tooltip, {
505
+ title: "History enabled",
506
+ children: /* @__PURE__ */ jsx("div", { className: "w-1.5 h-1.5 rounded-full bg-blue-400" })
507
+ })]
508
+ })
509
+ ]
510
+ }),
511
+ /* @__PURE__ */ jsx("div", {
512
+ className: "divide-y divide-surface-100 dark:divide-surface-950/60",
513
+ children: columns.map((col) => /* @__PURE__ */ jsxs("div", {
514
+ className: cls("flex items-center gap-2 px-3 py-1.5 text-xs transition-colors", col.isPrimaryKey && "bg-amber-50/50 dark:bg-amber-950/10", col.isForeignKey && !col.isPrimaryKey && "bg-blue-50/40 dark:bg-blue-950/10"),
515
+ children: [
516
+ /* @__PURE__ */ jsxs("span", {
517
+ className: "w-3 shrink-0 text-center",
518
+ children: [col.isPrimaryKey && /* @__PURE__ */ jsx(Tooltip, {
519
+ title: "Primary Key",
520
+ children: /* @__PURE__ */ jsx("span", {
521
+ className: "text-amber-500 text-[10px] font-bold",
522
+ children: "🔑"
523
+ })
524
+ }), col.isForeignKey && !col.isPrimaryKey && /* @__PURE__ */ jsx(Tooltip, {
525
+ title: `FK → ${col.relationName ?? "?"}`,
526
+ children: /* @__PURE__ */ jsx("span", {
527
+ className: "text-blue-400 text-[10px] font-bold",
528
+ children: "🔗"
529
+ })
530
+ })]
531
+ }),
532
+ /* @__PURE__ */ jsx(Typography, {
533
+ variant: "caption",
534
+ className: cls("font-mono text-[11px] truncate flex-1 min-w-0", col.isPrimaryKey ? "font-semibold text-amber-700 dark:text-amber-400" : col.isForeignKey ? "text-blue-600 dark:text-blue-400" : "text-text-primary dark:text-text-primary-dark"),
535
+ children: col.name
536
+ }),
537
+ col.isEnum ? /* @__PURE__ */ jsx(Chip, {
538
+ size: "smallest",
539
+ className: "bg-violet-100 text-violet-700 dark:bg-violet-900/30 dark:text-violet-400 border-violet-200 dark:border-violet-800 text-[9px] py-0",
540
+ children: "enum"
541
+ }) : /* @__PURE__ */ jsx(Typography, {
542
+ variant: "caption",
543
+ className: "text-[10px] text-text-disabled dark:text-text-disabled-dark font-mono shrink-0",
544
+ children: col.typeLabel
545
+ }),
546
+ col.isRequired && !col.isPrimaryKey && /* @__PURE__ */ jsx(Tooltip, {
547
+ title: "Required",
548
+ children: /* @__PURE__ */ jsx("span", {
549
+ className: "text-red-400 text-[9px]",
550
+ children: "•"
551
+ })
552
+ })
553
+ ]
554
+ }, col.name))
555
+ }),
556
+ handles.map((h) => /* @__PURE__ */ jsx(Handle, {
557
+ id: h.id,
558
+ type: h.type,
559
+ position: h.position,
560
+ style: { top: h.top },
561
+ className: cls("!w-2 !h-2 !border-2 !border-white dark:!border-surface-900", h.type === "source" ? "!bg-blue-400" : "!bg-amber-400")
562
+ }, h.id))
563
+ ]
564
+ });
565
+ };
566
+ var TableNode = memo(TableNodeInner);
567
+ //#endregion
568
+ //#region src/components/SchemaVisualizer/RelationEdge.tsx
569
+ /**
570
+ * Custom React Flow edge that renders relations with style variations
571
+ * based on cardinality and direction.
572
+ *
573
+ * - Owning one-to-one: solid, primary color
574
+ * - Many-to-many (junction): solid, violet
575
+ * - Inverse: dashed, muted
576
+ * - Join path: dotted, muted
577
+ */
578
+ var RelationEdgeInner = ({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, data, selected }) => {
579
+ const edgeData = data;
580
+ const [edgePath, labelX, labelY] = getSmoothStepPath({
581
+ sourceX,
582
+ sourceY,
583
+ sourcePosition,
584
+ targetX,
585
+ targetY,
586
+ targetPosition,
587
+ borderRadius: 8
588
+ });
589
+ const isInverse = edgeData?.direction === "inverse";
590
+ const isJoinPath = edgeData?.hasJoinPath;
591
+ const isJunction = edgeData?.hasJunction;
592
+ let strokeColor = "var(--rf-edge-stroke, #94a3b8)";
593
+ let strokeDasharray;
594
+ let strokeWidth = 1.5;
595
+ if (selected) {
596
+ strokeColor = "var(--rf-edge-stroke-selected, #6366f1)";
597
+ strokeWidth = 2.5;
598
+ } else if (isJunction) strokeColor = "#8b5cf6";
599
+ else if (isInverse) {
600
+ strokeDasharray = "6 3";
601
+ strokeColor = "#94a3b8";
602
+ } else if (isJoinPath) {
603
+ strokeDasharray = "3 3";
604
+ strokeColor = "#94a3b8";
605
+ } else strokeColor = "#6366f1";
606
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(BaseEdge, {
607
+ id,
608
+ path: edgePath,
609
+ style: {
610
+ stroke: strokeColor,
611
+ strokeWidth,
612
+ strokeDasharray
613
+ }
614
+ }), edgeData?.label && /* @__PURE__ */ jsx(EdgeLabelRenderer, { children: /* @__PURE__ */ jsx("div", {
615
+ style: {
616
+ position: "absolute",
617
+ transform: `translate(-50%, -50%) translate(${labelX}px,${labelY}px)`,
618
+ pointerEvents: "all"
619
+ },
620
+ className: cls("px-1.5 py-0.5 rounded text-[9px] font-mono font-semibold leading-none", "bg-white dark:bg-surface-900 border", selected ? "border-primary text-primary" : isJunction ? "border-violet-200 dark:border-violet-800 text-violet-600 dark:text-violet-400" : isInverse || isJoinPath ? "border-surface-200 dark:border-surface-700 text-text-disabled dark:text-text-disabled-dark" : "border-primary/30 dark:border-primary/30 text-primary"),
621
+ children: edgeData.label
622
+ }) })] });
623
+ };
624
+ var RelationEdge = memo(RelationEdgeInner);
625
+ //#endregion
626
+ //#region src/components/SchemaVisualizer/SchemaVisualizer.tsx
627
+ var nodeTypes = { tableNode: TableNode };
628
+ var edgeTypes = { relationEdge: RelationEdge };
629
+ function SchemaVisualizerCanvas({ collections }) {
630
+ const reactFlowInstance = useReactFlow();
631
+ const { nodes: layoutedNodes, edges: layoutedEdges, direction, setDirection, relayout, tableCount, relationCount } = useSchemaGraph(collections);
632
+ const [nodes, setNodes] = useState([]);
633
+ const [edges, setEdges] = useState([]);
634
+ const [selectedTable, setSelectedTable] = useState(null);
635
+ const [searchQuery, setSearchQuery] = useState("");
636
+ const initialFitDone = useRef(false);
637
+ useEffect(() => {
638
+ setNodes(layoutedNodes);
639
+ setEdges(layoutedEdges);
640
+ }, [layoutedNodes, layoutedEdges]);
641
+ const onNodesChange = useCallback((changes) => setNodes((nds) => applyNodeChanges(changes, nds)), []);
642
+ const onEdgesChange = useCallback((changes) => setEdges((eds) => applyEdgeChanges(changes, eds)), []);
643
+ useEffect(() => {
644
+ if (nodes.length > 0 && !initialFitDone.current) {
645
+ const timer = setTimeout(() => {
646
+ reactFlowInstance.fitView({
647
+ padding: .15,
648
+ duration: 400
649
+ });
650
+ initialFitDone.current = true;
651
+ }, 200);
652
+ return () => clearTimeout(timer);
653
+ }
654
+ }, [nodes.length, reactFlowInstance]);
655
+ const handleFitView = useCallback(() => {
656
+ reactFlowInstance.fitView({
657
+ padding: .15,
658
+ duration: 400
659
+ });
660
+ }, [reactFlowInstance]);
661
+ const handleNodeClick = useCallback((_, node) => {
662
+ setSelectedTable(node.id);
663
+ }, []);
664
+ const handlePaneClick = useCallback(() => {
665
+ setSelectedTable(null);
666
+ }, []);
667
+ const handleTableSelect = useCallback((nodeId) => {
668
+ setSelectedTable(nodeId);
669
+ const node = nodes.find((n) => n.id === nodeId);
670
+ if (node) reactFlowInstance.setCenter(node.position.x + 140, node.position.y + 60, {
671
+ zoom: 1.2,
672
+ duration: 400
673
+ });
674
+ }, [nodes, reactFlowInstance]);
675
+ const [sidebarSize, setSidebarSize] = useState(() => {
676
+ try {
677
+ const saved = localStorage.getItem("rebase_schema_viz_sidebar_size");
678
+ return saved !== null ? parseFloat(saved) : 20;
679
+ } catch {
680
+ return 20;
681
+ }
682
+ });
683
+ useEffect(() => {
684
+ try {
685
+ localStorage.setItem("rebase_schema_viz_sidebar_size", sidebarSize.toString());
686
+ } catch {}
687
+ }, [sidebarSize]);
688
+ const postgresCollections = useMemo(() => collections.filter(isPostgresCollection), [collections]);
689
+ const filteredCollections = useMemo(() => {
690
+ if (!searchQuery.trim()) return postgresCollections;
691
+ const q = searchQuery.toLowerCase();
692
+ return postgresCollections.filter((c) => c.name.toLowerCase().includes(q) || c.table?.toLowerCase().includes(q) || c.slug?.toLowerCase().includes(q));
693
+ }, [postgresCollections, searchQuery]);
694
+ const junctionNodes = useMemo(() => nodes.filter((n) => n.data.isJunction), [nodes]);
695
+ const stats = useMemo(() => ({
696
+ tables: tableCount,
697
+ relations: relationCount,
698
+ junctions: junctionNodes.length,
699
+ withRls: postgresCollections.filter((c) => isPostgresCollection(c) && c.securityRules && c.securityRules.length > 0).length
700
+ }), [
701
+ tableCount,
702
+ relationCount,
703
+ junctionNodes.length,
704
+ postgresCollections
705
+ ]);
706
+ return /* @__PURE__ */ jsx(ResizablePanels, {
707
+ orientation: "horizontal",
708
+ panelSizePercent: sidebarSize,
709
+ onPanelSizeChange: setSidebarSize,
710
+ minPanelSizePx: 220,
711
+ firstPanel: /* @__PURE__ */ jsxs("div", {
712
+ className: cls("flex flex-col h-full w-full bg-white dark:bg-surface-950 border-r", defaultBorderMixin),
713
+ children: [
714
+ /* @__PURE__ */ jsxs("div", {
715
+ className: cls("flex items-center justify-between px-3 py-2 border-b bg-surface-50 dark:bg-surface-900 min-h-[48px]", defaultBorderMixin),
716
+ children: [/* @__PURE__ */ jsx(Typography, {
717
+ variant: "caption",
718
+ className: "font-bold uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark",
719
+ children: "Tables"
720
+ }), /* @__PURE__ */ jsx(Typography, {
721
+ variant: "caption",
722
+ className: "text-[10px] text-text-disabled dark:text-text-disabled-dark font-mono",
723
+ children: stats.tables
724
+ })]
725
+ }),
726
+ /* @__PURE__ */ jsx("div", {
727
+ className: "px-2 py-1.5 border-b border-surface-200/40 dark:border-surface-700/40",
728
+ children: /* @__PURE__ */ jsx(SearchBar, {
729
+ size: "smallest",
730
+ placeholder: "Filter tables…",
731
+ onTextSearch: (val) => setSearchQuery(val ?? ""),
732
+ innerClassName: "text-xs"
733
+ })
734
+ }),
735
+ /* @__PURE__ */ jsxs("div", {
736
+ className: "flex-grow overflow-y-auto no-scrollbar p-1",
737
+ children: [/* @__PURE__ */ jsx("div", {
738
+ className: "space-y-0.5",
739
+ children: filteredCollections.map((collection) => {
740
+ const table = collection.table ?? collection.slug;
741
+ const nodeId = `table-${table}`;
742
+ return /* @__PURE__ */ jsxs("div", {
743
+ onClick: () => handleTableSelect(nodeId),
744
+ className: cls("flex items-center p-1.5 cursor-pointer rounded transition-colors group", selectedTable === nodeId ? "bg-primary/10 text-primary dark:bg-primary/20 dark:text-primary-light" : "hover:bg-surface-100 dark:hover:bg-surface-950 text-text-secondary dark:text-text-secondary-dark"),
745
+ children: [
746
+ /* @__PURE__ */ jsx("div", {
747
+ className: "shrink-0 mr-1.5 text-text-disabled dark:text-text-disabled-dark",
748
+ children: /* @__PURE__ */ jsx(IconForView, {
749
+ collectionOrView: {
750
+ slug: collection.slug,
751
+ name: collection.name,
752
+ icon: typeof collection.icon === "string" ? collection.icon : void 0
753
+ },
754
+ size: "smallest"
755
+ })
756
+ }),
757
+ /* @__PURE__ */ jsxs("div", {
758
+ className: "flex flex-col min-w-0 flex-1",
759
+ children: [/* @__PURE__ */ jsx(Typography, {
760
+ variant: "caption",
761
+ className: "text-xs truncate font-medium",
762
+ children: collection.name
763
+ }), table !== collection.name && /* @__PURE__ */ jsx(Typography, {
764
+ variant: "caption",
765
+ className: "text-[10px] text-text-disabled dark:text-text-disabled-dark font-mono truncate",
766
+ children: table
767
+ })]
768
+ }),
769
+ /* @__PURE__ */ jsxs("div", {
770
+ className: "flex items-center gap-1 shrink-0 ml-1",
771
+ children: [isPostgresCollection(collection) && collection.securityRules && collection.securityRules.length > 0 && /* @__PURE__ */ jsx(Tooltip, {
772
+ title: "RLS enabled",
773
+ children: /* @__PURE__ */ jsx("div", { className: "w-1.5 h-1.5 rounded-full bg-green-500" })
774
+ }), collection.history && /* @__PURE__ */ jsx(Tooltip, {
775
+ title: "History enabled",
776
+ children: /* @__PURE__ */ jsx("div", { className: "w-1.5 h-1.5 rounded-full bg-blue-400" })
777
+ })]
778
+ })
779
+ ]
780
+ }, nodeId);
781
+ })
782
+ }), junctionNodes.length > 0 && /* @__PURE__ */ jsxs("div", {
783
+ className: "mt-3",
784
+ children: [/* @__PURE__ */ jsx(Typography, {
785
+ variant: "caption",
786
+ className: "px-1.5 text-[10px] uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark font-medium",
787
+ children: "Junction Tables"
788
+ }), /* @__PURE__ */ jsx("div", {
789
+ className: "mt-1 space-y-0.5",
790
+ children: junctionNodes.map((node) => {
791
+ const d = node.data;
792
+ return /* @__PURE__ */ jsxs("div", {
793
+ onClick: () => handleTableSelect(node.id),
794
+ className: cls("flex items-center p-1.5 cursor-pointer rounded transition-colors", selectedTable === node.id ? "bg-primary/10 text-primary dark:bg-primary/20" : "hover:bg-surface-100 dark:hover:bg-surface-950 text-text-disabled dark:text-text-disabled-dark"),
795
+ children: [/* @__PURE__ */ jsx("svg", {
796
+ className: "w-3.5 h-3.5 mr-1.5 shrink-0",
797
+ fill: "none",
798
+ stroke: "currentColor",
799
+ viewBox: "0 0 24 24",
800
+ children: /* @__PURE__ */ jsx("path", {
801
+ strokeLinecap: "round",
802
+ strokeLinejoin: "round",
803
+ strokeWidth: 2,
804
+ d: "M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"
805
+ })
806
+ }), /* @__PURE__ */ jsx(Typography, {
807
+ variant: "caption",
808
+ className: "text-xs font-mono truncate",
809
+ children: d.tableName
810
+ })]
811
+ }, node.id);
812
+ })
813
+ })]
814
+ })]
815
+ }),
816
+ /* @__PURE__ */ jsxs("div", {
817
+ className: cls("px-3 py-2 border-t bg-surface-50 dark:bg-surface-900 space-y-1", defaultBorderMixin),
818
+ children: [
819
+ /* @__PURE__ */ jsxs("div", {
820
+ className: "flex items-center justify-between",
821
+ children: [/* @__PURE__ */ jsx(Typography, {
822
+ variant: "caption",
823
+ className: "text-[10px] text-text-disabled dark:text-text-disabled-dark",
824
+ children: "Tables"
825
+ }), /* @__PURE__ */ jsx(Typography, {
826
+ variant: "caption",
827
+ className: "text-[10px] font-mono font-medium",
828
+ children: stats.tables
829
+ })]
830
+ }),
831
+ /* @__PURE__ */ jsxs("div", {
832
+ className: "flex items-center justify-between",
833
+ children: [/* @__PURE__ */ jsx(Typography, {
834
+ variant: "caption",
835
+ className: "text-[10px] text-text-disabled dark:text-text-disabled-dark",
836
+ children: "Relations"
837
+ }), /* @__PURE__ */ jsx(Typography, {
838
+ variant: "caption",
839
+ className: "text-[10px] font-mono font-medium",
840
+ children: stats.relations
841
+ })]
842
+ }),
843
+ /* @__PURE__ */ jsxs("div", {
844
+ className: "flex items-center justify-between",
845
+ children: [/* @__PURE__ */ jsx(Typography, {
846
+ variant: "caption",
847
+ className: "text-[10px] text-text-disabled dark:text-text-disabled-dark",
848
+ children: "RLS protected"
849
+ }), /* @__PURE__ */ jsxs("div", {
850
+ className: "flex items-center gap-1",
851
+ children: [/* @__PURE__ */ jsx("div", { className: "w-1.5 h-1.5 rounded-full bg-green-500" }), /* @__PURE__ */ jsx(Typography, {
852
+ variant: "caption",
853
+ className: "text-[10px] font-mono font-medium",
854
+ children: stats.withRls
855
+ })]
856
+ })]
857
+ })
858
+ ]
859
+ })
860
+ ]
861
+ }),
862
+ secondPanel: /* @__PURE__ */ jsxs("div", {
863
+ className: "flex-grow flex flex-col min-w-0 h-full w-full bg-white dark:bg-surface-950",
864
+ children: [/* @__PURE__ */ jsxs("div", {
865
+ className: cls("flex items-center justify-between pr-2 border-b bg-white dark:bg-surface-950 min-h-[46px]", defaultBorderMixin),
866
+ children: [/* @__PURE__ */ jsx("div", {
867
+ className: "flex items-center gap-2 px-4",
868
+ children: /* @__PURE__ */ jsx(Typography, {
869
+ variant: "subtitle2",
870
+ className: "font-mono text-text-secondary dark:text-text-secondary-dark",
871
+ children: "Schema Visualizer"
872
+ })
873
+ }), /* @__PURE__ */ jsxs("div", {
874
+ className: "flex shrink-0 items-center gap-1.5",
875
+ children: [
876
+ /* @__PURE__ */ jsxs("div", {
877
+ className: "flex items-center bg-surface-100 dark:bg-surface-950 rounded-md border border-surface-200/40 dark:border-surface-700/40",
878
+ children: [/* @__PURE__ */ jsx(Tooltip, {
879
+ title: "Left to right layout",
880
+ children: /* @__PURE__ */ jsx(Button, {
881
+ size: "small",
882
+ variant: direction === "LR" ? "filled" : "text",
883
+ color: direction === "LR" ? "primary" : "neutral",
884
+ onClick: () => setDirection("LR"),
885
+ className: "!rounded-r-none !px-2 !py-1 !text-[10px] !font-mono",
886
+ children: "LR"
887
+ })
888
+ }), /* @__PURE__ */ jsx(Tooltip, {
889
+ title: "Top to bottom layout",
890
+ children: /* @__PURE__ */ jsx(Button, {
891
+ size: "small",
892
+ variant: direction === "TB" ? "filled" : "text",
893
+ color: direction === "TB" ? "primary" : "neutral",
894
+ onClick: () => setDirection("TB"),
895
+ className: "!rounded-l-none !px-2 !py-1 !text-[10px] !font-mono",
896
+ children: "TB"
897
+ })
898
+ })]
899
+ }),
900
+ /* @__PURE__ */ jsx("div", { className: "h-4 w-px bg-surface-200 dark:bg-surface-950 mx-0.5" }),
901
+ /* @__PURE__ */ jsx(Tooltip, {
902
+ title: "Fit to view",
903
+ children: /* @__PURE__ */ jsx(IconButton, {
904
+ size: "small",
905
+ onClick: handleFitView,
906
+ children: /* @__PURE__ */ jsx("svg", {
907
+ className: "w-4 h-4",
908
+ fill: "none",
909
+ stroke: "currentColor",
910
+ viewBox: "0 0 24 24",
911
+ children: /* @__PURE__ */ jsx("path", {
912
+ strokeLinecap: "round",
913
+ strokeLinejoin: "round",
914
+ strokeWidth: 2,
915
+ d: "M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"
916
+ })
917
+ })
918
+ })
919
+ }),
920
+ /* @__PURE__ */ jsx(Tooltip, {
921
+ title: "Re-layout",
922
+ children: /* @__PURE__ */ jsx(IconButton, {
923
+ size: "small",
924
+ onClick: relayout,
925
+ children: /* @__PURE__ */ jsx("svg", {
926
+ className: "w-4 h-4",
927
+ fill: "none",
928
+ stroke: "currentColor",
929
+ viewBox: "0 0 24 24",
930
+ children: /* @__PURE__ */ jsx("path", {
931
+ strokeLinecap: "round",
932
+ strokeLinejoin: "round",
933
+ strokeWidth: 2,
934
+ d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
935
+ })
936
+ })
937
+ })
938
+ })
939
+ ]
940
+ })]
941
+ }), /* @__PURE__ */ jsxs("div", {
942
+ className: "flex-grow relative",
943
+ children: [/* @__PURE__ */ jsxs(ReactFlow, {
944
+ nodes,
945
+ edges,
946
+ onNodesChange,
947
+ onEdgesChange,
948
+ onNodeClick: handleNodeClick,
949
+ onPaneClick: handlePaneClick,
950
+ nodeTypes,
951
+ edgeTypes,
952
+ fitView: true,
953
+ fitViewOptions: { padding: .15 },
954
+ minZoom: .1,
955
+ maxZoom: 2,
956
+ proOptions: { hideAttribution: true },
957
+ className: "bg-surface-50 dark:bg-surface-950",
958
+ children: [
959
+ /* @__PURE__ */ jsx(Background, {
960
+ variant: BackgroundVariant.Dots,
961
+ gap: 20,
962
+ size: 1,
963
+ className: "!bg-surface-50 dark:!bg-surface-950",
964
+ color: "var(--rf-bg-dot, #d4d4d8)"
965
+ }),
966
+ /* @__PURE__ */ jsx(Controls, {
967
+ showInteractive: false,
968
+ className: "!bg-white dark:!bg-surface-900 !border !border-surface-200/40 dark:!border-surface-700/40 !shadow-sm !rounded-lg"
969
+ }),
970
+ /* @__PURE__ */ jsx(MiniMap, {
971
+ nodeStrokeColor: (n) => {
972
+ const d = n.data;
973
+ if (d.isJunction) return "#a78bfa";
974
+ if (d.rlsEnabled) return "#22c55e";
975
+ return "#6366f1";
976
+ },
977
+ nodeColor: (n) => {
978
+ if (n.data.isJunction) return "#ede9fe";
979
+ return "#eef2ff";
980
+ },
981
+ maskColor: "rgba(0,0,0,0.08)",
982
+ className: "!bg-white dark:!bg-surface-900 !border !border-surface-200/40 dark:!border-surface-700/40 !shadow-sm !rounded-lg"
983
+ })
984
+ ]
985
+ }), /* @__PURE__ */ jsxs("div", {
986
+ className: "absolute bottom-4 left-4 flex items-center gap-3 px-3 py-2 bg-white/90 dark:bg-surface-900/90 backdrop-blur-sm rounded-lg border border-surface-200/40 dark:border-surface-700/40 shadow-sm",
987
+ children: [
988
+ /* @__PURE__ */ jsxs("div", {
989
+ className: "flex items-center gap-1.5",
990
+ children: [/* @__PURE__ */ jsx("div", { className: "w-6 h-0.5 bg-indigo-500 rounded" }), /* @__PURE__ */ jsx(Typography, {
991
+ variant: "caption",
992
+ className: "text-[10px] text-text-disabled dark:text-text-disabled-dark",
993
+ children: "Owning"
994
+ })]
995
+ }),
996
+ /* @__PURE__ */ jsxs("div", {
997
+ className: "flex items-center gap-1.5",
998
+ children: [/* @__PURE__ */ jsx("div", { className: "w-6 h-0.5 bg-violet-500 rounded" }), /* @__PURE__ */ jsx(Typography, {
999
+ variant: "caption",
1000
+ className: "text-[10px] text-text-disabled dark:text-text-disabled-dark",
1001
+ children: "M:N"
1002
+ })]
1003
+ }),
1004
+ /* @__PURE__ */ jsxs("div", {
1005
+ className: "flex items-center gap-1.5",
1006
+ children: [/* @__PURE__ */ jsx("div", {
1007
+ className: "w-6 h-0.5 rounded",
1008
+ style: { backgroundImage: "repeating-linear-gradient(90deg, #94a3b8, #94a3b8 4px, transparent 4px, transparent 7px)" }
1009
+ }), /* @__PURE__ */ jsx(Typography, {
1010
+ variant: "caption",
1011
+ className: "text-[10px] text-text-disabled dark:text-text-disabled-dark",
1012
+ children: "Inverse"
1013
+ })]
1014
+ }),
1015
+ /* @__PURE__ */ jsx("div", { className: "h-3 w-px bg-surface-200 dark:bg-surface-700" }),
1016
+ /* @__PURE__ */ jsxs("div", {
1017
+ className: "flex items-center gap-1",
1018
+ children: [/* @__PURE__ */ jsx("span", {
1019
+ className: "text-[9px]",
1020
+ children: "🔑"
1021
+ }), /* @__PURE__ */ jsx(Typography, {
1022
+ variant: "caption",
1023
+ className: "text-[10px] text-text-disabled dark:text-text-disabled-dark",
1024
+ children: "PK"
1025
+ })]
1026
+ }),
1027
+ /* @__PURE__ */ jsxs("div", {
1028
+ className: "flex items-center gap-1",
1029
+ children: [/* @__PURE__ */ jsx("span", {
1030
+ className: "text-[9px]",
1031
+ children: "🔗"
1032
+ }), /* @__PURE__ */ jsx(Typography, {
1033
+ variant: "caption",
1034
+ className: "text-[10px] text-text-disabled dark:text-text-disabled-dark",
1035
+ children: "FK"
1036
+ })]
1037
+ })
1038
+ ]
1039
+ })]
1040
+ })]
1041
+ })
1042
+ });
1043
+ }
1044
+ var SchemaVisualizer = () => {
1045
+ const { collections: registryCollections } = useStudioCollectionRegistry();
1046
+ const collections = useMemo(() => {
1047
+ return registryCollections ?? [];
1048
+ }, [registryCollections]);
1049
+ if (!collections || collections.length === 0) return /* @__PURE__ */ jsx("div", {
1050
+ className: "flex items-center justify-center h-full w-full",
1051
+ children: /* @__PURE__ */ jsxs("div", {
1052
+ className: "text-center space-y-3",
1053
+ children: [/* @__PURE__ */ jsx(CircularProgress, { size: "small" }), /* @__PURE__ */ jsx(Typography, {
1054
+ variant: "body2",
1055
+ color: "secondary",
1056
+ children: "Loading schema…"
1057
+ })]
1058
+ })
1059
+ });
1060
+ return /* @__PURE__ */ jsx("div", {
1061
+ className: "flex h-full w-full bg-white dark:bg-surface-950 overflow-hidden text-text-primary dark:text-text-primary-dark",
1062
+ children: /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(SchemaVisualizerCanvas, { collections }) })
1063
+ });
1064
+ };
1065
+ //#endregion
1066
+ export { SchemaVisualizer };
1067
+
1068
+ //# sourceMappingURL=SchemaVisualizer-BJK2u3C0.js.map