@rebasepro/studio 0.5.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 (369) hide show
  1. package/dist/ApiExplorer-CdIwR9Ga.js +963 -0
  2. package/dist/ApiExplorer-CdIwR9Ga.js.map +1 -0
  3. package/dist/AuthSimulationSelector-iEZ-Or_1.js +56 -0
  4. package/dist/AuthSimulationSelector-iEZ-Or_1.js.map +1 -0
  5. package/dist/BranchesView-DncIRcZt.js +461 -0
  6. package/dist/BranchesView-DncIRcZt.js.map +1 -0
  7. package/dist/CronJobsView-4gdtJvoe.js +500 -0
  8. package/dist/CronJobsView-4gdtJvoe.js.map +1 -0
  9. package/dist/JSEditor-BhAbEjCP.js +1573 -0
  10. package/dist/JSEditor-BhAbEjCP.js.map +1 -0
  11. package/dist/LogsExplorer-CqtKILj8.js +240 -0
  12. package/dist/LogsExplorer-CqtKILj8.js.map +1 -0
  13. package/dist/MonacoEditor-COZqrIJ1.js +246 -0
  14. package/dist/MonacoEditor-COZqrIJ1.js.map +1 -0
  15. package/dist/RLSEditor-CTxYbBdW.js +1362 -0
  16. package/dist/RLSEditor-CTxYbBdW.js.map +1 -0
  17. package/dist/SQLEditor-BLuq_zDM.js +1964 -0
  18. package/dist/SQLEditor-BLuq_zDM.js.map +1 -0
  19. package/dist/SchemaVisualizer-BJK2u3C0.js +1068 -0
  20. package/dist/SchemaVisualizer-BJK2u3C0.js.map +1 -0
  21. package/dist/StorageView-nDaC2foF.js +1382 -0
  22. package/dist/StorageView-nDaC2foF.js.map +1 -0
  23. package/dist/{studio/src/components → components}/ApiExplorer/ApiExplorer.d.ts +2 -1
  24. package/dist/{studio/src/components → components}/ApiExplorer/EndpointDetail.d.ts +2 -1
  25. package/dist/{studio/src/components → components}/ApiExplorer/TryItPanel.d.ts +2 -1
  26. package/dist/{studio/src/components → components}/AuthSimulationSelector.d.ts +2 -1
  27. package/dist/components/Branches/BranchesView.d.ts +2 -0
  28. package/dist/components/CronJobs/CronJobsView.d.ts +2 -0
  29. package/dist/components/JSEditor/JSEditor.d.ts +2 -0
  30. package/dist/{studio/src/components → components}/JSEditor/JSEditorSidebar.d.ts +2 -1
  31. package/dist/{studio/src/components → components}/JSEditor/JSMonacoEditor.d.ts +2 -1
  32. package/dist/components/LogsExplorer/LogsExplorer.d.ts +2 -0
  33. package/dist/{studio/src/components → components}/RLSEditor/PolicyEditor.d.ts +2 -1
  34. package/dist/{studio/src/components → components}/RLSEditor/RLSEditor.d.ts +2 -1
  35. package/dist/{studio/src/components → components}/SQLEditor/MonacoEditor.d.ts +2 -1
  36. package/dist/{studio/src/components → components}/SQLEditor/SQLEditor.d.ts +2 -1
  37. package/dist/{studio/src/components → components}/SQLEditor/SQLEditorSidebar.d.ts +2 -1
  38. package/dist/{studio/src/components → components}/SQLEditor/SchemaBrowser.d.ts +2 -1
  39. package/dist/{studio/src/components → components}/SchemaVisualizer/RelationEdge.d.ts +1 -1
  40. package/dist/components/SchemaVisualizer/SchemaVisualizer.d.ts +3 -0
  41. package/dist/{studio/src/components → components}/SchemaVisualizer/TableNode.d.ts +1 -1
  42. package/dist/components/StorageView/StorageView.d.ts +2 -0
  43. package/dist/{studio/src/components → components}/StudioHomePage.d.ts +1 -1
  44. package/dist/index.es.js +688 -746
  45. package/dist/index.es.js.map +1 -1
  46. package/dist/index.umd.js +10303 -9572
  47. package/dist/index.umd.js.map +1 -1
  48. package/package.json +22 -22
  49. package/src/components/ApiExplorer/TryItPanel.tsx +15 -18
  50. package/src/components/CronJobs/CronJobsView.tsx +1 -1
  51. package/src/components/JSEditor/JSEditor.tsx +9 -14
  52. package/src/components/LogsExplorer/LogsExplorer.tsx +6 -3
  53. package/src/components/RLSEditor/PolicyEditor.tsx +0 -1
  54. package/src/components/SQLEditor/SQLEditor.tsx +40 -30
  55. package/src/components/StorageView/StorageView.tsx +22 -11
  56. package/src/components/StudioHomePage.tsx +51 -15
  57. package/src/utils/parseSpec.test.ts +41 -20
  58. package/src/utils/pgColumnToProperty.ts +1 -1
  59. package/dist/ApiExplorer-CGHEF1uL.js +0 -1052
  60. package/dist/ApiExplorer-CGHEF1uL.js.map +0 -1
  61. package/dist/AuthSimulationSelector-DGoXkWSg.js +0 -105
  62. package/dist/AuthSimulationSelector-DGoXkWSg.js.map +0 -1
  63. package/dist/BranchesView-BiTEwIhd.js +0 -291
  64. package/dist/BranchesView-BiTEwIhd.js.map +0 -1
  65. package/dist/CronJobsView-3PM_qR8v.js +0 -472
  66. package/dist/CronJobsView-3PM_qR8v.js.map +0 -1
  67. package/dist/JSEditor-DfwRLBZg.js +0 -1297
  68. package/dist/JSEditor-DfwRLBZg.js.map +0 -1
  69. package/dist/LogsExplorer-_4sZadKn.js +0 -162
  70. package/dist/LogsExplorer-_4sZadKn.js.map +0 -1
  71. package/dist/MonacoEditor-CMYEjiRf.js +0 -161
  72. package/dist/MonacoEditor-CMYEjiRf.js.map +0 -1
  73. package/dist/RLSEditor-CHEExeSB.js +0 -1871
  74. package/dist/RLSEditor-CHEExeSB.js.map +0 -1
  75. package/dist/SQLEditor-CQXaI0iU.js +0 -1797
  76. package/dist/SQLEditor-CQXaI0iU.js.map +0 -1
  77. package/dist/SchemaVisualizer-BGpmzyXT.js +0 -1069
  78. package/dist/SchemaVisualizer-BGpmzyXT.js.map +0 -1
  79. package/dist/StorageView-B7AsN2qX.js +0 -869
  80. package/dist/StorageView-B7AsN2qX.js.map +0 -1
  81. package/dist/common/src/collections/CollectionRegistry.d.ts +0 -56
  82. package/dist/common/src/collections/default-collections.d.ts +0 -9
  83. package/dist/common/src/collections/index.d.ts +0 -2
  84. package/dist/common/src/data/buildRebaseData.d.ts +0 -14
  85. package/dist/common/src/data/query_builder.d.ts +0 -55
  86. package/dist/common/src/index.d.ts +0 -4
  87. package/dist/common/src/util/builders.d.ts +0 -57
  88. package/dist/common/src/util/callbacks.d.ts +0 -6
  89. package/dist/common/src/util/collections.d.ts +0 -11
  90. package/dist/common/src/util/common.d.ts +0 -2
  91. package/dist/common/src/util/conditions.d.ts +0 -26
  92. package/dist/common/src/util/entities.d.ts +0 -58
  93. package/dist/common/src/util/enums.d.ts +0 -3
  94. package/dist/common/src/util/index.d.ts +0 -16
  95. package/dist/common/src/util/navigation_from_path.d.ts +0 -34
  96. package/dist/common/src/util/navigation_utils.d.ts +0 -20
  97. package/dist/common/src/util/parent_references_from_path.d.ts +0 -6
  98. package/dist/common/src/util/paths.d.ts +0 -14
  99. package/dist/common/src/util/permissions.d.ts +0 -14
  100. package/dist/common/src/util/references.d.ts +0 -2
  101. package/dist/common/src/util/relations.d.ts +0 -22
  102. package/dist/common/src/util/resolutions.d.ts +0 -72
  103. package/dist/common/src/util/storage.d.ts +0 -24
  104. package/dist/core/src/components/AIIcon.d.ts +0 -16
  105. package/dist/core/src/components/BootstrapAdminBanner.d.ts +0 -4
  106. package/dist/core/src/components/ConfirmationDialog.d.ts +0 -9
  107. package/dist/core/src/components/Debug/UIReferenceView.d.ts +0 -1
  108. package/dist/core/src/components/Debug/UIStyleGuide.d.ts +0 -1
  109. package/dist/core/src/components/ErrorTooltip.d.ts +0 -2
  110. package/dist/core/src/components/ErrorView.d.ts +0 -21
  111. package/dist/core/src/components/LanguageToggle.d.ts +0 -1
  112. package/dist/core/src/components/LoginView/LoginView.d.ts +0 -109
  113. package/dist/core/src/components/LoginView/index.d.ts +0 -2
  114. package/dist/core/src/components/NotFoundPage.d.ts +0 -1
  115. package/dist/core/src/components/RebaseAuth.d.ts +0 -10
  116. package/dist/core/src/components/RebaseLogo.d.ts +0 -7
  117. package/dist/core/src/components/UnsavedChangesDialog.d.ts +0 -9
  118. package/dist/core/src/components/UserDisplay.d.ts +0 -7
  119. package/dist/core/src/components/UserSelectPopover.d.ts +0 -62
  120. package/dist/core/src/components/UserSettingsView.d.ts +0 -1
  121. package/dist/core/src/components/common/index.d.ts +0 -6
  122. package/dist/core/src/components/common/table_height.d.ts +0 -5
  123. package/dist/core/src/components/common/types.d.ts +0 -66
  124. package/dist/core/src/components/common/useColumnsIds.d.ts +0 -9
  125. package/dist/core/src/components/common/useDataTableController.d.ts +0 -45
  126. package/dist/core/src/components/common/useDebouncedData.d.ts +0 -9
  127. package/dist/core/src/components/common/useScrollRestoration.d.ts +0 -14
  128. package/dist/core/src/components/index.d.ts +0 -17
  129. package/dist/core/src/contexts/AdminModeController.d.ts +0 -4
  130. package/dist/core/src/contexts/AnalyticsContext.d.ts +0 -3
  131. package/dist/core/src/contexts/AuthControllerContext.d.ts +0 -3
  132. package/dist/core/src/contexts/CustomizationControllerContext.d.ts +0 -3
  133. package/dist/core/src/contexts/DataDriverContext.d.ts +0 -3
  134. package/dist/core/src/contexts/DatabaseAdminContext.d.ts +0 -3
  135. package/dist/core/src/contexts/DialogsProvider.d.ts +0 -4
  136. package/dist/core/src/contexts/EffectiveRoleController.d.ts +0 -4
  137. package/dist/core/src/contexts/InternalUserManagementContext.d.ts +0 -3
  138. package/dist/core/src/contexts/ModeController.d.ts +0 -4
  139. package/dist/core/src/contexts/RebaseClientInstanceContext.d.ts +0 -6
  140. package/dist/core/src/contexts/RebaseDataContext.d.ts +0 -3
  141. package/dist/core/src/contexts/SnackbarProvider.d.ts +0 -2
  142. package/dist/core/src/contexts/StorageSourceContext.d.ts +0 -3
  143. package/dist/core/src/contexts/UserConfigurationPersistenceContext.d.ts +0 -3
  144. package/dist/core/src/contexts/index.d.ts +0 -13
  145. package/dist/core/src/core/PluginLifecycleManager.d.ts +0 -17
  146. package/dist/core/src/core/PluginProviderStack.d.ts +0 -21
  147. package/dist/core/src/core/Rebase.d.ts +0 -14
  148. package/dist/core/src/core/RebaseProps.d.ts +0 -147
  149. package/dist/core/src/core/RebaseRouter.d.ts +0 -4
  150. package/dist/core/src/core/RebaseRoutes.d.ts +0 -17
  151. package/dist/core/src/core/index.d.ts +0 -4
  152. package/dist/core/src/hooks/ApiConfigContext.d.ts +0 -24
  153. package/dist/core/src/hooks/data/delete.d.ts +0 -31
  154. package/dist/core/src/hooks/data/save.d.ts +0 -34
  155. package/dist/core/src/hooks/data/useCollectionFetch.d.ts +0 -62
  156. package/dist/core/src/hooks/data/useData.d.ts +0 -13
  157. package/dist/core/src/hooks/data/useDataOrder.d.ts +0 -12
  158. package/dist/core/src/hooks/data/useEntityFetch.d.ts +0 -43
  159. package/dist/core/src/hooks/data/useRelationSelector.d.ts +0 -52
  160. package/dist/core/src/hooks/data/useUserSelector.d.ts +0 -31
  161. package/dist/core/src/hooks/index.d.ts +0 -37
  162. package/dist/core/src/hooks/useAdminModeController.d.ts +0 -19
  163. package/dist/core/src/hooks/useAnalyticsController.d.ts +0 -5
  164. package/dist/core/src/hooks/useAuthController.d.ts +0 -11
  165. package/dist/core/src/hooks/useAuthSubscription.d.ts +0 -2
  166. package/dist/core/src/hooks/useBackendStorageSource.d.ts +0 -30
  167. package/dist/core/src/hooks/useBridgeRegistration.d.ts +0 -18
  168. package/dist/core/src/hooks/useBrowserTitleAndIcon.d.ts +0 -6
  169. package/dist/core/src/hooks/useBuildAdminModeController.d.ts +0 -6
  170. package/dist/core/src/hooks/useBuildEffectiveRoleController.d.ts +0 -8
  171. package/dist/core/src/hooks/useBuildLocalConfigurationPersistence.d.ts +0 -2
  172. package/dist/core/src/hooks/useBuildModeController.d.ts +0 -6
  173. package/dist/core/src/hooks/useClipboard.d.ts +0 -57
  174. package/dist/core/src/hooks/useCollapsedGroups.d.ts +0 -27
  175. package/dist/core/src/hooks/useCustomizationController.d.ts +0 -11
  176. package/dist/core/src/hooks/useDialogsController.d.ts +0 -11
  177. package/dist/core/src/hooks/useEffectiveRoleController.d.ts +0 -7
  178. package/dist/core/src/hooks/useInternalUserManagementController.d.ts +0 -12
  179. package/dist/core/src/hooks/useLargeLayout.d.ts +0 -1
  180. package/dist/core/src/hooks/useModeController.d.ts +0 -19
  181. package/dist/core/src/hooks/usePermissions.d.ts +0 -12
  182. package/dist/core/src/hooks/useRebaseClient.d.ts +0 -5
  183. package/dist/core/src/hooks/useRebaseContext.d.ts +0 -11
  184. package/dist/core/src/hooks/useRebaseRegistry.d.ts +0 -34
  185. package/dist/core/src/hooks/useResolvedComponent.d.ts +0 -47
  186. package/dist/core/src/hooks/useSlot.d.ts +0 -18
  187. package/dist/core/src/hooks/useSnackbarController.d.ts +0 -20
  188. package/dist/core/src/hooks/useStorageSource.d.ts +0 -7
  189. package/dist/core/src/hooks/useStudioBridge.d.ts +0 -91
  190. package/dist/core/src/hooks/useTranslation.d.ts +0 -17
  191. package/dist/core/src/hooks/useUnsavedChangesDialog.d.ts +0 -12
  192. package/dist/core/src/hooks/useUserConfigurationPersistence.d.ts +0 -8
  193. package/dist/core/src/i18n/RebaseI18nProvider.d.ts +0 -33
  194. package/dist/core/src/index.d.ts +0 -15
  195. package/dist/core/src/internal/common.d.ts +0 -3
  196. package/dist/core/src/internal/useRestoreScroll.d.ts +0 -6
  197. package/dist/core/src/locales/de.d.ts +0 -2
  198. package/dist/core/src/locales/en.d.ts +0 -10
  199. package/dist/core/src/locales/es.d.ts +0 -10
  200. package/dist/core/src/locales/fr.d.ts +0 -2
  201. package/dist/core/src/locales/hi.d.ts +0 -2
  202. package/dist/core/src/locales/it.d.ts +0 -2
  203. package/dist/core/src/locales/pt.d.ts +0 -7
  204. package/dist/core/src/util/constants.d.ts +0 -1
  205. package/dist/core/src/util/createFormexStub.d.ts +0 -2
  206. package/dist/core/src/util/entity_cache.d.ts +0 -22
  207. package/dist/core/src/util/enums.d.ts +0 -5
  208. package/dist/core/src/util/icon_list.d.ts +0 -5
  209. package/dist/core/src/util/icons.d.ts +0 -20
  210. package/dist/core/src/util/index.d.ts +0 -8
  211. package/dist/core/src/util/previews.d.ts +0 -4
  212. package/dist/core/src/util/useStorageUploadController.d.ts +0 -38
  213. package/dist/formex/src/Field.d.ts +0 -52
  214. package/dist/formex/src/Formex.d.ts +0 -7
  215. package/dist/formex/src/index.d.ts +0 -5
  216. package/dist/formex/src/types.d.ts +0 -40
  217. package/dist/formex/src/useCreateFormex.d.ts +0 -14
  218. package/dist/formex/src/utils.d.ts +0 -16
  219. package/dist/studio/src/components/Branches/BranchesView.d.ts +0 -1
  220. package/dist/studio/src/components/CronJobs/CronJobsView.d.ts +0 -1
  221. package/dist/studio/src/components/JSEditor/JSEditor.d.ts +0 -1
  222. package/dist/studio/src/components/LogsExplorer/LogsExplorer.d.ts +0 -1
  223. package/dist/studio/src/components/SchemaVisualizer/SchemaVisualizer.d.ts +0 -2
  224. package/dist/studio/src/components/StorageView/StorageView.d.ts +0 -1
  225. package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
  226. package/dist/types/src/controllers/auth.d.ts +0 -104
  227. package/dist/types/src/controllers/client.d.ts +0 -168
  228. package/dist/types/src/controllers/collection_registry.d.ts +0 -46
  229. package/dist/types/src/controllers/customization_controller.d.ts +0 -60
  230. package/dist/types/src/controllers/data.d.ts +0 -207
  231. package/dist/types/src/controllers/data_driver.d.ts +0 -218
  232. package/dist/types/src/controllers/database_admin.d.ts +0 -11
  233. package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
  234. package/dist/types/src/controllers/effective_role.d.ts +0 -4
  235. package/dist/types/src/controllers/email.d.ts +0 -36
  236. package/dist/types/src/controllers/index.d.ts +0 -18
  237. package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
  238. package/dist/types/src/controllers/navigation.d.ts +0 -225
  239. package/dist/types/src/controllers/registry.d.ts +0 -63
  240. package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
  241. package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
  242. package/dist/types/src/controllers/snackbar.d.ts +0 -24
  243. package/dist/types/src/controllers/storage.d.ts +0 -171
  244. package/dist/types/src/index.d.ts +0 -4
  245. package/dist/types/src/rebase_context.d.ts +0 -122
  246. package/dist/types/src/types/auth_adapter.d.ts +0 -301
  247. package/dist/types/src/types/backend.d.ts +0 -571
  248. package/dist/types/src/types/backend_hooks.d.ts +0 -172
  249. package/dist/types/src/types/builders.d.ts +0 -15
  250. package/dist/types/src/types/chips.d.ts +0 -5
  251. package/dist/types/src/types/collections.d.ts +0 -961
  252. package/dist/types/src/types/component_ref.d.ts +0 -47
  253. package/dist/types/src/types/cron.d.ts +0 -102
  254. package/dist/types/src/types/data_source.d.ts +0 -64
  255. package/dist/types/src/types/database_adapter.d.ts +0 -94
  256. package/dist/types/src/types/entities.d.ts +0 -145
  257. package/dist/types/src/types/entity_actions.d.ts +0 -104
  258. package/dist/types/src/types/entity_callbacks.d.ts +0 -173
  259. package/dist/types/src/types/entity_link_builder.d.ts +0 -7
  260. package/dist/types/src/types/entity_overrides.d.ts +0 -10
  261. package/dist/types/src/types/entity_views.d.ts +0 -87
  262. package/dist/types/src/types/export_import.d.ts +0 -21
  263. package/dist/types/src/types/formex.d.ts +0 -40
  264. package/dist/types/src/types/index.d.ts +0 -28
  265. package/dist/types/src/types/locales.d.ts +0 -4
  266. package/dist/types/src/types/modify_collections.d.ts +0 -5
  267. package/dist/types/src/types/plugins.d.ts +0 -282
  268. package/dist/types/src/types/properties.d.ts +0 -1173
  269. package/dist/types/src/types/property_config.d.ts +0 -74
  270. package/dist/types/src/types/relations.d.ts +0 -336
  271. package/dist/types/src/types/slots.d.ts +0 -262
  272. package/dist/types/src/types/translations.d.ts +0 -900
  273. package/dist/types/src/types/user_management_delegate.d.ts +0 -86
  274. package/dist/types/src/types/websockets.d.ts +0 -78
  275. package/dist/types/src/users/index.d.ts +0 -1
  276. package/dist/types/src/users/user.d.ts +0 -50
  277. package/dist/ui/src/components/Alert.d.ts +0 -12
  278. package/dist/ui/src/components/Autocomplete.d.ts +0 -21
  279. package/dist/ui/src/components/Avatar.d.ts +0 -11
  280. package/dist/ui/src/components/Badge.d.ts +0 -8
  281. package/dist/ui/src/components/BooleanSwitch.d.ts +0 -14
  282. package/dist/ui/src/components/BooleanSwitchWithLabel.d.ts +0 -17
  283. package/dist/ui/src/components/Button.d.ts +0 -14
  284. package/dist/ui/src/components/Card.d.ts +0 -8
  285. package/dist/ui/src/components/CenteredView.d.ts +0 -9
  286. package/dist/ui/src/components/Checkbox.d.ts +0 -13
  287. package/dist/ui/src/components/Chip.d.ts +0 -26
  288. package/dist/ui/src/components/CircularProgress.d.ts +0 -5
  289. package/dist/ui/src/components/CircularProgressCenter.d.ts +0 -11
  290. package/dist/ui/src/components/Collapse.d.ts +0 -9
  291. package/dist/ui/src/components/ColorPicker.d.ts +0 -30
  292. package/dist/ui/src/components/Container.d.ts +0 -8
  293. package/dist/ui/src/components/DateTimeField.d.ts +0 -24
  294. package/dist/ui/src/components/DebouncedTextField.d.ts +0 -2
  295. package/dist/ui/src/components/Dialog.d.ts +0 -39
  296. package/dist/ui/src/components/DialogActions.d.ts +0 -7
  297. package/dist/ui/src/components/DialogContent.d.ts +0 -7
  298. package/dist/ui/src/components/DialogTitle.d.ts +0 -10
  299. package/dist/ui/src/components/ErrorBoundary.d.ts +0 -33
  300. package/dist/ui/src/components/ExpandablePanel.d.ts +0 -12
  301. package/dist/ui/src/components/FileUpload.d.ts +0 -23
  302. package/dist/ui/src/components/FilterChip.d.ts +0 -34
  303. package/dist/ui/src/components/IconButton.d.ts +0 -12
  304. package/dist/ui/src/components/InfoLabel.d.ts +0 -5
  305. package/dist/ui/src/components/InputLabel.d.ts +0 -11
  306. package/dist/ui/src/components/Label.d.ts +0 -7
  307. package/dist/ui/src/components/LoadingButton.d.ts +0 -7
  308. package/dist/ui/src/components/Markdown.d.ts +0 -10
  309. package/dist/ui/src/components/Menu.d.ts +0 -23
  310. package/dist/ui/src/components/Menubar.d.ts +0 -80
  311. package/dist/ui/src/components/MultiSelect.d.ts +0 -48
  312. package/dist/ui/src/components/Paper.d.ts +0 -6
  313. package/dist/ui/src/components/Popover.d.ts +0 -24
  314. package/dist/ui/src/components/RadioGroup.d.ts +0 -28
  315. package/dist/ui/src/components/ResizablePanels.d.ts +0 -18
  316. package/dist/ui/src/components/SearchBar.d.ts +0 -26
  317. package/dist/ui/src/components/Select.d.ts +0 -43
  318. package/dist/ui/src/components/Separator.d.ts +0 -5
  319. package/dist/ui/src/components/Sheet.d.ts +0 -22
  320. package/dist/ui/src/components/Skeleton.d.ts +0 -6
  321. package/dist/ui/src/components/Slider.d.ts +0 -21
  322. package/dist/ui/src/components/Table.d.ts +0 -34
  323. package/dist/ui/src/components/Tabs.d.ts +0 -19
  324. package/dist/ui/src/components/TextField.d.ts +0 -58
  325. package/dist/ui/src/components/TextareaAutosize.d.ts +0 -43
  326. package/dist/ui/src/components/ToggleButtonGroup.d.ts +0 -30
  327. package/dist/ui/src/components/Tooltip.d.ts +0 -19
  328. package/dist/ui/src/components/Typography.d.ts +0 -36
  329. package/dist/ui/src/components/VirtualTable/VirtualTable.d.ts +0 -11
  330. package/dist/ui/src/components/VirtualTable/VirtualTableCell.d.ts +0 -21
  331. package/dist/ui/src/components/VirtualTable/VirtualTableHeader.d.ts +0 -29
  332. package/dist/ui/src/components/VirtualTable/VirtualTableHeaderRow.d.ts +0 -2
  333. package/dist/ui/src/components/VirtualTable/VirtualTableProps.d.ts +0 -249
  334. package/dist/ui/src/components/VirtualTable/VirtualTableRow.d.ts +0 -3
  335. package/dist/ui/src/components/VirtualTable/index.d.ts +0 -3
  336. package/dist/ui/src/components/VirtualTable/types.d.ts +0 -38
  337. package/dist/ui/src/components/common/SelectInputLabel.d.ts +0 -5
  338. package/dist/ui/src/components/index.d.ts +0 -58
  339. package/dist/ui/src/hooks/PortalContainerContext.d.ts +0 -31
  340. package/dist/ui/src/hooks/index.d.ts +0 -6
  341. package/dist/ui/src/hooks/useDebounceCallback.d.ts +0 -1
  342. package/dist/ui/src/hooks/useDebounceValue.d.ts +0 -1
  343. package/dist/ui/src/hooks/useDebouncedCallback.d.ts +0 -1
  344. package/dist/ui/src/hooks/useInjectStyles.d.ts +0 -7
  345. package/dist/ui/src/hooks/useOutsideAlerter.d.ts +0 -5
  346. package/dist/ui/src/icons/GitHubIcon.d.ts +0 -2
  347. package/dist/ui/src/icons/HandleIcon.d.ts +0 -1
  348. package/dist/ui/src/icons/Icon.d.ts +0 -20
  349. package/dist/ui/src/icons/cool_icon_keys.d.ts +0 -1
  350. package/dist/ui/src/icons/icon_keys.d.ts +0 -1
  351. package/dist/ui/src/icons/index.d.ts +0 -8
  352. package/dist/ui/src/index.d.ts +0 -5
  353. package/dist/ui/src/styles.d.ts +0 -12
  354. package/dist/ui/src/util/chip_colors.d.ts +0 -4
  355. package/dist/ui/src/util/cls.d.ts +0 -2
  356. package/dist/ui/src/util/debounce.d.ts +0 -10
  357. package/dist/ui/src/util/hash.d.ts +0 -1
  358. package/dist/ui/src/util/index.d.ts +0 -4
  359. package/dist/ui/src/util/key_to_icon_component.d.ts +0 -1
  360. /package/dist/{studio/src/components → components}/ApiExplorer/parseSpec.d.ts +0 -0
  361. /package/dist/{studio/src/components → components}/ApiExplorer/types.d.ts +0 -0
  362. /package/dist/{studio/src/components → components}/RLSEditor/index.d.ts +0 -0
  363. /package/dist/{studio/src/components → components}/RebaseStudio.d.ts +0 -0
  364. /package/dist/{studio/src/components → components}/SQLEditor/ExplainVisualizer.d.ts +0 -0
  365. /package/dist/{studio/src/components → components}/SchemaVisualizer/schema-visualizer.utils.d.ts +0 -0
  366. /package/dist/{studio/src/components → components}/SchemaVisualizer/useSchemaGraph.d.ts +0 -0
  367. /package/dist/{studio/src/index.d.ts → index.d.ts} +0 -0
  368. /package/dist/{studio/src/utils → utils}/pgColumnToProperty.d.ts +0 -0
  369. /package/dist/{studio/src/utils → utils}/sql_utils.d.ts +0 -0
@@ -1,1297 +0,0 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { c } from "react-compiler-runtime";
3
- import { useRef, useState, useMemo, useEffect, useCallback } from "react";
4
- import { themes, Highlight } from "prism-react-renderer";
5
- import { toSnakeCase } from "@rebasepro/utils";
6
- import { cls, Tabs, Tab, Tooltip, Typography, defaultBorderMixin, PlusIcon, iconSize, Trash2Icon, IconButton, ResizablePanels, TerminalIcon, XIcon, SaveIcon, DownloadIcon, Button, CircularProgress, PlayIcon, Chip, VirtualTable, PencilIcon, Menu, MenuItem, MoreVerticalIcon, Dialog, DialogTitle, DialogContent, TextField, DialogActions } from "@rebasepro/ui";
7
- import { useModeController, useRebaseContext, useRebaseClient, useApiConfig, useSnackbarController, useStudioCollectionRegistry, useStudioSideEntityController, useTranslation, ErrorView, IconForView } from "@rebasepro/core";
8
- import { createRebaseClient } from "@rebasepro/client";
9
- import Editor from "@monaco-editor/react";
10
- import { A as AuthSimulationSelector } from "./AuthSimulationSelector-DGoXkWSg.js";
11
- const REBASE_CLIENT_TYPES = `
12
- // ─── Rebase Client SDK Type Definitions ─────────────────────────────
13
-
14
- interface Entity<M extends Record<string, any> = any> {
15
- id: string | number;
16
- path: string;
17
- values: M;
18
- }
19
-
20
- interface FindParams {
21
- limit?: number;
22
- offset?: number;
23
- page?: number;
24
- where?: Record<string, string>;
25
- orderBy?: string;
26
- include?: string[];
27
- searchString?: string;
28
- }
29
-
30
- interface FindResponse<M extends Record<string, any> = any> {
31
- data: Entity<M>[];
32
- meta: {
33
- total: number;
34
- limit: number;
35
- offset: number;
36
- hasMore: boolean;
37
- };
38
- }
39
-
40
- type FilterOperator = "=" | "!=" | ">" | ">=" | "<" | "<=" | "in" | "not-in" | "array-contains" | "array-contains-any" | "is" | "is_not" | "like" | "ilike";
41
-
42
- interface QueryBuilder<M extends Record<string, any> = any> {
43
- where(column: keyof M & string, operator: FilterOperator, value: any): QueryBuilder<M>;
44
- orderBy(column: keyof M & string, direction?: "asc" | "desc"): QueryBuilder<M>;
45
- limit(count: number): QueryBuilder<M>;
46
- offset(count: number): QueryBuilder<M>;
47
- search(searchString: string): QueryBuilder<M>;
48
- find(): Promise<FindResponse<M>>;
49
- findOne(): Promise<Entity<M> | undefined>;
50
- count(): Promise<number>;
51
- }
52
-
53
- interface CollectionClient<M extends Record<string, any> = any> {
54
- find(params?: FindParams): Promise<FindResponse<M>>;
55
- findById(id: string | number): Promise<Entity<M> | undefined>;
56
- create(data: Partial<M>, id?: string | number): Promise<Entity<M>>;
57
- update(id: string | number, data: Partial<M>): Promise<Entity<M>>;
58
- delete(id: string | number): Promise<void>;
59
- where(column: keyof M & string, operator: FilterOperator, value: any): QueryBuilder<M>;
60
- orderBy(column: keyof M & string, direction?: "asc" | "desc"): QueryBuilder<M>;
61
- limit(count: number): QueryBuilder<M>;
62
- offset(count: number): QueryBuilder<M>;
63
- search(searchString: string): QueryBuilder<M>;
64
- listen?(params: FindParams | undefined, onUpdate: (response: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
65
- listenById?(id: string | number, onUpdate: (entity: Entity<M> | undefined) => void, onError?: (error: Error) => void): () => void;
66
- count?(params?: FindParams): Promise<number>;
67
- }
68
-
69
- interface RebaseUser {
70
- uid: string;
71
- email: string | null;
72
- displayName: string | null;
73
- photoURL: string | null;
74
- emailVerified?: boolean;
75
- roles?: string[];
76
- providerId: string;
77
- isAnonymous: boolean;
78
- }
79
-
80
- interface RebaseSession {
81
- accessToken: string;
82
- refreshToken: string;
83
- expiresAt: number;
84
- user: RebaseUser;
85
- }
86
-
87
- type AuthChangeEvent = 'SIGNED_IN' | 'SIGNED_OUT' | 'TOKEN_REFRESHED' | 'USER_UPDATED';
88
-
89
- interface RebaseAuth {
90
- signInWithEmail(email: string, password: string): Promise<{ user: RebaseUser; accessToken: string; refreshToken: string }>;
91
- signUp(email: string, password: string, displayName?: string): Promise<{ user: RebaseUser; accessToken: string; refreshToken: string }>;
92
- signInWithGoogle(idToken: string): Promise<{ user: RebaseUser; accessToken: string; refreshToken: string }>;
93
- signOut(): Promise<void>;
94
- refreshSession(): Promise<RebaseSession>;
95
- getUser(): Promise<RebaseUser>;
96
- updateUser(updates: { displayName?: string; photoURL?: string }): Promise<RebaseUser>;
97
- resetPasswordForEmail(email: string): Promise<{ success: boolean; message: string }>;
98
- resetPassword(token: string, password: string): Promise<{ success: boolean; message: string }>;
99
- changePassword(oldPassword: string, newPassword: string): Promise<{ success: boolean; message: string }>;
100
- sendVerificationEmail(): Promise<{ success: boolean; message: string }>;
101
- verifyEmail(token: string): Promise<{ success: boolean; message: string }>;
102
- getSessions(): Promise<RebaseSession[]>;
103
- revokeSession(sessionId: string): Promise<{ success: boolean }>;
104
- revokeAllSessions(): Promise<{ success: boolean }>;
105
- getSession(): RebaseSession | null;
106
- onAuthStateChange(callback: (event: AuthChangeEvent, session: RebaseSession | null) => void): () => void;
107
- }
108
-
109
- interface AdminUser {
110
- uid: string;
111
- email: string;
112
- displayName: string | null;
113
- photoURL: string | null;
114
- provider: string;
115
- roles: string[];
116
- createdAt: string;
117
- updatedAt: string;
118
- }
119
-
120
- interface RebaseAdmin {
121
- listUsers(): Promise<{ users: AdminUser[] }>;
122
- getUser(userId: string): Promise<{ user: AdminUser }>;
123
- createUser(data: { email: string; displayName?: string; password?: string; roles?: string[] }): Promise<{ user: AdminUser }>;
124
- updateUser(userId: string, data: { email?: string; displayName?: string; password?: string; roles?: string[] }): Promise<{ user: AdminUser }>;
125
- deleteUser(userId: string): Promise<{ success: boolean }>;
126
- bootstrap(): Promise<{ success: boolean; message: string; user: { uid: string; roles: string[] } }>;
127
- }
128
-
129
- interface UploadFileProps {
130
- file: FileIcon;
131
- fileName?: string;
132
- path?: string;
133
- metadata?: Record<string, unknown>;
134
- bucket?: string;
135
- }
136
-
137
- interface UploadFileResult {
138
- path: string;
139
- bucket?: string;
140
- downloadUrl?: string;
141
- }
142
-
143
- interface DownloadConfig {
144
- url: string | null;
145
- fileNotFound?: boolean;
146
- metadata?: Record<string, unknown>;
147
- }
148
-
149
- interface StorageSource {
150
- putObject(props: UploadFileProps): Promise<UploadFileResult>;
151
- getSignedUrl(pathOrUrl: string, bucket?: string): Promise<DownloadConfig>;
152
- getObject(path: string, bucket?: string): Promise<FileIcon | null>;
153
- deleteObject(path: string, bucket?: string): Promise<void>;
154
- listObjects(path: string, options?: { bucket?: string; maxResults?: number; pageToken?: string }): Promise<unknown>;
155
- }
156
-
157
- type RebaseData = {
158
- /** Look up a collection by slug. */
159
- collection(slug: string): CollectionClient;
160
- } & {
161
- /** Dynamic collection access — e.g. client.data.authors */
162
- [collectionSlug: string]: CollectionClient;
163
- };
164
-
165
- /**
166
- * The Rebase client instance. Use \`client.data\`, \`client.auth\`, \`client.admin\`,
167
- * \`client.storage\`, and \`client.call()\` to interact with your Rebase backend.
168
- *
169
- * @example
170
- * // Query a collection
171
- * const result = await client.data.products.find({ limit: 10 });
172
- *
173
- * // Create a record
174
- * await client.data.products.create({ name: "Camera", price: 299 });
175
- *
176
- * // Fluent query
177
- * const expensive = await client.data.products.where("price", ">", 100).orderBy("price", "desc").limit(5).find();
178
- *
179
- * // Auth
180
- * const session = client.auth.getSession();
181
- *
182
- * // Admin
183
- * const { users } = await client.admin.listUsers();
184
- *
185
- * // Custom endpoint
186
- * const result = await client.call("/my-endpoint", { myData: 123 });
187
- */
188
- interface RebaseClient {
189
- /** Data access — dynamic collection accessors */
190
- data: RebaseData;
191
- /** Authentication methods */
192
- auth: RebaseAuth;
193
- /** User/role admin methods */
194
- admin: RebaseAdmin;
195
- /** Storage operations */
196
- storage?: StorageSource;
197
- /** Call a custom server-side endpoint */
198
- call<T = unknown>(endpoint: string, payload?: unknown): Promise<T>;
199
- /** Direct collection access (shorthand) */
200
- [collectionSlug: string]: unknown;
201
- }
202
-
203
- /** The pre-configured client instance. Already authenticated with the current user session. */
204
- declare const client: RebaseClient;
205
-
206
- /** Execution context with user and collection information. */
207
- interface JSEditorContext {
208
- /** The user the script is running as. */
209
- user: {
210
- uid: string;
211
- displayName: string | null;
212
- email: string | null;
213
- roles?: string[];
214
- } | null;
215
- /** Registered collections with their property names. */
216
- collections: Array<{
217
- slug: string;
218
- name: string;
219
- properties: string[];
220
- }>;
221
- }
222
-
223
- /** Execution context — contains info about the selected user and registered collections. */
224
- declare const context: JSEditorContext;
225
- `;
226
- const JSMonacoEditor = ({
227
- value,
228
- onChange,
229
- onRun,
230
- className,
231
- readOnly = false,
232
- autoFocus = true,
233
- collectionSlugs = [],
234
- collections = []
235
- }) => {
236
- const {
237
- mode
238
- } = useModeController();
239
- const editorRef = useRef(null);
240
- const monacoRef = useRef(null);
241
- const onRunRef = useRef(onRun);
242
- onRunRef.current = onRun;
243
- const typesRegisteredRef = useRef(false);
244
- const handleEditorOnMount = (editorInstance, monaco) => {
245
- editorRef.current = editorInstance;
246
- monacoRef.current = monaco;
247
- editorInstance.addAction({
248
- id: "run-script",
249
- label: "Run Script",
250
- keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter],
251
- contextMenuGroupId: "operation",
252
- contextMenuOrder: 0,
253
- run: () => {
254
- if (onRunRef.current) {
255
- const selection = editorInstance.getSelection();
256
- let selectedText;
257
- if (selection && !selection.isEmpty()) {
258
- selectedText = editorInstance.getModel()?.getValueInRange(selection)?.trim();
259
- }
260
- onRunRef.current(selectedText || void 0);
261
- }
262
- }
263
- });
264
- if (!typesRegisteredRef.current) {
265
- typesRegisteredRef.current = true;
266
- const ts = monaco.languages.typescript;
267
- ts.typescriptDefaults.setCompilerOptions({
268
- target: ts.ScriptTarget.ESNext,
269
- module: ts.ModuleKind.ESNext,
270
- allowJs: true,
271
- checkJs: false,
272
- strict: false,
273
- noEmit: true,
274
- allowNonTsExtensions: true
275
- });
276
- ts.typescriptDefaults.setDiagnosticsOptions({
277
- diagnosticCodesToIgnore: [1375, 1108]
278
- });
279
- ts.typescriptDefaults.addExtraLib(REBASE_CLIENT_TYPES, "ts:rebase-client.d.ts");
280
- if (collections.length > 0) {
281
- const lines = [];
282
- for (const col of collections) {
283
- const ifaceName = col.slug.replace(/[^a-zA-Z0-9_]/g, "_");
284
- const propsType = col.properties.length > 0 ? `{ ${col.properties.map((p) => `${p}: any`).join("; ")} }` : "Record<string, any>";
285
- lines.push(`/** Collection: ${col.name} (${col.slug}) */`);
286
- lines.push(`interface ${ifaceName}_Row ${propsType}`);
287
- lines.push(`declare namespace client.data { const ${col.slug}: CollectionClient<${ifaceName}_Row>; }`);
288
- }
289
- ts.typescriptDefaults.addExtraLib(lines.join("\n"), "ts:rebase-collections.d.ts");
290
- } else if (collectionSlugs.length > 0) {
291
- const collectionHints = collectionSlugs.map((slug) => `/** Collection: ${slug} */
292
- declare namespace client.data { const ${slug}: CollectionClient; }`).join("\n");
293
- ts.typescriptDefaults.addExtraLib(collectionHints, "ts:rebase-collections.d.ts");
294
- }
295
- }
296
- if (autoFocus) {
297
- editorInstance.focus();
298
- }
299
- };
300
- return /* @__PURE__ */ jsx("div", { className: cls("relative w-full h-full overflow-hidden", className), children: /* @__PURE__ */ jsx(Editor, { height: "100%", defaultLanguage: "typescript", path: "rebase-script.ts", value, onChange, onMount: handleEditorOnMount, theme: mode === "dark" ? "vs-dark" : "vs", options: {
301
- minimap: {
302
- enabled: false
303
- },
304
- fontSize: 14,
305
- lineNumbers: "on",
306
- scrollBeyondLastLine: false,
307
- automaticLayout: true,
308
- readOnly,
309
- tabSize: 2,
310
- wordWrap: "on",
311
- suggestOnTriggerCharacters: true,
312
- quickSuggestions: true,
313
- parameterHints: {
314
- enabled: true
315
- }
316
- } }) });
317
- };
318
- const QUICK_REFERENCE = [{
319
- label: "Find all",
320
- code: 'const result = await client.data.collection("COLLECTION").find({ limit: 20 });\nreturn result;',
321
- description: "Fetch records with pagination"
322
- }, {
323
- label: "Find by ID",
324
- code: 'const item = await client.data.collection("COLLECTION").findById("ID");\nreturn item;',
325
- description: "Fetch a single record"
326
- }, {
327
- label: "Create",
328
- code: 'const created = await client.data.collection("COLLECTION").create({\n // your fields here\n});\nreturn created;',
329
- description: "Insert a new record"
330
- }, {
331
- label: "Update",
332
- code: 'const updated = await client.data.collection("COLLECTION").update("ID", {\n // fields to update\n});\nreturn updated;',
333
- description: "Update an existing record"
334
- }, {
335
- label: "Delete",
336
- code: 'await client.data.collection("COLLECTION").delete("ID");\nreturn { success: true };',
337
- description: "Delete a record"
338
- }, {
339
- label: "Fluent query",
340
- code: 'const result = await client.data.collection("COLLECTION")\n .where("field", ">", value)\n .orderBy("field", "desc")\n .limit(10)\n .find();\nreturn result;',
341
- description: "Chained query builder"
342
- }, {
343
- label: "Auth: Current session",
344
- code: "const session = client.auth.getSession();\nreturn session;",
345
- description: "Get current auth session"
346
- }, {
347
- label: "Admin: List users",
348
- code: "const { users } = await client.admin.listUsers();\nreturn users;",
349
- description: "List all registered users"
350
- }, {
351
- label: "Custom endpoint",
352
- code: 'const result = await client.call("/my-endpoint", { key: "value" });\nreturn result;',
353
- description: "Call a custom API endpoint"
354
- }];
355
- const JSEditorSidebar = ({
356
- collections,
357
- snippets,
358
- history,
359
- onSelectSnippet,
360
- onDeleteSnippet,
361
- onInsertCode
362
- }) => {
363
- const [activeTab, setActiveTab] = useState("collections");
364
- return /* @__PURE__ */ jsxs("div", { className: cls("flex flex-col h-full w-full bg-white dark:bg-surface-950 border-r", defaultBorderMixin), children: [
365
- /* @__PURE__ */ jsxs(Tabs, { value: activeTab, onValueChange: (v) => setActiveTab(v), variant: "boxy", className: "border-b border-surface-200 dark:border-surface-950", children: [
366
- /* @__PURE__ */ jsx(Tab, { value: "collections", children: /* @__PURE__ */ jsx(Tooltip, { title: "Browse collections", children: /* @__PURE__ */ jsx("span", { className: "text-xs", children: "Collections" }) }) }),
367
- /* @__PURE__ */ jsx(Tab, { value: "reference", children: /* @__PURE__ */ jsx(Tooltip, { title: "SDK quick reference", children: /* @__PURE__ */ jsx("span", { className: "text-xs", children: "Reference" }) }) }),
368
- /* @__PURE__ */ jsx(Tab, { value: "snippets", children: /* @__PURE__ */ jsx("span", { className: "text-xs", children: "Snippets" }) }),
369
- /* @__PURE__ */ jsx(Tab, { value: "history", children: /* @__PURE__ */ jsx("span", { className: "text-xs", children: "History" }) })
370
- ] }),
371
- /* @__PURE__ */ jsxs("div", { className: "flex-grow overflow-hidden relative", children: [
372
- activeTab === "collections" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
373
- /* @__PURE__ */ jsx("div", { className: cls("flex items-center justify-between px-3 py-2 border-b bg-surface-50 dark:bg-surface-900 min-h-[48px]", defaultBorderMixin), children: /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "font-bold uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark", children: "Collections" }) }),
374
- /* @__PURE__ */ jsx("div", { className: "flex-grow overflow-y-auto p-1 space-y-1 no-scrollbar", children: collections.length === 0 ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-disabled dark:text-text-disabled-dark", children: "No collections found" }) }) : collections.map((col) => /* @__PURE__ */ jsx(CollectionItem, { collection: col, onInsertCode }, col.slug)) })
375
- ] }),
376
- activeTab === "reference" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
377
- /* @__PURE__ */ jsx("div", { className: cls("flex items-center justify-between px-3 py-2 border-b bg-surface-50 dark:bg-surface-900 min-h-[48px]", defaultBorderMixin), children: /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "font-bold uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark", children: "SDK Reference" }) }),
378
- /* @__PURE__ */ jsx("div", { className: "flex-grow overflow-y-auto p-2 space-y-2 no-scrollbar", children: QUICK_REFERENCE.map((ref, i) => /* @__PURE__ */ jsxs("div", { className: cls("group p-2.5 rounded-lg border hover:border-primary/40 dark:hover:border-primary/40", "bg-white dark:bg-surface-900 transition-all cursor-pointer", defaultBorderMixin), onClick: () => onInsertCode(ref.code), children: [
379
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-1", children: [
380
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-text-primary dark:text-text-primary-dark font-semibold text-[13px]", children: ref.label }),
381
- /* @__PURE__ */ jsx("svg", { className: "w-3.5 h-3.5 text-text-disabled group-hover:text-primary transition-colors", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" }) })
382
- ] }),
383
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-disabled dark:text-text-disabled-dark text-[10px] leading-tight", children: ref.description })
384
- ] }, i)) })
385
- ] }),
386
- activeTab === "snippets" && (() => {
387
- const favorites = snippets.filter((s) => s.isFavorite);
388
- const others = snippets.filter((s_0) => !s_0.isFavorite);
389
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
390
- /* @__PURE__ */ jsx("div", { className: cls("flex items-center justify-between px-3 py-2 border-b bg-surface-50 dark:bg-surface-900 min-h-[48px]", defaultBorderMixin), children: /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "font-bold uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark", children: "Snippets" }) }),
391
- /* @__PURE__ */ jsx("div", { className: "flex-grow overflow-y-auto p-2 space-y-2 no-scrollbar", children: snippets.length === 0 ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-disabled dark:text-text-disabled-dark", children: "No saved snippets yet. Use the save button to store reusable code." }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
392
- favorites.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mb-3", children: [
393
- /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-[10px] font-bold uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark mb-2 px-1 flex items-center", children: [
394
- /* @__PURE__ */ jsx("svg", { className: "w-3 h-3 mr-1 text-amber-500", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx("path", { d: "M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" }) }),
395
- "Favorites"
396
- ] }),
397
- /* @__PURE__ */ jsx("div", { className: "space-y-2", children: favorites.map((snippet) => /* @__PURE__ */ jsx(SnippetItem, { snippet, onSelect: onSelectSnippet, onDelete: onDeleteSnippet }, snippet.id)) })
398
- ] }),
399
- others.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
400
- favorites.length > 0 && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] font-bold uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark mb-2 px-1", children: "Others" }),
401
- /* @__PURE__ */ jsx("div", { className: "space-y-2", children: others.map((snippet_0) => /* @__PURE__ */ jsx(SnippetItem, { snippet: snippet_0, onSelect: onSelectSnippet, onDelete: onDeleteSnippet }, snippet_0.id)) })
402
- ] })
403
- ] }) })
404
- ] });
405
- })(),
406
- activeTab === "history" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
407
- /* @__PURE__ */ jsx("div", { className: cls("flex items-center justify-between px-3 py-2 border-b bg-surface-50 dark:bg-surface-900 min-h-[48px]", defaultBorderMixin), children: /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "font-bold uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark", children: "History" }) }),
408
- /* @__PURE__ */ jsx("div", { className: "flex-grow overflow-y-auto p-1 space-y-1 no-scrollbar", children: history.length === 0 ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-disabled dark:text-text-disabled-dark", children: "No execution history yet" }) }) : [...history].reverse().map((code, i_0) => /* @__PURE__ */ jsxs("div", { className: "p-2 py-1.5 rounded hover:bg-surface-100 dark:hover:bg-surface-950 cursor-pointer group transition-colors flex items-start", onClick: () => onSelectSnippet(code), children: [
409
- /* @__PURE__ */ jsx("svg", { className: "w-3 h-3 mt-1 mr-2 text-text-disabled dark:text-text-disabled-dark group-hover:text-primary transition-colors flex-shrink-0", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
410
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary dark:text-text-secondary-dark group-hover:text-text-primary dark:group-hover:text-text-primary-dark text-[11px] line-clamp-2 leading-tight flex-grow font-mono", children: code.length > 120 ? code.substring(0, 120) + "…" : code })
411
- ] }, i_0)) })
412
- ] })
413
- ] })
414
- ] });
415
- };
416
- function CollectionItem(t0) {
417
- const $ = c(28);
418
- const {
419
- collection,
420
- onInsertCode
421
- } = t0;
422
- const [expanded, setExpanded] = useState(false);
423
- let t1;
424
- if ($[0] !== expanded) {
425
- t1 = () => setExpanded(!expanded);
426
- $[0] = expanded;
427
- $[1] = t1;
428
- } else {
429
- t1 = $[1];
430
- }
431
- const t2 = expanded && "rotate-90";
432
- let t3;
433
- if ($[2] !== t2) {
434
- t3 = cls("w-3 h-3 mr-1 transition-transform", t2);
435
- $[2] = t2;
436
- $[3] = t3;
437
- } else {
438
- t3 = $[3];
439
- }
440
- let t4;
441
- if ($[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
442
- t4 = /* @__PURE__ */ jsx("path", { d: "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" });
443
- $[4] = t4;
444
- } else {
445
- t4 = $[4];
446
- }
447
- let t5;
448
- if ($[5] !== t3) {
449
- t5 = /* @__PURE__ */ jsx("svg", { className: t3, fill: "currentColor", viewBox: "0 0 20 20", children: t4 });
450
- $[5] = t3;
451
- $[6] = t5;
452
- } else {
453
- t5 = $[6];
454
- }
455
- let t6;
456
- if ($[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
457
- t6 = /* @__PURE__ */ jsx("svg", { className: "w-3.5 h-3.5 mr-1 shrink-0 text-text-disabled dark:text-text-disabled-dark", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4" }) });
458
- $[7] = t6;
459
- } else {
460
- t6 = $[7];
461
- }
462
- let t7;
463
- if ($[8] !== collection.slug) {
464
- t7 = /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-text-secondary dark:text-text-secondary-dark text-xs truncate flex-1 min-w-0", children: collection.slug });
465
- $[8] = collection.slug;
466
- $[9] = t7;
467
- } else {
468
- t7 = $[9];
469
- }
470
- let t8;
471
- if ($[10] !== collection.slug || $[11] !== onInsertCode) {
472
- t8 = (e) => {
473
- e.stopPropagation();
474
- onInsertCode(`const result = await client.data.${collection.slug}.find({ limit: 20 });
475
- return result;`);
476
- };
477
- $[10] = collection.slug;
478
- $[11] = onInsertCode;
479
- $[12] = t8;
480
- } else {
481
- t8 = $[12];
482
- }
483
- let t9;
484
- if ($[13] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
485
- t9 = /* @__PURE__ */ jsx(PlusIcon, { size: iconSize.smallest });
486
- $[13] = t9;
487
- } else {
488
- t9 = $[13];
489
- }
490
- let t10;
491
- if ($[14] !== t8) {
492
- t10 = /* @__PURE__ */ jsx(Tooltip, { title: "Insert find() snippet", children: /* @__PURE__ */ jsx(IconButton, { size: "smallest", className: "opacity-0 group-hover:opacity-100 text-text-disabled hover:text-primary transition-all", onClick: t8, children: t9 }) });
493
- $[14] = t8;
494
- $[15] = t10;
495
- } else {
496
- t10 = $[15];
497
- }
498
- let t11;
499
- if ($[16] !== t1 || $[17] !== t10 || $[18] !== t5 || $[19] !== t7) {
500
- t11 = /* @__PURE__ */ jsxs("div", { className: "flex items-center p-1 cursor-pointer hover:bg-surface-100 dark:hover:bg-surface-950 rounded transition-colors group relative", onClick: t1, children: [
501
- t5,
502
- t6,
503
- t7,
504
- t10
505
- ] });
506
- $[16] = t1;
507
- $[17] = t10;
508
- $[18] = t5;
509
- $[19] = t7;
510
- $[20] = t11;
511
- } else {
512
- t11 = $[20];
513
- }
514
- let t12;
515
- if ($[21] !== collection.properties || $[22] !== expanded || $[23] !== onInsertCode) {
516
- t12 = expanded && collection.properties.length > 0 && /* @__PURE__ */ jsx("div", { className: cls("ml-5 mt-1 space-y-0.5 border-l", defaultBorderMixin), children: collection.properties.map((prop) => /* @__PURE__ */ jsxs("div", { className: "flex items-center p-1 pl-2 hover:bg-surface-50 dark:hover:bg-surface-950 rounded-r cursor-pointer transition-colors group/prop relative min-h-[28px]", onClick: () => onInsertCode(`"${prop}"`), children: [
517
- /* @__PURE__ */ jsx("svg", { className: "w-3 h-3 mr-1.5 text-text-disabled dark:text-text-disabled-dark shrink-0", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M9 4.5v15m6-15v15m-10.5-1.5h15c.621 0 1.125-.504 1.125-1.125V5.625c0-.621-.504-1.125-1.125-1.125h-15c-.621 0-1.125.504-1.125 1.125v12.75c0 .621.504 1.125 1.125 1.125Z" }) }),
518
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-primary dark:text-text-primary-dark text-[11px] truncate flex-grow font-mono", children: prop })
519
- ] }, prop)) });
520
- $[21] = collection.properties;
521
- $[22] = expanded;
522
- $[23] = onInsertCode;
523
- $[24] = t12;
524
- } else {
525
- t12 = $[24];
526
- }
527
- let t13;
528
- if ($[25] !== t11 || $[26] !== t12) {
529
- t13 = /* @__PURE__ */ jsxs("div", { children: [
530
- t11,
531
- t12
532
- ] });
533
- $[25] = t11;
534
- $[26] = t12;
535
- $[27] = t13;
536
- } else {
537
- t13 = $[27];
538
- }
539
- return t13;
540
- }
541
- function SnippetItem(t0) {
542
- const $ = c(19);
543
- const {
544
- snippet,
545
- onSelect,
546
- onDelete
547
- } = t0;
548
- let t1;
549
- if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
550
- t1 = cls("group p-2 rounded border hover:border-surface-400 dark:hover:border-surface-600 bg-white dark:bg-surface-900 transition-all cursor-pointer relative", defaultBorderMixin);
551
- $[0] = t1;
552
- } else {
553
- t1 = $[0];
554
- }
555
- let t2;
556
- if ($[1] !== onSelect || $[2] !== snippet.code) {
557
- t2 = () => onSelect(snippet.code);
558
- $[1] = onSelect;
559
- $[2] = snippet.code;
560
- $[3] = t2;
561
- } else {
562
- t2 = $[3];
563
- }
564
- let t3;
565
- if ($[4] !== snippet.name) {
566
- t3 = /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-text-primary dark:text-text-primary-dark font-medium text-[13px] truncate pr-6", children: snippet.name });
567
- $[4] = snippet.name;
568
- $[5] = t3;
569
- } else {
570
- t3 = $[5];
571
- }
572
- let t4;
573
- if ($[6] !== snippet.code) {
574
- t4 = /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary dark:text-text-secondary-dark text-[10px] block mt-1 truncate font-mono", children: snippet.code });
575
- $[6] = snippet.code;
576
- $[7] = t4;
577
- } else {
578
- t4 = $[7];
579
- }
580
- let t5;
581
- if ($[8] !== onDelete || $[9] !== snippet.id) {
582
- t5 = (e) => {
583
- e.stopPropagation();
584
- onDelete(snippet.id);
585
- };
586
- $[8] = onDelete;
587
- $[9] = snippet.id;
588
- $[10] = t5;
589
- } else {
590
- t5 = $[10];
591
- }
592
- let t6;
593
- if ($[11] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
594
- t6 = /* @__PURE__ */ jsx(Trash2Icon, { size: iconSize.smallest });
595
- $[11] = t6;
596
- } else {
597
- t6 = $[11];
598
- }
599
- let t7;
600
- if ($[12] !== t5) {
601
- t7 = /* @__PURE__ */ jsx(IconButton, { size: "smallest", className: "absolute right-1 top-1 opacity-0 group-hover:opacity-100 text-text-disabled hover:text-red-500 transition-opacity", onClick: t5, children: t6 });
602
- $[12] = t5;
603
- $[13] = t7;
604
- } else {
605
- t7 = $[13];
606
- }
607
- let t8;
608
- if ($[14] !== t2 || $[15] !== t3 || $[16] !== t4 || $[17] !== t7) {
609
- t8 = /* @__PURE__ */ jsxs("div", { className: t1, onClick: t2, children: [
610
- t3,
611
- t4,
612
- t7
613
- ] });
614
- $[14] = t2;
615
- $[15] = t3;
616
- $[16] = t4;
617
- $[17] = t7;
618
- $[18] = t8;
619
- } else {
620
- t8 = $[18];
621
- }
622
- return t8;
623
- }
624
- const STORAGE_PREFIX = "rebase_js_";
625
- const DEFAULT_CODE = `// Available: client (RebaseClient)
626
- // Press Cmd+Enter (Ctrl+Enter) to run
627
- //
628
- // Examples:
629
- // const result = await client.data.collection("your_collection").find({ limit: 10 });
630
- // const users = await client.admin.listUsers();
631
- // const session = client.auth.getSession();
632
-
633
- const result = await client.data.collection("your_collection").find({ limit: 10 });
634
- return result;
635
- `;
636
- function loadFromStorage(key, fallback) {
637
- try {
638
- const raw = localStorage.getItem(STORAGE_PREFIX + key);
639
- return raw ? JSON.parse(raw) : fallback;
640
- } catch {
641
- return fallback;
642
- }
643
- }
644
- function saveToStorage(key, value) {
645
- try {
646
- localStorage.setItem(STORAGE_PREFIX + key, JSON.stringify(value));
647
- } catch {
648
- }
649
- }
650
- function formatJSON(value) {
651
- try {
652
- return JSON.stringify(value, null, 2);
653
- } catch {
654
- return String(value);
655
- }
656
- }
657
- function detectCollectionsInResult(code, resultValue, collections) {
658
- if (!resultValue || !collections?.length) return [];
659
- const mentionedSlugs = /* @__PURE__ */ new Set();
660
- const collectionCallRegex = /\.collection\(["']([^"']+)["']\)/g;
661
- let m;
662
- while ((m = collectionCallRegex.exec(code)) !== null) {
663
- mentionedSlugs.add(m[1]);
664
- }
665
- const dotAccessRegex = /client\.data\.([a-zA-Z_][a-zA-Z0-9_]*)\./g;
666
- while ((m = dotAccessRegex.exec(code)) !== null) {
667
- if (!["collection", "find", "findById", "create", "update", "delete"].includes(m[1])) {
668
- mentionedSlugs.add(m[1]);
669
- }
670
- }
671
- if (mentionedSlugs.size === 0) return [];
672
- let rows = [];
673
- const rv = resultValue;
674
- if (rv?.data && Array.isArray(rv.data)) {
675
- rows = rv.data;
676
- } else if (Array.isArray(resultValue)) {
677
- rows = resultValue;
678
- }
679
- const hasId = rows.length > 0 && rows.some((r) => r?.id != null);
680
- if (!hasId) return [];
681
- const matched = [];
682
- for (const slug of mentionedSlugs) {
683
- const normalised = toSnakeCase(slug);
684
- const col = collections.find((c2) => {
685
- const tableName = ("table" in c2 ? c2.table : void 0) || toSnakeCase(c2.slug);
686
- return c2.slug === slug || tableName === normalised || toSnakeCase(c2.slug) === normalised;
687
- });
688
- if (col) {
689
- matched.push({
690
- collectionSlug: col.slug,
691
- collection: col,
692
- pkColumn: "id"
693
- });
694
- }
695
- }
696
- return matched;
697
- }
698
- function JSEditor() {
699
- const rebaseContext = useRebaseContext();
700
- const rebaseClient = useRebaseClient();
701
- const apiConfig = useApiConfig();
702
- const snackbar = useSnackbarController();
703
- const collectionRegistry = useStudioCollectionRegistry();
704
- const sideEntityController = useStudioSideEntityController();
705
- const {
706
- t
707
- } = useTranslation();
708
- const userManagement = rebaseContext.userManagement;
709
- const currentUser = rebaseContext.authController?.user;
710
- const [tabs, setTabs] = useState(() => loadFromStorage("tabs", [{
711
- id: "1",
712
- name: "Script 1",
713
- code: DEFAULT_CODE
714
- }]));
715
- const [activeTabId, setActiveTabId] = useState(() => loadFromStorage("activeTab", "1"));
716
- const [result, setResult] = useState(null);
717
- const [isRunning, setIsRunning] = useState(false);
718
- const [snippets, setSnippets] = useState(() => loadFromStorage("snippets", []));
719
- const [history, setHistory] = useState(() => loadFromStorage("history", []));
720
- const [showSaveDialog, setShowSaveDialog] = useState(false);
721
- const [snippetName, setSnippetName] = useState("");
722
- const [resultView, setResultView] = useState("json");
723
- const [selectedUser, setSelectedUser] = useState(null);
724
- const [authMode, setAuthMode] = useState("jwt");
725
- const [sidebarSize, setSidebarSize] = useState(() => {
726
- try {
727
- const stored = localStorage.getItem(STORAGE_PREFIX + "sidebar_size");
728
- return stored ? Number(stored) : 18;
729
- } catch {
730
- return 18;
731
- }
732
- });
733
- const [editorHeight, setEditorHeight] = useState(() => {
734
- try {
735
- const stored_0 = localStorage.getItem(STORAGE_PREFIX + "editor_height");
736
- return stored_0 ? Number(stored_0) : 55;
737
- } catch {
738
- return 55;
739
- }
740
- });
741
- const activeTab = tabs.find((t_0) => t_0.id === activeTabId) ?? tabs[0];
742
- const collectionInfos = useMemo(() => {
743
- const collections = collectionRegistry?.collections ?? [];
744
- return collections.map((col) => ({
745
- slug: col.slug,
746
- name: col.name,
747
- properties: Object.keys(col.properties ?? {})
748
- }));
749
- }, [collectionRegistry?.collections]);
750
- const collectionSlugs = useMemo(() => collectionInfos.map((c2) => c2.slug), [collectionInfos]);
751
- const users = useMemo(() => {
752
- const managed = (userManagement?.users ?? []).map((u) => ({
753
- uid: u.uid,
754
- displayName: u.displayName,
755
- email: u.email,
756
- photoURL: u.photoURL,
757
- roles: u.roles
758
- }));
759
- if (currentUser && !managed.some((u_0) => u_0.uid === currentUser.uid)) {
760
- managed.unshift({
761
- uid: currentUser.uid,
762
- displayName: currentUser.displayName,
763
- email: currentUser.email,
764
- photoURL: currentUser.photoURL,
765
- roles: currentUser.roles
766
- });
767
- }
768
- return managed;
769
- }, [userManagement?.users, currentUser]);
770
- const currentSelectableUser = useMemo(() => {
771
- if (!currentUser) return null;
772
- return {
773
- uid: currentUser.uid,
774
- displayName: currentUser.displayName,
775
- email: currentUser.email,
776
- photoURL: currentUser.photoURL,
777
- roles: currentUser.roles
778
- };
779
- }, [currentUser]);
780
- useEffect(() => {
781
- saveToStorage("tabs", tabs);
782
- }, [tabs]);
783
- useEffect(() => {
784
- saveToStorage("activeTab", activeTabId);
785
- }, [activeTabId]);
786
- useEffect(() => {
787
- saveToStorage("snippets", snippets);
788
- }, [snippets]);
789
- useEffect(() => {
790
- saveToStorage("history", history);
791
- }, [history]);
792
- useEffect(() => {
793
- try {
794
- localStorage.setItem(STORAGE_PREFIX + "sidebar_size", sidebarSize.toString());
795
- } catch {
796
- }
797
- }, [sidebarSize]);
798
- useEffect(() => {
799
- try {
800
- localStorage.setItem(STORAGE_PREFIX + "editor_height", editorHeight.toString());
801
- } catch {
802
- }
803
- }, [editorHeight]);
804
- const updateActiveCode = useCallback((code) => {
805
- setTabs((prev) => prev.map((t_1) => t_1.id === activeTabId ? {
806
- ...t_1,
807
- code: code ?? ""
808
- } : t_1));
809
- }, [activeTabId]);
810
- const addTab = useCallback(() => {
811
- const id = String(Date.now());
812
- const newTab = {
813
- id,
814
- name: `Script ${tabs.length + 1}`,
815
- code: DEFAULT_CODE
816
- };
817
- setTabs((prev_0) => [...prev_0, newTab]);
818
- setActiveTabId(id);
819
- }, [tabs.length]);
820
- const closeTab = useCallback((tabId) => {
821
- setTabs((prev_1) => {
822
- const filtered = prev_1.filter((t_2) => t_2.id !== tabId);
823
- if (filtered.length === 0) {
824
- const fresh = {
825
- id: String(Date.now()),
826
- name: "Script 1",
827
- code: DEFAULT_CODE
828
- };
829
- setActiveTabId(fresh.id);
830
- return [fresh];
831
- }
832
- if (activeTabId === tabId) {
833
- setActiveTabId(filtered[filtered.length - 1].id);
834
- }
835
- return filtered;
836
- });
837
- }, [activeTabId]);
838
- const buildClient = useCallback(async () => {
839
- const apiUrl = apiConfig?.apiUrl;
840
- const getAuthToken = apiConfig?.getAuthToken;
841
- if (!apiUrl) {
842
- throw new Error("API URL not configured. Make sure apiUrl is set.");
843
- }
844
- if (authMode === "none") {
845
- const client = createRebaseClient({
846
- baseUrl: apiUrl,
847
- token: void 0
848
- });
849
- return {
850
- client,
851
- isScoped: true
852
- };
853
- }
854
- if (!selectedUser || currentUser && selectedUser.uid === currentUser.uid) {
855
- if (!rebaseClient) {
856
- throw new Error("Application client is not initialized.");
857
- }
858
- return {
859
- client: rebaseClient,
860
- isScoped: false
861
- };
862
- }
863
- let token;
864
- if (getAuthToken) {
865
- token = await getAuthToken() ?? void 0;
866
- }
867
- if (!token) {
868
- throw new Error("No auth token available. Please sign in first.");
869
- }
870
- const client_0 = createRebaseClient({
871
- baseUrl: apiUrl,
872
- token
873
- });
874
- return {
875
- client: client_0,
876
- isScoped: true
877
- };
878
- }, [apiConfig, rebaseClient, selectedUser, currentUser, authMode]);
879
- const executeCode = useCallback(async (codeOverride) => {
880
- const code_0 = codeOverride ?? activeTab?.code ?? "";
881
- if (!code_0.trim()) return;
882
- setIsRunning(true);
883
- setResult(null);
884
- setHistory((prev_2) => {
885
- const deduped = prev_2.filter((h) => h !== code_0);
886
- return [...deduped, code_0].slice(-50);
887
- });
888
- const consoleEntries = [];
889
- const startTime = performance.now();
890
- let scopedClientToCleanUp = null;
891
- const originalConsole = {
892
- log: console.log,
893
- warn: console.warn,
894
- error: console.error,
895
- info: console.info
896
- };
897
- const captureConsole = (type) => (...args) => {
898
- consoleEntries.push({
899
- type,
900
- args,
901
- timestamp: Date.now()
902
- });
903
- originalConsole[type](...args);
904
- };
905
- try {
906
- console.log = captureConsole("log");
907
- console.warn = captureConsole("warn");
908
- console.error = captureConsole("error");
909
- console.info = captureConsole("info");
910
- const {
911
- client: client_1,
912
- isScoped
913
- } = await buildClient();
914
- if (isScoped) {
915
- scopedClientToCleanUp = client_1;
916
- }
917
- const context = {
918
- user: selectedUser ?? (currentUser ? {
919
- uid: currentUser.uid,
920
- displayName: currentUser.displayName,
921
- email: currentUser.email,
922
- roles: currentUser.roles
923
- } : null),
924
- collections: collectionInfos
925
- };
926
- const AsyncFunction = Object.getPrototypeOf(async function() {
927
- }).constructor;
928
- const fn = new AsyncFunction("client", "context", code_0);
929
- const value = await fn(client_1, context);
930
- const duration_0 = performance.now() - startTime;
931
- setResult({
932
- value,
933
- console: consoleEntries,
934
- duration: duration_0,
935
- timestamp: Date.now()
936
- });
937
- const resultObj = value;
938
- if (resultObj?.data && Array.isArray(resultObj.data)) {
939
- setResultView("table");
940
- } else if (consoleEntries.length > 0 && value === void 0) {
941
- setResultView("console");
942
- } else {
943
- setResultView("json");
944
- }
945
- } catch (err) {
946
- const duration = performance.now() - startTime;
947
- setResult({
948
- value: void 0,
949
- console: consoleEntries,
950
- duration,
951
- error: err instanceof Error ? err.message : String(err),
952
- timestamp: Date.now()
953
- });
954
- setResultView("json");
955
- } finally {
956
- console.log = originalConsole.log;
957
- console.warn = originalConsole.warn;
958
- console.error = originalConsole.error;
959
- console.info = originalConsole.info;
960
- setIsRunning(false);
961
- if (scopedClientToCleanUp) {
962
- scopedClientToCleanUp.ws?.disconnect();
963
- }
964
- }
965
- }, [activeTab?.code, buildClient, selectedUser, currentUser, collectionInfos]);
966
- const saveSnippet = useCallback(() => {
967
- if (!snippetName.trim() || !activeTab?.code.trim()) return;
968
- const snippet = {
969
- id: String(Date.now()),
970
- name: snippetName.trim(),
971
- code: activeTab.code,
972
- createdAt: Date.now()
973
- };
974
- setSnippets((prev_3) => [snippet, ...prev_3]);
975
- setShowSaveDialog(false);
976
- setSnippetName("");
977
- snackbar.open({
978
- type: "success",
979
- message: "Snippet saved"
980
- });
981
- }, [snippetName, activeTab?.code, snackbar]);
982
- const deleteSnippet = useCallback((id_0) => {
983
- setSnippets((prev_4) => prev_4.filter((s) => s.id !== id_0));
984
- }, []);
985
- const exportResult = useCallback(() => {
986
- if (!result?.value) return;
987
- const blob = new Blob([formatJSON(result.value)], {
988
- type: "application/json"
989
- });
990
- const url = URL.createObjectURL(blob);
991
- const a = document.createElement("a");
992
- a.href = url;
993
- a.download = `rebase-result-${Date.now()}.json`;
994
- a.click();
995
- URL.revokeObjectURL(url);
996
- }, [result]);
997
- const tableData = useMemo(() => {
998
- if (!result?.value) return {
999
- columns: [],
1000
- data: []
1001
- };
1002
- let rows = [];
1003
- const val = result.value;
1004
- if (val?.data && Array.isArray(val.data)) {
1005
- rows = val.data.map((entity) => ({
1006
- id: entity.id,
1007
- ...entity.values ?? {},
1008
- ...entity.values ? {} : entity
1009
- }));
1010
- } else if (Array.isArray(result.value)) {
1011
- rows = result.value;
1012
- }
1013
- if (rows.length === 0) return {
1014
- columns: [],
1015
- data: []
1016
- };
1017
- const keys = /* @__PURE__ */ new Set();
1018
- rows.slice(0, 20).forEach((row) => {
1019
- if (row && typeof row === "object") {
1020
- Object.keys(row).forEach((k) => keys.add(k));
1021
- }
1022
- });
1023
- const columns = Array.from(keys).map((key) => ({
1024
- key,
1025
- title: key,
1026
- width: key === "id" ? 100 : 200
1027
- }));
1028
- return {
1029
- columns,
1030
- data: rows
1031
- };
1032
- }, [result]);
1033
- const matchedCollections = useMemo(() => {
1034
- if (!result?.value || result.error) return [];
1035
- return detectCollectionsInResult(activeTab?.code ?? "", result.value, collectionRegistry?.collections ?? []);
1036
- }, [result, activeTab?.code, collectionRegistry?.collections]);
1037
- const getRowEntityActions = useCallback((rowData) => {
1038
- if (!rowData || matchedCollections.length === 0) return [];
1039
- return matchedCollections.filter((mc) => rowData[mc.pkColumn] != null).map((mc_0) => ({
1040
- collection: mc_0,
1041
- entityId: rowData[mc_0.pkColumn]
1042
- }));
1043
- }, [matchedCollections]);
1044
- const handleExportCSV = useCallback(() => {
1045
- if (tableData.data.length === 0) return;
1046
- const headers = tableData.columns.map((c_0) => c_0.key).join(",");
1047
- const rows_0 = tableData.data.map((row_0) => tableData.columns.map((c_1) => {
1048
- const val_0 = row_0[c_1.key];
1049
- const str = val_0 === null || val_0 === void 0 ? "" : String(val_0);
1050
- return str.includes(",") ? `"${str}"` : str;
1051
- }).join(","));
1052
- const csv = [headers, ...rows_0].join("\n");
1053
- const blob_0 = new Blob([csv], {
1054
- type: "text/csv"
1055
- });
1056
- const url_0 = URL.createObjectURL(blob_0);
1057
- const a_0 = document.createElement("a");
1058
- a_0.href = url_0;
1059
- a_0.download = `js_results_${(/* @__PURE__ */ new Date()).toISOString().slice(0, 19)}.csv`;
1060
- a_0.click();
1061
- URL.revokeObjectURL(url_0);
1062
- }, [tableData]);
1063
- const handleExportMarkdown = useCallback(() => {
1064
- if (tableData.data.length === 0) return;
1065
- const headers_0 = tableData.columns.map((c_2) => c_2.key);
1066
- const headerRow = `| ${headers_0.join(" | ")} |`;
1067
- const dividerRow = `| ${headers_0.map(() => "---").join(" | ")} |`;
1068
- const dataRows = tableData.data.map((row_1) => `| ${headers_0.map((h_0) => {
1069
- const val_1 = row_1[h_0];
1070
- if (val_1 === null || val_1 === void 0) return "";
1071
- return String(val_1).replace(/\|/g, "\\|").replace(/\n/g, " ");
1072
- }).join(" | ")} |`);
1073
- const markdown = [headerRow, dividerRow, ...dataRows].join("\n");
1074
- navigator.clipboard.writeText(markdown).then(() => {
1075
- snackbar.open({
1076
- type: "success",
1077
- message: t("studio_sql_markdown_copied")
1078
- });
1079
- }).catch(() => {
1080
- snackbar.open({
1081
- type: "error",
1082
- message: t("studio_sql_markdown_copy_failed")
1083
- });
1084
- });
1085
- }, [tableData, snackbar, t]);
1086
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full w-full", children: [
1087
- /* @__PURE__ */ jsx("div", { className: "flex-grow overflow-hidden", children: /* @__PURE__ */ jsx(ResizablePanels, { orientation: "horizontal", panelSizePercent: sidebarSize, onPanelSizeChange: setSidebarSize, minPanelSizePx: 200, firstPanel: /* @__PURE__ */ jsx(JSEditorSidebar, { collections: collectionInfos, snippets, history, onSelectSnippet: (code_1) => updateActiveCode(code_1), onDeleteSnippet: deleteSnippet, onInsertCode: (code_2) => updateActiveCode(code_2) }), secondPanel: /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full overflow-hidden", children: [
1088
- /* @__PURE__ */ jsxs("div", { className: cls("flex items-center justify-between pr-2 border-b bg-white dark:bg-surface-950", defaultBorderMixin), children: [
1089
- /* @__PURE__ */ jsx("div", { className: "flex items-center flex-grow overflow-hidden mr-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center no-scrollbar overflow-x-auto min-w-0", children: [
1090
- /* @__PURE__ */ jsx(Tabs, { value: activeTabId, onValueChange: setActiveTabId, variant: "boxy", className: "w-[unset] flex-shrink-0", innerClassName: "bg-white dark:bg-surface-950", children: tabs.map((tab) => /* @__PURE__ */ jsxs(Tab, { value: tab.id, className: "flex items-center justify-between group max-w-[200px]", children: [
1091
- /* @__PURE__ */ jsx(TerminalIcon, { size: iconSize.smallest, className: "text-amber-500 mr-1.5 flex-shrink-0" }),
1092
- /* @__PURE__ */ jsx("span", { className: "truncate", children: tab.name }),
1093
- tabs.length > 1 && /* @__PURE__ */ jsx(IconButton, { size: "smallest", onClick: (e) => {
1094
- e.stopPropagation();
1095
- closeTab(tab.id);
1096
- }, className: "ml-1 !p-0.5 opacity-0 group-hover:opacity-100 hover:text-red-500 transition-opacity", children: /* @__PURE__ */ jsx(XIcon, { size: iconSize.smallest }) })
1097
- ] }, tab.id)) }),
1098
- /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: addTab, className: "ml-2 flex-shrink-0", children: /* @__PURE__ */ jsx(PlusIcon, { size: iconSize.smallest }) })
1099
- ] }) }),
1100
- /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center justify-end gap-1.5", children: [
1101
- /* @__PURE__ */ jsx(Tooltip, { title: "SaveIcon as snippet", children: /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: () => {
1102
- setSnippetName("");
1103
- setShowSaveDialog(true);
1104
- }, disabled: !activeTab?.code.trim(), children: /* @__PURE__ */ jsx(SaveIcon, { size: iconSize.smallest }) }) }),
1105
- result?.value != null && /* @__PURE__ */ jsx(Tooltip, { title: "Export result as JSON", children: /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: exportResult, children: /* @__PURE__ */ jsx(DownloadIcon, { size: iconSize.smallest }) }) }),
1106
- /* @__PURE__ */ jsxs(Button, { size: "small", color: "primary", disabled: isRunning || !activeTab?.code.trim(), onClick: () => executeCode(), children: [
1107
- isRunning ? /* @__PURE__ */ jsx(CircularProgress, { size: "smallest", className: "mr-2" }) : /* @__PURE__ */ jsx(PlayIcon, { size: iconSize.smallest, className: "mr-2" }),
1108
- "Run"
1109
- ] })
1110
- ] })
1111
- ] }),
1112
- /* @__PURE__ */ jsx("div", { className: "flex-grow overflow-hidden", children: /* @__PURE__ */ jsx(ResizablePanels, { orientation: "vertical", panelSizePercent: editorHeight, onPanelSizeChange: setEditorHeight, minPanelSizePx: 100, firstPanel: /* @__PURE__ */ jsxs("div", { className: "h-full w-full overflow-hidden flex flex-col", children: [
1113
- /* @__PURE__ */ jsx("div", { className: "p-2 px-3 border-b border-surface-200 dark:border-surface-950 bg-surface-50 dark:bg-surface-900 flex items-center shrink-0", children: /* @__PURE__ */ jsx(AuthSimulationSelector, { authMode, setAuthMode, selectedUser, setSelectedUser, users, loading: userManagement?.loading, currentUser: currentSelectableUser }) }),
1114
- /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0", children: /* @__PURE__ */ jsx(JSMonacoEditor, { value: activeTab?.code ?? "", onChange: updateActiveCode, onRun: (selectedText) => executeCode(selectedText), collectionSlugs, collections: collectionInfos, autoFocus: true }) })
1115
- ] }), secondPanel: /* @__PURE__ */ jsxs("div", { className: "h-full w-full flex flex-col bg-surface-50 dark:bg-surface-950 overflow-hidden min-h-0", children: [
1116
- /* @__PURE__ */ jsxs("div", { className: cls("p-2 px-4 bg-surface-100 dark:bg-surface-900 border-b shrink-0 flex items-center", defaultBorderMixin), children: [
1117
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "font-bold text-text-disabled dark:text-text-disabled-dark uppercase tracking-widest text-[10px]", children: t("studio_sql_query_results") }),
1118
- result && /* @__PURE__ */ jsxs(Fragment, { children: [
1119
- /* @__PURE__ */ jsx("div", { className: "flex-grow" }),
1120
- /* @__PURE__ */ jsxs(Tabs, { value: resultView, onValueChange: (val_2) => setResultView(val_2), variant: "pill", className: "w-[unset] mr-2", children: [
1121
- /* @__PURE__ */ jsx(Tab, { value: "json", children: "JSON" }),
1122
- tableData.data.length > 0 && /* @__PURE__ */ jsx(Tab, { value: "table", children: "Table" }),
1123
- result.console.length > 0 && /* @__PURE__ */ jsxs(Tab, { value: "console", children: [
1124
- "Console (",
1125
- result.console.length,
1126
- ")"
1127
- ] })
1128
- ] }),
1129
- /* @__PURE__ */ jsx(Chip, { size: "smallest", colorScheme: result.error ? "redDarker" : "greenDarker", children: result.error ? "Error" : `${result.duration.toFixed(0)}ms` })
1130
- ] })
1131
- ] }),
1132
- /* @__PURE__ */ jsxs("div", { className: "flex-grow flex flex-col min-h-0 overflow-hidden", children: [
1133
- isRunning && /* @__PURE__ */ jsx("div", { className: "flex-grow flex items-center justify-center", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
1134
- /* @__PURE__ */ jsx(CircularProgress, { size: "medium" }),
1135
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "mt-4 text-text-secondary dark:text-text-secondary-dark font-mono tracking-tight animate-pulse", children: "EXECUTING SCRIPT..." })
1136
- ] }) }),
1137
- !isRunning && !result && /* @__PURE__ */ jsx("div", { className: "flex-grow flex items-center justify-center text-text-disabled dark:text-text-disabled-dark", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
1138
- /* @__PURE__ */ jsx("svg", { className: "w-12 h-12 mx-auto mb-4 opacity-50", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1, d: "M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" }) }),
1139
- /* @__PURE__ */ jsxs(Typography, { variant: "body2", children: [
1140
- "Write JavaScript and press ",
1141
- /* @__PURE__ */ jsx("kbd", { className: "px-1.5 py-0.5 rounded bg-surface-200 dark:bg-surface-700 text-[11px] font-mono", children: "⌘ Enter" }),
1142
- " to run"
1143
- ] })
1144
- ] }) }),
1145
- !isRunning && result?.error && /* @__PURE__ */ jsx("div", { className: "flex-grow flex items-center justify-center p-6 overflow-auto", children: /* @__PURE__ */ jsx(ErrorView, { title: "Execution Error", error: result.error }) }),
1146
- !isRunning && result && !result.error && resultView === "json" && /* @__PURE__ */ jsx("pre", { className: "flex-grow overflow-auto p-4 text-[13px] font-mono leading-relaxed text-text-primary dark:text-text-primary-dark whitespace-pre-wrap break-words", children: result.value === void 0 ? /* @__PURE__ */ jsx("span", { className: "text-text-disabled italic", children: "undefined (no return value)" }) : /* @__PURE__ */ jsx(JSONHighlight, { value: result.value }) }),
1147
- !isRunning && result && !result.error && resultView === "table" && tableData.data.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex-grow flex flex-col overflow-hidden min-h-0", children: [
1148
- matchedCollections.length > 0 && /* @__PURE__ */ jsxs("div", { className: cls("px-4 py-1.5 border-b flex items-center gap-2 shrink-0 bg-surface-50 dark:bg-surface-900", defaultBorderMixin), children: [
1149
- /* @__PURE__ */ jsx(Tooltip, { title: t("studio_sql_cms_collections_tooltip"), children: /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] font-bold uppercase tracking-widest text-text-disabled dark:text-text-disabled-dark mr-1 shrink-0 cursor-help", children: t("studio_sql_cms") }) }),
1150
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1.5 overflow-x-auto no-scrollbar", children: matchedCollections.map((mc_1) => /* @__PURE__ */ jsx(Tooltip, { title: `${mc_1.collection.name} (${mc_1.collectionSlug})`, children: /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[11px] font-medium bg-primary/10 dark:bg-primary-dark/15 text-primary dark:text-primary-dark whitespace-nowrap border border-primary/20 dark:border-primary-dark/20", children: [
1151
- typeof mc_1.collection.icon === "string" && /* @__PURE__ */ jsx(IconForView, { collectionOrView: {
1152
- icon: mc_1.collection.icon
1153
- }, className: "text-[12px]" }),
1154
- mc_1.collection.name
1155
- ] }) }, mc_1.collectionSlug)) })
1156
- ] }),
1157
- /* @__PURE__ */ jsx("div", { className: "flex-grow relative h-full min-h-0 min-w-0", children: /* @__PURE__ */ jsx(VirtualTable, { data: tableData.data, columns: matchedCollections.length > 0 ? [{
1158
- key: "__entity_action__",
1159
- title: "",
1160
- width: 36,
1161
- sortable: false,
1162
- resizable: false
1163
- }, ...tableData.columns] : tableData.columns, rowHeight: 32, headerHeight: 32, cellRenderer: ({
1164
- rowData: rowData_0,
1165
- column,
1166
- rowIndex
1167
- }) => {
1168
- if (column.key === "__entity_action__") {
1169
- const rowActions = getRowEntityActions(rowData_0 ?? {});
1170
- if (rowActions.length === 0) return /* @__PURE__ */ jsx("div", { className: "h-full w-full" });
1171
- if (rowActions.length === 1) {
1172
- const ra = rowActions[0];
1173
- return /* @__PURE__ */ jsx("div", { className: "h-full flex items-center justify-center", children: /* @__PURE__ */ jsx(Tooltip, { title: t("studio_sql_edit_entity", {
1174
- name: ra.collection.collection.name,
1175
- id: String(ra.entityId)
1176
- }), children: /* @__PURE__ */ jsx(IconButton, { size: "small", className: "text-surface-400 dark:text-surface-500 hover:text-surface-600 dark:hover:text-surface-300", onClick: (e_0) => {
1177
- e_0.stopPropagation();
1178
- sideEntityController.open({
1179
- path: ra.collection.collectionSlug,
1180
- entityId: ra.entityId,
1181
- collection: ra.collection.collection,
1182
- updateUrl: false
1183
- });
1184
- }, children: /* @__PURE__ */ jsx(PencilIcon, { size: iconSize.smallest }) }) }) });
1185
- }
1186
- return /* @__PURE__ */ jsx("div", { className: "h-full flex items-center justify-center", children: /* @__PURE__ */ jsx(Menu, { trigger: /* @__PURE__ */ jsx(IconButton, { size: "small", className: "text-surface-400 dark:text-surface-500 hover:text-surface-600 dark:hover:text-surface-300", onClick: (e_1) => e_1.stopPropagation(), children: /* @__PURE__ */ jsx(MoreVerticalIcon, { size: iconSize.smallest }) }), children: rowActions.map((ra_0) => /* @__PURE__ */ jsx(MenuItem, { dense: true, onClick: () => {
1187
- sideEntityController.open({
1188
- path: ra_0.collection.collectionSlug,
1189
- entityId: ra_0.entityId,
1190
- collection: ra_0.collection.collection,
1191
- updateUrl: false
1192
- });
1193
- }, children: t("studio_sql_edit_entity", {
1194
- name: ra_0.collection.collection.name,
1195
- id: String(ra_0.entityId)
1196
- }) }, ra_0.collection.collectionSlug)) }) });
1197
- }
1198
- if (!rowData_0) return null;
1199
- const val_3 = rowData_0[column.key];
1200
- const displayValue = typeof val_3 === "object" && val_3 !== null ? JSON.stringify(val_3) : String(val_3 ?? "");
1201
- return /* @__PURE__ */ jsx("div", { className: "px-4 py-1.5 h-full flex items-center whitespace-nowrap text-[13px] text-text-primary dark:text-text-primary-dark font-mono", children: /* @__PURE__ */ jsx("div", { className: "truncate flex-grow", title: displayValue, children: displayValue === "" ? /* @__PURE__ */ jsx("span", { className: "text-text-disabled dark:text-text-disabled-dark italic text-[11px]", children: "NULL" }) : displayValue }) });
1202
- } }) })
1203
- ] }),
1204
- !isRunning && result && resultView === "console" && /* @__PURE__ */ jsxs("div", { className: "flex-grow overflow-auto p-2 space-y-1 font-mono text-[12px]", children: [
1205
- result.console.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-disabled p-2", children: "No console output" }) : result.console.map((entry, i) => /* @__PURE__ */ jsxs("div", { className: cls("px-2 py-1 rounded flex items-start gap-2", entry.type === "error" && "bg-red-50 dark:bg-red-950/30 text-red-700 dark:text-red-400", entry.type === "warn" && "bg-amber-50 dark:bg-amber-950/30 text-amber-700 dark:text-amber-400", entry.type === "log" && "text-text-primary dark:text-text-primary-dark", entry.type === "info" && "text-blue-700 dark:text-blue-400"), children: [
1206
- /* @__PURE__ */ jsx("span", { className: "text-[10px] opacity-50 flex-shrink-0 mt-0.5", children: entry.type === "error" ? "❌" : entry.type === "warn" ? "⚠️" : entry.type === "info" ? "ℹ️" : "›" }),
1207
- /* @__PURE__ */ jsx("span", { className: "whitespace-pre-wrap break-words", children: entry.args.map((a_1) => typeof a_1 === "object" ? JSON.stringify(a_1, null, 2) : String(a_1)).join(" ") })
1208
- ] }, i)),
1209
- result.value !== void 0 && /* @__PURE__ */ jsxs("div", { className: cls("px-2 py-1 mt-2 border-t pt-2", defaultBorderMixin), children: [
1210
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-disabled text-[10px] uppercase tracking-wider mb-1 block", children: "Return Value" }),
1211
- /* @__PURE__ */ jsx("pre", { className: "text-text-primary dark:text-text-primary-dark whitespace-pre-wrap break-words text-[12px]", children: formatJSON(result.value) })
1212
- ] })
1213
- ] })
1214
- ] }),
1215
- !isRunning && result && !result.error && resultView === "table" && tableData.data.length > 0 && /* @__PURE__ */ jsxs("div", { className: cls("p-2 px-4 border-t bg-surface-50 dark:bg-surface-900 flex justify-between items-center shrink-0", defaultBorderMixin), children: [
1216
- /* @__PURE__ */ jsxs("div", { className: "flex space-x-4", children: [
1217
- /* @__PURE__ */ jsxs("div", { className: "flex items-center text-[11px]", children: [
1218
- /* @__PURE__ */ jsx("span", { className: "font-bold text-text-disabled dark:text-text-disabled-dark mr-2 uppercase tracking-tighter", children: t("studio_sql_rows") }),
1219
- /* @__PURE__ */ jsx("span", { className: "font-mono text-text-secondary dark:text-text-secondary-dark", children: tableData.data.length })
1220
- ] }),
1221
- /* @__PURE__ */ jsxs("div", { className: "flex items-center text-[11px]", children: [
1222
- /* @__PURE__ */ jsx("span", { className: "font-bold text-text-disabled dark:text-text-disabled-dark mr-2 uppercase tracking-tighter", children: t("studio_sql_time") }),
1223
- /* @__PURE__ */ jsxs("span", { className: "font-mono text-text-secondary dark:text-text-secondary-dark", children: [
1224
- result.duration.toFixed(0),
1225
- "ms"
1226
- ] })
1227
- ] })
1228
- ] }),
1229
- /* @__PURE__ */ jsxs("div", { className: "flex gap-2 overflow-x-auto no-scrollbar items-center px-2", children: [
1230
- /* @__PURE__ */ jsx(Button, { size: "small", variant: "text", className: "text-[10px] uppercase font-bold text-text-secondary dark:text-text-secondary-dark whitespace-nowrap", onClick: handleExportMarkdown, children: t("studio_sql_copy_markdown") }),
1231
- /* @__PURE__ */ jsx(Button, { size: "small", variant: "text", className: "text-[10px] uppercase font-bold text-text-secondary dark:text-text-secondary-dark whitespace-nowrap", onClick: exportResult, children: t("studio_sql_export_json") }),
1232
- /* @__PURE__ */ jsx(Button, { size: "small", variant: "text", className: "text-[10px] uppercase font-bold text-text-secondary dark:text-text-secondary-dark whitespace-nowrap", onClick: handleExportCSV, children: t("studio_sql_export_csv") })
1233
- ] })
1234
- ] })
1235
- ] }) }) })
1236
- ] }) }) }),
1237
- /* @__PURE__ */ jsxs(Dialog, { open: showSaveDialog, onOpenChange: setShowSaveDialog, children: [
1238
- /* @__PURE__ */ jsx(DialogTitle, { children: "SaveIcon Snippet" }),
1239
- /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(TextField, { label: "Snippet name", value: snippetName, onChange: (e_2) => setSnippetName(e_2.target.value), placeholder: "e.g. List all products", autoFocus: true, onKeyDown: (e_3) => {
1240
- if (e_3.key === "Enter") saveSnippet();
1241
- } }) }),
1242
- /* @__PURE__ */ jsxs(DialogActions, { children: [
1243
- /* @__PURE__ */ jsx(Button, { variant: "text", onClick: () => setShowSaveDialog(false), children: "Cancel" }),
1244
- /* @__PURE__ */ jsx(Button, { variant: "filled", color: "primary", onClick: saveSnippet, disabled: !snippetName.trim(), children: "Save" })
1245
- ] })
1246
- ] })
1247
- ] });
1248
- }
1249
- function JSONHighlight(t0) {
1250
- const $ = c(5);
1251
- const {
1252
- value
1253
- } = t0;
1254
- let t1;
1255
- if ($[0] !== value) {
1256
- t1 = formatJSON(value);
1257
- $[0] = value;
1258
- $[1] = t1;
1259
- } else {
1260
- t1 = $[1];
1261
- }
1262
- const json = t1;
1263
- const {
1264
- mode
1265
- } = useModeController();
1266
- const t2 = mode === "dark" ? themes.vsDark : themes.github;
1267
- let t3;
1268
- if ($[2] !== json || $[3] !== t2) {
1269
- t3 = /* @__PURE__ */ jsx(Highlight, { theme: t2, code: json, language: "json", children: _temp });
1270
- $[2] = json;
1271
- $[3] = t2;
1272
- $[4] = t3;
1273
- } else {
1274
- t3 = $[4];
1275
- }
1276
- return t3;
1277
- }
1278
- function _temp(t0) {
1279
- const {
1280
- style,
1281
- tokens,
1282
- getLineProps,
1283
- getTokenProps
1284
- } = t0;
1285
- return /* @__PURE__ */ jsx("span", { style: {
1286
- ...style,
1287
- backgroundColor: "transparent"
1288
- }, children: tokens.map((line, i) => /* @__PURE__ */ jsx("div", { ...getLineProps({
1289
- line
1290
- }), children: line.map((token, key) => /* @__PURE__ */ jsx("span", { ...getTokenProps({
1291
- token
1292
- }) }, key)) }, i)) });
1293
- }
1294
- export {
1295
- JSEditor
1296
- };
1297
- //# sourceMappingURL=JSEditor-DfwRLBZg.js.map