@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,1871 +0,0 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { useTranslation, useRebaseContext, useSnackbarController, useStudioCollectionRegistry, ErrorView } from "@rebasepro/core";
3
- import { useState, useEffect, useCallback, useMemo } from "react";
4
- import { IconButton, HelpCircleIcon, iconSize, cls, defaultBorderMixin, Typography, Select, SelectItem, DialogTitle, TextField, Button, MultiSelect, Paper, DialogContent, DialogActions, Dialog, MultiSelectItem, ResizablePanels, Chip, RefreshCwIcon, CircularProgress, Alert, AlertTriangleIcon, KeyIcon, Tooltip, Trash2Icon, ShieldIcon, Tabs, Tab } from "@rebasepro/ui";
5
- import { isPostgresCollection } from "@rebasepro/types";
6
- import { c } from "react-compiler-runtime";
7
- import { M as MonacoEditor } from "./MonacoEditor-CMYEjiRf.js";
8
- const COMMAND_OPTIONS = ["ALL", "SELECT", "INSERT", "UPDATE", "DELETE"];
9
- const ROLE_OPTIONS = ["public", "authenticated", "anon", "admin"];
10
- const POLICY_PRESETS = [{
11
- id: "public_read",
12
- label: "Enable read access to everyone",
13
- description: "Anyone can read data, regardless of authentication status.",
14
- policyname: "Enable read access for all users",
15
- cmd: "SELECT",
16
- permissive: "PERMISSIVE",
17
- roles: ["public"],
18
- qual: "true",
19
- with_check: ""
20
- }, {
21
- id: "auth_read",
22
- label: "Enable read access for authenticated users only",
23
- description: "Only logged-in users are allowed to read data.",
24
- policyname: "Enable read access for authenticated users",
25
- cmd: "SELECT",
26
- permissive: "PERMISSIVE",
27
- roles: ["authenticated"],
28
- qual: "true",
29
- with_check: ""
30
- }, {
31
- id: "auth_insert",
32
- label: "Enable insert for authenticated users only",
33
- description: "Only logged-in users are allowed to insert new data.",
34
- policyname: "Enable insert for authenticated users only",
35
- cmd: "INSERT",
36
- permissive: "PERMISSIVE",
37
- roles: ["authenticated"],
38
- qual: "",
39
- with_check: "true"
40
- }, {
41
- id: "user_select_own",
42
- label: "Users can read their own rows",
43
- description: "Users can only read rows where the user_id matches their auth.uid()",
44
- policyname: "Users can select their own data",
45
- cmd: "SELECT",
46
- permissive: "PERMISSIVE",
47
- roles: ["authenticated"],
48
- qual: "auth.uid() = user_id",
49
- with_check: ""
50
- }, {
51
- id: "user_update_own",
52
- label: "Users can update their own rows",
53
- description: "Users can only update rows where the user_id matches their auth.uid()",
54
- policyname: "Users can update their own data",
55
- cmd: "UPDATE",
56
- permissive: "PERMISSIVE",
57
- roles: ["authenticated"],
58
- qual: "auth.uid() = user_id",
59
- with_check: "auth.uid() = user_id"
60
- }, {
61
- id: "user_delete_own",
62
- label: "Users can delete their own rows",
63
- description: "Users can only delete rows where the user_id matches their auth.uid()",
64
- policyname: "Users can delete their own data",
65
- cmd: "DELETE",
66
- permissive: "PERMISSIVE",
67
- roles: ["authenticated"],
68
- qual: "auth.uid() = user_id",
69
- with_check: ""
70
- }];
71
- const PolicyEditor = (t0) => {
72
- const $ = c(294);
73
- const {
74
- policy,
75
- schema,
76
- table,
77
- onSave,
78
- onCancel
79
- } = t0;
80
- const {
81
- t
82
- } = useTranslation();
83
- const [name, setName] = useState("");
84
- const [helpOpen, setHelpOpen] = useState(false);
85
- const [behavior, setBehavior] = useState("PERMISSIVE");
86
- const [command, setCommand] = useState("ALL");
87
- let t1;
88
- if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
89
- t1 = ["public"];
90
- $[0] = t1;
91
- } else {
92
- t1 = $[0];
93
- }
94
- const [roles, setRoles] = useState(t1);
95
- const [usingExpr, setUsingExpr] = useState("");
96
- const [checkExpr, setCheckExpr] = useState("");
97
- const [selectedPreset, setSelectedPreset] = useState("");
98
- let t2;
99
- let t3;
100
- if ($[1] !== policy) {
101
- t2 = () => {
102
- if (policy) {
103
- setName(policy.policyname || "");
104
- setBehavior(policy.permissive || "PERMISSIVE");
105
- setCommand(policy.cmd || "ALL");
106
- const initialRoles = policy.roles ? Array.isArray(policy.roles) ? policy.roles : [policy.roles] : ["public"];
107
- setRoles(initialRoles);
108
- setUsingExpr(policy.qual || "");
109
- setCheckExpr(policy.with_check || "");
110
- } else {
111
- setName("");
112
- setBehavior("PERMISSIVE");
113
- setCommand("ALL");
114
- setRoles(["public"]);
115
- setUsingExpr("");
116
- setCheckExpr("");
117
- setSelectedPreset("");
118
- }
119
- };
120
- t3 = [policy];
121
- $[1] = policy;
122
- $[2] = t2;
123
- $[3] = t3;
124
- } else {
125
- t2 = $[2];
126
- t3 = $[3];
127
- }
128
- useEffect(t2, t3);
129
- let t4;
130
- if ($[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
131
- t4 = (presetId) => {
132
- const preset = POLICY_PRESETS.find((p) => p.id === presetId);
133
- if (!preset) {
134
- return;
135
- }
136
- setSelectedPreset(presetId);
137
- setName(preset.policyname);
138
- setBehavior(preset.permissive);
139
- setCommand(preset.cmd);
140
- setRoles(preset.roles);
141
- setUsingExpr(preset.qual);
142
- setCheckExpr(preset.with_check);
143
- };
144
- $[4] = t4;
145
- } else {
146
- t4 = $[4];
147
- }
148
- const handlePresetChange = t4;
149
- const showCheck = command === "ALL" || command === "INSERT" || command === "UPDATE";
150
- let t5;
151
- if ($[5] !== behavior || $[6] !== checkExpr || $[7] !== command || $[8] !== name || $[9] !== onSave || $[10] !== roles || $[11] !== showCheck || $[12] !== usingExpr) {
152
- t5 = () => {
153
- onSave({
154
- policyname: name,
155
- permissive: behavior,
156
- cmd: command,
157
- roles,
158
- qual: usingExpr,
159
- with_check: showCheck ? checkExpr : null
160
- });
161
- };
162
- $[5] = behavior;
163
- $[6] = checkExpr;
164
- $[7] = command;
165
- $[8] = name;
166
- $[9] = onSave;
167
- $[10] = roles;
168
- $[11] = showCheck;
169
- $[12] = usingExpr;
170
- $[13] = t5;
171
- } else {
172
- t5 = $[13];
173
- }
174
- const handleSave = t5;
175
- let t6;
176
- if ($[14] !== policy || $[15] !== t) {
177
- t6 = policy ? t("studio_policy_edit") : t("studio_policy_create");
178
- $[14] = policy;
179
- $[15] = t;
180
- $[16] = t6;
181
- } else {
182
- t6 = $[16];
183
- }
184
- let t7;
185
- if ($[17] !== t6) {
186
- t7 = /* @__PURE__ */ jsx("div", { children: t6 });
187
- $[17] = t6;
188
- $[18] = t7;
189
- } else {
190
- t7 = $[18];
191
- }
192
- let t8;
193
- if ($[19] !== t) {
194
- t8 = t("studio_policy_defining_rules");
195
- $[19] = t;
196
- $[20] = t8;
197
- } else {
198
- t8 = $[20];
199
- }
200
- let t9;
201
- if ($[21] !== schema || $[22] !== table) {
202
- t9 = /* @__PURE__ */ jsxs("span", { className: "font-mono text-primary bg-primary-bg dark:bg-primary-bg-dark px-1 py-0.5 rounded", children: [
203
- schema,
204
- ".",
205
- table
206
- ] });
207
- $[21] = schema;
208
- $[22] = table;
209
- $[23] = t9;
210
- } else {
211
- t9 = $[23];
212
- }
213
- let t10;
214
- if ($[24] !== t8 || $[25] !== t9) {
215
- t10 = /* @__PURE__ */ jsxs("div", { className: "text-sm font-normal text-text-secondary dark:text-text-secondary-dark tracking-wide mt-1", children: [
216
- t8,
217
- " ",
218
- t9
219
- ] });
220
- $[24] = t8;
221
- $[25] = t9;
222
- $[26] = t10;
223
- } else {
224
- t10 = $[26];
225
- }
226
- let t11;
227
- if ($[27] !== t10 || $[28] !== t7) {
228
- t11 = /* @__PURE__ */ jsxs("div", { children: [
229
- t7,
230
- t10
231
- ] });
232
- $[27] = t10;
233
- $[28] = t7;
234
- $[29] = t11;
235
- } else {
236
- t11 = $[29];
237
- }
238
- let t12;
239
- if ($[30] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
240
- t12 = /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: () => setHelpOpen(true), children: /* @__PURE__ */ jsx(HelpCircleIcon, { size: iconSize.smallest }) });
241
- $[30] = t12;
242
- } else {
243
- t12 = $[30];
244
- }
245
- let t13;
246
- if ($[31] !== t11) {
247
- t13 = /* @__PURE__ */ jsxs(DialogTitle, { className: "flex justify-between items-center w-full", variant: "h6", children: [
248
- t11,
249
- t12
250
- ] });
251
- $[31] = t11;
252
- $[32] = t13;
253
- } else {
254
- t13 = $[32];
255
- }
256
- let t14;
257
- if ($[33] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
258
- t14 = cls("p-4 md:p-6 flex flex-col gap-6 bg-white dark:bg-surface-900 border-none sm:border-solid rounded-none sm:rounded-xl", defaultBorderMixin);
259
- $[33] = t14;
260
- } else {
261
- t14 = $[33];
262
- }
263
- let t15;
264
- if ($[34] !== policy || $[35] !== selectedPreset || $[36] !== t) {
265
- t15 = !policy && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 bg-primary/5 dark:bg-primary-bg-dark/20 p-3 sm:p-4 rounded-lg border border-primary/10 dark:border-primary/20", children: [
266
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-primary dark:text-primary-light uppercase tracking-wider", children: t("studio_policy_template") }),
267
- /* @__PURE__ */ jsx(Select, { size: "small", value: selectedPreset, onValueChange: handlePresetChange, position: "item-aligned", placeholder: t("studio_policy_select_template"), className: "bg-white dark:bg-surface-950", children: POLICY_PRESETS.map(_temp) })
268
- ] });
269
- $[34] = policy;
270
- $[35] = selectedPreset;
271
- $[36] = t;
272
- $[37] = t15;
273
- } else {
274
- t15 = $[37];
275
- }
276
- let t16;
277
- if ($[38] !== t) {
278
- t16 = t("studio_policy_name");
279
- $[38] = t;
280
- $[39] = t16;
281
- } else {
282
- t16 = $[39];
283
- }
284
- let t17;
285
- if ($[40] !== t16) {
286
- t17 = /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "uppercase tracking-wider text-text-secondary", children: t16 });
287
- $[40] = t16;
288
- $[41] = t17;
289
- } else {
290
- t17 = $[41];
291
- }
292
- let t18;
293
- if ($[42] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
294
- t18 = (e) => setName(e.target.value);
295
- $[42] = t18;
296
- } else {
297
- t18 = $[42];
298
- }
299
- let t19;
300
- if ($[43] !== t) {
301
- t19 = t("studio_policy_name_placeholder");
302
- $[43] = t;
303
- $[44] = t19;
304
- } else {
305
- t19 = $[44];
306
- }
307
- let t20;
308
- if ($[45] !== name || $[46] !== t19) {
309
- t20 = /* @__PURE__ */ jsx(TextField, { value: name, onChange: t18, placeholder: t19, className: "w-full" });
310
- $[45] = name;
311
- $[46] = t19;
312
- $[47] = t20;
313
- } else {
314
- t20 = $[47];
315
- }
316
- let t21;
317
- if ($[48] !== t17 || $[49] !== t20) {
318
- t21 = /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
319
- t17,
320
- t20
321
- ] });
322
- $[48] = t17;
323
- $[49] = t20;
324
- $[50] = t21;
325
- } else {
326
- t21 = $[50];
327
- }
328
- let t22;
329
- if ($[51] !== t) {
330
- t22 = t("studio_policy_behavior");
331
- $[51] = t;
332
- $[52] = t22;
333
- } else {
334
- t22 = $[52];
335
- }
336
- let t23;
337
- if ($[53] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
338
- t23 = /* @__PURE__ */ jsx("code", { className: "text-[10px] bg-surface-200 dark:bg-surface-950 text-text-secondary dark:text-text-secondary-dark px-1 py-0.5 rounded ml-1", children: "AS" });
339
- $[53] = t23;
340
- } else {
341
- t23 = $[53];
342
- }
343
- let t24;
344
- if ($[54] !== t22) {
345
- t24 = /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "uppercase tracking-wider text-text-secondary", children: [
346
- t22,
347
- " ",
348
- t23
349
- ] });
350
- $[54] = t22;
351
- $[55] = t24;
352
- } else {
353
- t24 = $[55];
354
- }
355
- let t25;
356
- if ($[56] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
357
- t25 = (val) => setBehavior(val);
358
- $[56] = t25;
359
- } else {
360
- t25 = $[56];
361
- }
362
- let t26;
363
- if ($[57] !== t) {
364
- t26 = t("studio_policy_permissive");
365
- $[57] = t;
366
- $[58] = t26;
367
- } else {
368
- t26 = $[58];
369
- }
370
- let t27;
371
- if ($[59] !== t26) {
372
- t27 = /* @__PURE__ */ jsx("span", { className: "", children: t26 });
373
- $[59] = t26;
374
- $[60] = t27;
375
- } else {
376
- t27 = $[60];
377
- }
378
- let t28;
379
- if ($[61] !== t) {
380
- t28 = t("studio_policy_permissive_desc");
381
- $[61] = t;
382
- $[62] = t28;
383
- } else {
384
- t28 = $[62];
385
- }
386
- let t29;
387
- if ($[63] !== t28) {
388
- t29 = /* @__PURE__ */ jsx("span", { className: "text-xs text-text-secondary dark:text-text-secondary-dark", children: t28 });
389
- $[63] = t28;
390
- $[64] = t29;
391
- } else {
392
- t29 = $[64];
393
- }
394
- let t30;
395
- if ($[65] !== t27 || $[66] !== t29) {
396
- t30 = /* @__PURE__ */ jsx(SelectItem, { value: "PERMISSIVE", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-left", children: [
397
- t27,
398
- t29
399
- ] }) });
400
- $[65] = t27;
401
- $[66] = t29;
402
- $[67] = t30;
403
- } else {
404
- t30 = $[67];
405
- }
406
- let t31;
407
- if ($[68] !== t) {
408
- t31 = t("studio_policy_restrictive");
409
- $[68] = t;
410
- $[69] = t31;
411
- } else {
412
- t31 = $[69];
413
- }
414
- let t32;
415
- if ($[70] !== t31) {
416
- t32 = /* @__PURE__ */ jsx("span", { className: "", children: t31 });
417
- $[70] = t31;
418
- $[71] = t32;
419
- } else {
420
- t32 = $[71];
421
- }
422
- let t33;
423
- if ($[72] !== t) {
424
- t33 = t("studio_policy_restrictive_desc");
425
- $[72] = t;
426
- $[73] = t33;
427
- } else {
428
- t33 = $[73];
429
- }
430
- let t34;
431
- if ($[74] !== t33) {
432
- t34 = /* @__PURE__ */ jsx("span", { className: "text-xs text-text-secondary dark:text-text-secondary-dark", children: t33 });
433
- $[74] = t33;
434
- $[75] = t34;
435
- } else {
436
- t34 = $[75];
437
- }
438
- let t35;
439
- if ($[76] !== t32 || $[77] !== t34) {
440
- t35 = /* @__PURE__ */ jsx(SelectItem, { value: "RESTRICTIVE", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-left", children: [
441
- t32,
442
- t34
443
- ] }) });
444
- $[76] = t32;
445
- $[77] = t34;
446
- $[78] = t35;
447
- } else {
448
- t35 = $[78];
449
- }
450
- let t36;
451
- if ($[79] !== behavior || $[80] !== t30 || $[81] !== t35) {
452
- t36 = /* @__PURE__ */ jsxs(Select, { value: behavior, onValueChange: t25, position: "item-aligned", children: [
453
- t30,
454
- t35
455
- ] });
456
- $[79] = behavior;
457
- $[80] = t30;
458
- $[81] = t35;
459
- $[82] = t36;
460
- } else {
461
- t36 = $[82];
462
- }
463
- let t37;
464
- if ($[83] !== t24 || $[84] !== t36) {
465
- t37 = /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
466
- t24,
467
- t36
468
- ] });
469
- $[83] = t24;
470
- $[84] = t36;
471
- $[85] = t37;
472
- } else {
473
- t37 = $[85];
474
- }
475
- let t38;
476
- if ($[86] !== t21 || $[87] !== t37) {
477
- t38 = /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4 sm:gap-6", children: [
478
- t21,
479
- t37
480
- ] });
481
- $[86] = t21;
482
- $[87] = t37;
483
- $[88] = t38;
484
- } else {
485
- t38 = $[88];
486
- }
487
- let t39;
488
- if ($[89] !== t) {
489
- t39 = t("studio_policy_command");
490
- $[89] = t;
491
- $[90] = t39;
492
- } else {
493
- t39 = $[90];
494
- }
495
- let t40;
496
- if ($[91] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
497
- t40 = /* @__PURE__ */ jsx("code", { className: "text-[10px] bg-surface-200 dark:bg-surface-950 text-text-secondary dark:text-text-secondary-dark px-1 py-0.5 rounded ml-1", children: "FOR" });
498
- $[91] = t40;
499
- } else {
500
- t40 = $[91];
501
- }
502
- let t41;
503
- if ($[92] !== t39) {
504
- t41 = /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "uppercase tracking-wider text-text-secondary", children: [
505
- t39,
506
- " ",
507
- t40
508
- ] });
509
- $[92] = t39;
510
- $[93] = t41;
511
- } else {
512
- t41 = $[93];
513
- }
514
- let t42;
515
- if ($[94] !== command) {
516
- t42 = COMMAND_OPTIONS.map((cmd) => /* @__PURE__ */ jsx(Button, { size: "small", variant: command === cmd ? "filled" : "text", color: "neutral", onClick: () => setCommand(cmd), className: "min-w-[80px]", children: cmd }, cmd));
517
- $[94] = command;
518
- $[95] = t42;
519
- } else {
520
- t42 = $[95];
521
- }
522
- let t43;
523
- if ($[96] !== t42) {
524
- t43 = /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1.5", children: t42 });
525
- $[96] = t42;
526
- $[97] = t43;
527
- } else {
528
- t43 = $[97];
529
- }
530
- let t44;
531
- if ($[98] !== t41 || $[99] !== t43) {
532
- t44 = /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
533
- t41,
534
- t43
535
- ] });
536
- $[98] = t41;
537
- $[99] = t43;
538
- $[100] = t44;
539
- } else {
540
- t44 = $[100];
541
- }
542
- let t45;
543
- if ($[101] !== t) {
544
- t45 = t("studio_policy_target_roles");
545
- $[101] = t;
546
- $[102] = t45;
547
- } else {
548
- t45 = $[102];
549
- }
550
- let t46;
551
- if ($[103] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
552
- t46 = /* @__PURE__ */ jsx("code", { className: "text-[10px] bg-surface-200 dark:bg-surface-950 text-text-secondary dark:text-text-secondary-dark px-1 py-0.5 rounded ml-1", children: "TO" });
553
- $[103] = t46;
554
- } else {
555
- t46 = $[103];
556
- }
557
- let t47;
558
- if ($[104] !== t45) {
559
- t47 = /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "uppercase tracking-wider text-text-secondary", children: [
560
- t45,
561
- " ",
562
- t46
563
- ] });
564
- $[104] = t45;
565
- $[105] = t47;
566
- } else {
567
- t47 = $[105];
568
- }
569
- let t48;
570
- if ($[106] !== t) {
571
- t48 = t("studio_policy_roles_placeholder");
572
- $[106] = t;
573
- $[107] = t48;
574
- } else {
575
- t48 = $[107];
576
- }
577
- let t49;
578
- if ($[108] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
579
- t49 = ROLE_OPTIONS.map(_temp2);
580
- $[108] = t49;
581
- } else {
582
- t49 = $[108];
583
- }
584
- let t50;
585
- if ($[109] !== roles || $[110] !== t48) {
586
- t50 = /* @__PURE__ */ jsx(MultiSelect, { size: "small", value: roles, onValueChange: setRoles, placeholder: t48, children: t49 });
587
- $[109] = roles;
588
- $[110] = t48;
589
- $[111] = t50;
590
- } else {
591
- t50 = $[111];
592
- }
593
- let t51;
594
- if ($[112] !== t47 || $[113] !== t50) {
595
- t51 = /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
596
- t47,
597
- t50
598
- ] });
599
- $[112] = t47;
600
- $[113] = t50;
601
- $[114] = t51;
602
- } else {
603
- t51 = $[114];
604
- }
605
- let t52;
606
- if ($[115] !== t15 || $[116] !== t38 || $[117] !== t44 || $[118] !== t51) {
607
- t52 = /* @__PURE__ */ jsxs(Paper, { className: t14, children: [
608
- t15,
609
- t38,
610
- t44,
611
- t51
612
- ] });
613
- $[115] = t15;
614
- $[116] = t38;
615
- $[117] = t44;
616
- $[118] = t51;
617
- $[119] = t52;
618
- } else {
619
- t52 = $[119];
620
- }
621
- let t53;
622
- if ($[120] !== command || $[121] !== t || $[122] !== usingExpr) {
623
- t53 = command !== "INSERT" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
624
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
625
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "uppercase tracking-wider text-text-secondary", children: t("studio_policy_using_expr") }),
626
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary opacity-70", children: t("studio_policy_using_expr_desc") })
627
- ] }),
628
- /* @__PURE__ */ jsx("div", { className: cls("h-32 border rounded-md overflow-hidden bg-white dark:bg-[#1e1e1e]", defaultBorderMixin), children: /* @__PURE__ */ jsx(MonacoEditor, { value: usingExpr, onChange: (v) => setUsingExpr(v || ""), readOnly: false, autoFocus: true }) })
629
- ] });
630
- $[120] = command;
631
- $[121] = t;
632
- $[122] = usingExpr;
633
- $[123] = t53;
634
- } else {
635
- t53 = $[123];
636
- }
637
- let t54;
638
- if ($[124] !== checkExpr || $[125] !== command || $[126] !== showCheck || $[127] !== t) {
639
- t54 = showCheck && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 mt-2", children: [
640
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
641
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "uppercase tracking-wider text-text-secondary", children: t("studio_policy_check_expr") }),
642
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary opacity-70", children: t("studio_policy_check_expr_desc") })
643
- ] }),
644
- /* @__PURE__ */ jsx("div", { className: cls("h-32 border rounded-md overflow-hidden bg-white dark:bg-[#1e1e1e]", defaultBorderMixin), children: /* @__PURE__ */ jsx(MonacoEditor, { value: checkExpr, onChange: (v_0) => setCheckExpr(v_0 || ""), readOnly: false, autoFocus: command === "INSERT" }) })
645
- ] });
646
- $[124] = checkExpr;
647
- $[125] = command;
648
- $[126] = showCheck;
649
- $[127] = t;
650
- $[128] = t54;
651
- } else {
652
- t54 = $[128];
653
- }
654
- let t55;
655
- if ($[129] !== t53 || $[130] !== t54) {
656
- t55 = /* @__PURE__ */ jsxs("div", { className: "mt-8 flex flex-col gap-4", children: [
657
- t53,
658
- t54
659
- ] });
660
- $[129] = t53;
661
- $[130] = t54;
662
- $[131] = t55;
663
- } else {
664
- t55 = $[131];
665
- }
666
- let t56;
667
- if ($[132] !== t52 || $[133] !== t55) {
668
- t56 = /* @__PURE__ */ jsx(DialogContent, { className: "p-4 md:p-6 border-t dark:border-surface-950 bg-surface-50 dark:bg-surface-950", includeMargin: false, children: /* @__PURE__ */ jsxs("div", { className: "max-w-4xl mx-auto", children: [
669
- t52,
670
- t55
671
- ] }) });
672
- $[132] = t52;
673
- $[133] = t55;
674
- $[134] = t56;
675
- } else {
676
- t56 = $[134];
677
- }
678
- let t57;
679
- if ($[135] !== t) {
680
- t57 = t("studio_policy_cancel");
681
- $[135] = t;
682
- $[136] = t57;
683
- } else {
684
- t57 = $[136];
685
- }
686
- let t58;
687
- if ($[137] !== onCancel || $[138] !== t57) {
688
- t58 = /* @__PURE__ */ jsx(Button, { size: "small", variant: "text", color: "neutral", onClick: onCancel, children: t57 });
689
- $[137] = onCancel;
690
- $[138] = t57;
691
- $[139] = t58;
692
- } else {
693
- t58 = $[139];
694
- }
695
- const t59 = !name;
696
- let t60;
697
- if ($[140] !== t) {
698
- t60 = t("studio_policy_save");
699
- $[140] = t;
700
- $[141] = t60;
701
- } else {
702
- t60 = $[141];
703
- }
704
- let t61;
705
- if ($[142] !== handleSave || $[143] !== t59 || $[144] !== t60) {
706
- t61 = /* @__PURE__ */ jsx(Button, { size: "small", variant: "filled", color: "primary", onClick: handleSave, disabled: t59, children: t60 });
707
- $[142] = handleSave;
708
- $[143] = t59;
709
- $[144] = t60;
710
- $[145] = t61;
711
- } else {
712
- t61 = $[145];
713
- }
714
- let t62;
715
- if ($[146] !== t58 || $[147] !== t61) {
716
- t62 = /* @__PURE__ */ jsxs(DialogActions, { children: [
717
- t58,
718
- t61
719
- ] });
720
- $[146] = t58;
721
- $[147] = t61;
722
- $[148] = t62;
723
- } else {
724
- t62 = $[148];
725
- }
726
- let t63;
727
- if ($[149] !== t) {
728
- t63 = t("studio_policy_help_title");
729
- $[149] = t;
730
- $[150] = t63;
731
- } else {
732
- t63 = $[150];
733
- }
734
- let t64;
735
- if ($[151] !== t63) {
736
- t64 = /* @__PURE__ */ jsx(Typography, { variant: "h5", className: "mb-2", children: t63 });
737
- $[151] = t63;
738
- $[152] = t64;
739
- } else {
740
- t64 = $[152];
741
- }
742
- let t65;
743
- if ($[153] !== t) {
744
- t65 = t("studio_policy_help_intro");
745
- $[153] = t;
746
- $[154] = t65;
747
- } else {
748
- t65 = $[154];
749
- }
750
- let t66;
751
- if ($[155] !== t65) {
752
- t66 = /* @__PURE__ */ jsx(Typography, { className: "text-text-secondary dark:text-text-secondary-dark", children: t65 });
753
- $[155] = t65;
754
- $[156] = t66;
755
- } else {
756
- t66 = $[156];
757
- }
758
- let t67;
759
- if ($[157] !== t64 || $[158] !== t66) {
760
- t67 = /* @__PURE__ */ jsxs("div", { children: [
761
- t64,
762
- t66
763
- ] });
764
- $[157] = t64;
765
- $[158] = t66;
766
- $[159] = t67;
767
- } else {
768
- t67 = $[159];
769
- }
770
- let t68;
771
- if ($[160] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
772
- t68 = cls("p-4 sm:p-5 flex flex-col gap-1", defaultBorderMixin);
773
- $[160] = t68;
774
- } else {
775
- t68 = $[160];
776
- }
777
- let t69;
778
- if ($[161] !== t) {
779
- t69 = t("studio_policy_help_step1_title");
780
- $[161] = t;
781
- $[162] = t69;
782
- } else {
783
- t69 = $[162];
784
- }
785
- let t70;
786
- if ($[163] !== t69) {
787
- t70 = /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "text-primary dark:text-primary-light font-medium", children: t69 });
788
- $[163] = t69;
789
- $[164] = t70;
790
- } else {
791
- t70 = $[164];
792
- }
793
- let t71;
794
- if ($[165] !== t) {
795
- t71 = t("studio_policy_help_step1_desc");
796
- $[165] = t;
797
- $[166] = t71;
798
- } else {
799
- t71 = $[166];
800
- }
801
- let t72;
802
- if ($[167] !== t71) {
803
- t72 = /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-text-secondary dark:text-text-secondary-dark", children: t71 });
804
- $[167] = t71;
805
- $[168] = t72;
806
- } else {
807
- t72 = $[168];
808
- }
809
- let t73;
810
- if ($[169] !== t70 || $[170] !== t72) {
811
- t73 = /* @__PURE__ */ jsxs(Paper, { className: t68, children: [
812
- t70,
813
- t72
814
- ] });
815
- $[169] = t70;
816
- $[170] = t72;
817
- $[171] = t73;
818
- } else {
819
- t73 = $[171];
820
- }
821
- let t74;
822
- if ($[172] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
823
- t74 = cls("p-4 sm:p-5 flex flex-col gap-1", defaultBorderMixin);
824
- $[172] = t74;
825
- } else {
826
- t74 = $[172];
827
- }
828
- let t75;
829
- if ($[173] !== t) {
830
- t75 = t("studio_policy_help_step2_title");
831
- $[173] = t;
832
- $[174] = t75;
833
- } else {
834
- t75 = $[174];
835
- }
836
- let t76;
837
- if ($[175] !== t75) {
838
- t76 = /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "text-primary dark:text-primary-light font-medium", children: t75 });
839
- $[175] = t75;
840
- $[176] = t76;
841
- } else {
842
- t76 = $[176];
843
- }
844
- let t77;
845
- if ($[177] !== t) {
846
- t77 = t("studio_policy_help_step2_desc");
847
- $[177] = t;
848
- $[178] = t77;
849
- } else {
850
- t77 = $[178];
851
- }
852
- let t78;
853
- if ($[179] !== t77) {
854
- t78 = /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-text-secondary dark:text-text-secondary-dark mb-1", children: t77 });
855
- $[179] = t77;
856
- $[180] = t78;
857
- } else {
858
- t78 = $[180];
859
- }
860
- let t79;
861
- if ($[181] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
862
- t79 = /* @__PURE__ */ jsx("strong", { children: "public" });
863
- $[181] = t79;
864
- } else {
865
- t79 = $[181];
866
- }
867
- let t80;
868
- if ($[182] !== t) {
869
- t80 = t("studio_policy_help_role_public");
870
- $[182] = t;
871
- $[183] = t80;
872
- } else {
873
- t80 = $[183];
874
- }
875
- let t81;
876
- if ($[184] !== t80) {
877
- t81 = /* @__PURE__ */ jsxs("li", { children: [
878
- t79,
879
- ": ",
880
- t80
881
- ] });
882
- $[184] = t80;
883
- $[185] = t81;
884
- } else {
885
- t81 = $[185];
886
- }
887
- let t82;
888
- if ($[186] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
889
- t82 = /* @__PURE__ */ jsx("strong", { children: "authenticated" });
890
- $[186] = t82;
891
- } else {
892
- t82 = $[186];
893
- }
894
- let t83;
895
- if ($[187] !== t) {
896
- t83 = t("studio_policy_help_role_authenticated");
897
- $[187] = t;
898
- $[188] = t83;
899
- } else {
900
- t83 = $[188];
901
- }
902
- let t84;
903
- if ($[189] !== t83) {
904
- t84 = /* @__PURE__ */ jsxs("li", { children: [
905
- t82,
906
- ": ",
907
- t83
908
- ] });
909
- $[189] = t83;
910
- $[190] = t84;
911
- } else {
912
- t84 = $[190];
913
- }
914
- let t85;
915
- if ($[191] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
916
- t85 = /* @__PURE__ */ jsx("strong", { children: "anon" });
917
- $[191] = t85;
918
- } else {
919
- t85 = $[191];
920
- }
921
- let t86;
922
- if ($[192] !== t) {
923
- t86 = t("studio_policy_help_role_anon");
924
- $[192] = t;
925
- $[193] = t86;
926
- } else {
927
- t86 = $[193];
928
- }
929
- let t87;
930
- if ($[194] !== t86) {
931
- t87 = /* @__PURE__ */ jsxs("li", { children: [
932
- t85,
933
- ": ",
934
- t86
935
- ] });
936
- $[194] = t86;
937
- $[195] = t87;
938
- } else {
939
- t87 = $[195];
940
- }
941
- let t88;
942
- if ($[196] !== t81 || $[197] !== t84 || $[198] !== t87) {
943
- t88 = /* @__PURE__ */ jsxs("ul", { className: "list-disc pl-5 space-y-1 text-sm text-text-secondary dark:text-text-secondary-dark", children: [
944
- t81,
945
- t84,
946
- t87
947
- ] });
948
- $[196] = t81;
949
- $[197] = t84;
950
- $[198] = t87;
951
- $[199] = t88;
952
- } else {
953
- t88 = $[199];
954
- }
955
- let t89;
956
- if ($[200] !== t76 || $[201] !== t78 || $[202] !== t88) {
957
- t89 = /* @__PURE__ */ jsxs(Paper, { className: t74, children: [
958
- t76,
959
- t78,
960
- t88
961
- ] });
962
- $[200] = t76;
963
- $[201] = t78;
964
- $[202] = t88;
965
- $[203] = t89;
966
- } else {
967
- t89 = $[203];
968
- }
969
- let t90;
970
- if ($[204] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
971
- t90 = cls("p-4 sm:p-5 flex flex-col gap-1", defaultBorderMixin);
972
- $[204] = t90;
973
- } else {
974
- t90 = $[204];
975
- }
976
- let t91;
977
- if ($[205] !== t) {
978
- t91 = t("studio_policy_help_step3_title");
979
- $[205] = t;
980
- $[206] = t91;
981
- } else {
982
- t91 = $[206];
983
- }
984
- let t92;
985
- if ($[207] !== t91) {
986
- t92 = /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "text-primary dark:text-primary-light font-medium", children: t91 });
987
- $[207] = t91;
988
- $[208] = t92;
989
- } else {
990
- t92 = $[208];
991
- }
992
- let t93;
993
- if ($[209] !== t) {
994
- t93 = t("studio_policy_help_step3_desc");
995
- $[209] = t;
996
- $[210] = t93;
997
- } else {
998
- t93 = $[210];
999
- }
1000
- let t94;
1001
- if ($[211] !== t93) {
1002
- t94 = /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-text-secondary dark:text-text-secondary-dark mb-1", children: t93 });
1003
- $[211] = t93;
1004
- $[212] = t94;
1005
- } else {
1006
- t94 = $[212];
1007
- }
1008
- let t95;
1009
- if ($[213] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1010
- t95 = /* @__PURE__ */ jsx("div", { className: cls("bg-surface-100 dark:bg-surface-950 px-3 py-2 rounded-md font-mono text-sm my-2", defaultBorderMixin), children: "Example: auth.uid() = user_id" });
1011
- $[213] = t95;
1012
- } else {
1013
- t95 = $[213];
1014
- }
1015
- let t96;
1016
- if ($[214] !== t) {
1017
- t96 = t("studio_policy_help_step3_example");
1018
- $[214] = t;
1019
- $[215] = t96;
1020
- } else {
1021
- t96 = $[215];
1022
- }
1023
- let t97;
1024
- if ($[216] !== t96) {
1025
- t97 = /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary dark:text-text-secondary-dark", children: t96 });
1026
- $[216] = t96;
1027
- $[217] = t97;
1028
- } else {
1029
- t97 = $[217];
1030
- }
1031
- let t98;
1032
- if ($[218] !== t92 || $[219] !== t94 || $[220] !== t97) {
1033
- t98 = /* @__PURE__ */ jsxs(Paper, { className: t90, children: [
1034
- t92,
1035
- t94,
1036
- t95,
1037
- t97
1038
- ] });
1039
- $[218] = t92;
1040
- $[219] = t94;
1041
- $[220] = t97;
1042
- $[221] = t98;
1043
- } else {
1044
- t98 = $[221];
1045
- }
1046
- let t99;
1047
- if ($[222] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1048
- t99 = cls("p-4 sm:p-5 flex flex-col gap-1", defaultBorderMixin);
1049
- $[222] = t99;
1050
- } else {
1051
- t99 = $[222];
1052
- }
1053
- let t100;
1054
- if ($[223] !== t) {
1055
- t100 = t("studio_policy_help_step4_title");
1056
- $[223] = t;
1057
- $[224] = t100;
1058
- } else {
1059
- t100 = $[224];
1060
- }
1061
- let t101;
1062
- if ($[225] !== t100) {
1063
- t101 = /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "text-primary dark:text-primary-light font-medium", children: t100 });
1064
- $[225] = t100;
1065
- $[226] = t101;
1066
- } else {
1067
- t101 = $[226];
1068
- }
1069
- let t102;
1070
- if ($[227] !== t) {
1071
- t102 = t("studio_policy_help_step4_desc");
1072
- $[227] = t;
1073
- $[228] = t102;
1074
- } else {
1075
- t102 = $[228];
1076
- }
1077
- let t103;
1078
- if ($[229] !== t102) {
1079
- t103 = /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-text-secondary dark:text-text-secondary-dark mb-1", children: t102 });
1080
- $[229] = t102;
1081
- $[230] = t103;
1082
- } else {
1083
- t103 = $[230];
1084
- }
1085
- let t104;
1086
- if ($[231] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1087
- t104 = /* @__PURE__ */ jsx("div", { className: cls("bg-surface-100 dark:bg-surface-950 px-3 py-2 rounded-md font-mono text-sm my-2", defaultBorderMixin), children: "Example: auth.uid() = user_id" });
1088
- $[231] = t104;
1089
- } else {
1090
- t104 = $[231];
1091
- }
1092
- let t105;
1093
- if ($[232] !== t) {
1094
- t105 = t("studio_policy_help_step4_example");
1095
- $[232] = t;
1096
- $[233] = t105;
1097
- } else {
1098
- t105 = $[233];
1099
- }
1100
- let t106;
1101
- if ($[234] !== t105) {
1102
- t106 = /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary dark:text-text-secondary-dark", children: t105 });
1103
- $[234] = t105;
1104
- $[235] = t106;
1105
- } else {
1106
- t106 = $[235];
1107
- }
1108
- let t107;
1109
- if ($[236] !== t101 || $[237] !== t103 || $[238] !== t106) {
1110
- t107 = /* @__PURE__ */ jsxs(Paper, { className: t99, children: [
1111
- t101,
1112
- t103,
1113
- t104,
1114
- t106
1115
- ] });
1116
- $[236] = t101;
1117
- $[237] = t103;
1118
- $[238] = t106;
1119
- $[239] = t107;
1120
- } else {
1121
- t107 = $[239];
1122
- }
1123
- let t108;
1124
- if ($[240] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1125
- t108 = cls("p-4 sm:p-5 flex flex-col gap-2 bg-primary/5 dark:bg-primary-bg-dark/10", defaultBorderMixin);
1126
- $[240] = t108;
1127
- } else {
1128
- t108 = $[240];
1129
- }
1130
- let t109;
1131
- if ($[241] !== t) {
1132
- t109 = t("studio_policy_help_auth_vars_title");
1133
- $[241] = t;
1134
- $[242] = t109;
1135
- } else {
1136
- t109 = $[242];
1137
- }
1138
- let t110;
1139
- if ($[243] !== t109) {
1140
- t110 = /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "text-primary dark:text-primary-light font-medium", children: t109 });
1141
- $[243] = t109;
1142
- $[244] = t110;
1143
- } else {
1144
- t110 = $[244];
1145
- }
1146
- let t111;
1147
- if ($[245] !== t) {
1148
- t111 = t("studio_policy_help_auth_vars_desc");
1149
- $[245] = t;
1150
- $[246] = t111;
1151
- } else {
1152
- t111 = $[246];
1153
- }
1154
- let t112;
1155
- if ($[247] !== t111) {
1156
- t112 = /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-text-secondary dark:text-text-secondary-dark", children: t111 });
1157
- $[247] = t111;
1158
- $[248] = t112;
1159
- } else {
1160
- t112 = $[248];
1161
- }
1162
- let t113;
1163
- if ($[249] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1164
- t113 = /* @__PURE__ */ jsx("code", { className: "bg-surface-100 dark:bg-surface-950 px-1.5 py-0.5 rounded mr-1 whitespace-nowrap", children: "auth.uid()" });
1165
- $[249] = t113;
1166
- } else {
1167
- t113 = $[249];
1168
- }
1169
- let t114;
1170
- let t115;
1171
- if ($[250] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1172
- t114 = /* @__PURE__ */ jsxs("li", { children: [
1173
- t113,
1174
- /* @__PURE__ */ jsxs("span", { className: "block mt-0.5", children: [
1175
- "Returns the current user's ID as text. Example: ",
1176
- /* @__PURE__ */ jsx("code", { className: "bg-surface-100 dark:bg-surface-950 px-1 py-0.5 rounded text-[11px]", children: "auth.uid() = user_id" })
1177
- ] })
1178
- ] });
1179
- t115 = /* @__PURE__ */ jsx("code", { className: "bg-surface-100 dark:bg-surface-950 px-1.5 py-0.5 rounded mr-1 whitespace-nowrap", children: "auth.jwt()" });
1180
- $[250] = t114;
1181
- $[251] = t115;
1182
- } else {
1183
- t114 = $[250];
1184
- t115 = $[251];
1185
- }
1186
- let t116;
1187
- let t117;
1188
- if ($[252] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1189
- t116 = /* @__PURE__ */ jsxs("li", { children: [
1190
- t115,
1191
- /* @__PURE__ */ jsxs("span", { className: "block mt-0.5", children: [
1192
- "Returns the full JWT payload as JSONB so you can check custom claims. Example: ",
1193
- /* @__PURE__ */ jsx("code", { className: "bg-surface-100 dark:bg-surface-950 px-1 py-0.5 rounded text-[11px]", children: "auth.jwt() ->> 'email' = 'admin@example.com'" })
1194
- ] })
1195
- ] });
1196
- t117 = /* @__PURE__ */ jsx("code", { className: "bg-surface-100 dark:bg-surface-950 px-1.5 py-0.5 rounded mr-1 whitespace-nowrap", children: "auth.roles()" });
1197
- $[252] = t116;
1198
- $[253] = t117;
1199
- } else {
1200
- t116 = $[252];
1201
- t117 = $[253];
1202
- }
1203
- let t118;
1204
- if ($[254] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1205
- t118 = /* @__PURE__ */ jsxs("ul", { className: "list-disc pl-5 space-y-2 text-sm text-text-secondary dark:text-text-secondary-dark font-normal", children: [
1206
- t114,
1207
- t116,
1208
- /* @__PURE__ */ jsxs("li", { children: [
1209
- t117,
1210
- /* @__PURE__ */ jsxs("span", { className: "block mt-0.5", children: [
1211
- "Returns the user's role IDs as a comma-separated string. Best used with: ",
1212
- /* @__PURE__ */ jsx("code", { className: "bg-surface-100 dark:bg-surface-950 px-1 py-0.5 rounded text-[11px]", children: "string_to_array(auth.roles(), ',') @> ARRAY['admin']" })
1213
- ] })
1214
- ] })
1215
- ] });
1216
- $[254] = t118;
1217
- } else {
1218
- t118 = $[254];
1219
- }
1220
- let t119;
1221
- if ($[255] !== t110 || $[256] !== t112) {
1222
- t119 = /* @__PURE__ */ jsxs(Paper, { className: t108, children: [
1223
- t110,
1224
- t112,
1225
- t118
1226
- ] });
1227
- $[255] = t110;
1228
- $[256] = t112;
1229
- $[257] = t119;
1230
- } else {
1231
- t119 = $[257];
1232
- }
1233
- let t120;
1234
- if ($[258] !== t107 || $[259] !== t119 || $[260] !== t73 || $[261] !== t89 || $[262] !== t98) {
1235
- t120 = /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
1236
- t73,
1237
- t89,
1238
- t98,
1239
- t107,
1240
- t119
1241
- ] });
1242
- $[258] = t107;
1243
- $[259] = t119;
1244
- $[260] = t73;
1245
- $[261] = t89;
1246
- $[262] = t98;
1247
- $[263] = t120;
1248
- } else {
1249
- t120 = $[263];
1250
- }
1251
- let t121;
1252
- if ($[264] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1253
- t121 = cls("mt-2 flex flex-col sm:flex-row justify-between items-start sm:items-center bg-primary/5 dark:bg-primary-bg-dark/10 p-4 rounded-xl border border-primary/10 dark:border-primary/20", defaultBorderMixin);
1254
- $[264] = t121;
1255
- } else {
1256
- t121 = $[264];
1257
- }
1258
- let t122;
1259
- if ($[265] !== t) {
1260
- t122 = t("studio_policy_help_docs_cta");
1261
- $[265] = t;
1262
- $[266] = t122;
1263
- } else {
1264
- t122 = $[266];
1265
- }
1266
- let t123;
1267
- if ($[267] !== t122) {
1268
- t123 = /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-primary dark:text-primary-light mb-4 sm:mb-0 max-w-md", children: t122 });
1269
- $[267] = t122;
1270
- $[268] = t123;
1271
- } else {
1272
- t123 = $[268];
1273
- }
1274
- let t124;
1275
- if ($[269] !== t) {
1276
- t124 = t("studio_policy_help_read_docs");
1277
- $[269] = t;
1278
- $[270] = t124;
1279
- } else {
1280
- t124 = $[270];
1281
- }
1282
- let t125;
1283
- if ($[271] !== t124) {
1284
- t125 = /* @__PURE__ */ jsx(Button, { component: "a", href: "https://www.postgresql.org/docs/current/sql-createpolicy.html", target: "_blank", variant: "outlined", color: "primary", size: "small", className: "whitespace-nowrap flex-shrink-0", children: t124 });
1285
- $[271] = t124;
1286
- $[272] = t125;
1287
- } else {
1288
- t125 = $[272];
1289
- }
1290
- let t126;
1291
- if ($[273] !== t123 || $[274] !== t125) {
1292
- t126 = /* @__PURE__ */ jsxs("div", { className: t121, children: [
1293
- t123,
1294
- t125
1295
- ] });
1296
- $[273] = t123;
1297
- $[274] = t125;
1298
- $[275] = t126;
1299
- } else {
1300
- t126 = $[275];
1301
- }
1302
- let t127;
1303
- if ($[276] !== t120 || $[277] !== t126 || $[278] !== t67) {
1304
- t127 = /* @__PURE__ */ jsxs(DialogContent, { className: "p-4 sm:p-6 lg:p-8 flex flex-col gap-6", children: [
1305
- t67,
1306
- t120,
1307
- t126
1308
- ] });
1309
- $[276] = t120;
1310
- $[277] = t126;
1311
- $[278] = t67;
1312
- $[279] = t127;
1313
- } else {
1314
- t127 = $[279];
1315
- }
1316
- let t128;
1317
- if ($[280] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1318
- t128 = () => setHelpOpen(false);
1319
- $[280] = t128;
1320
- } else {
1321
- t128 = $[280];
1322
- }
1323
- let t129;
1324
- if ($[281] !== t) {
1325
- t129 = t("studio_policy_help_got_it");
1326
- $[281] = t;
1327
- $[282] = t129;
1328
- } else {
1329
- t129 = $[282];
1330
- }
1331
- let t130;
1332
- if ($[283] !== t129) {
1333
- t130 = /* @__PURE__ */ jsx(DialogActions, { className: "p-4 sm:px-6 sm:pb-6 pt-0 border-t-0", children: /* @__PURE__ */ jsx(Button, { onClick: t128, variant: "filled", color: "primary", children: t129 }) });
1334
- $[283] = t129;
1335
- $[284] = t130;
1336
- } else {
1337
- t130 = $[284];
1338
- }
1339
- let t131;
1340
- if ($[285] !== helpOpen || $[286] !== t127 || $[287] !== t130) {
1341
- t131 = /* @__PURE__ */ jsxs(Dialog, { open: helpOpen, onOpenChange: setHelpOpen, maxWidth: "3xl", children: [
1342
- t127,
1343
- t130
1344
- ] });
1345
- $[285] = helpOpen;
1346
- $[286] = t127;
1347
- $[287] = t130;
1348
- $[288] = t131;
1349
- } else {
1350
- t131 = $[288];
1351
- }
1352
- let t132;
1353
- if ($[289] !== t13 || $[290] !== t131 || $[291] !== t56 || $[292] !== t62) {
1354
- t132 = /* @__PURE__ */ jsxs(Fragment, { children: [
1355
- t13,
1356
- t56,
1357
- t62,
1358
- t131
1359
- ] });
1360
- $[289] = t13;
1361
- $[290] = t131;
1362
- $[291] = t56;
1363
- $[292] = t62;
1364
- $[293] = t132;
1365
- } else {
1366
- t132 = $[293];
1367
- }
1368
- return t132;
1369
- };
1370
- function _temp(preset_0) {
1371
- return /* @__PURE__ */ jsx(SelectItem, { value: preset_0.id, children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-left", children: [
1372
- /* @__PURE__ */ jsx("span", { className: "text-sm", children: preset_0.label }),
1373
- /* @__PURE__ */ jsx("span", { className: "text-xs text-text-secondary dark:text-text-secondary-dark", children: preset_0.description })
1374
- ] }) }, preset_0.id);
1375
- }
1376
- function _temp2(role) {
1377
- return /* @__PURE__ */ jsx(MultiSelectItem, { value: role, children: role }, role);
1378
- }
1379
- function sanitizeSqlIdentifier(name) {
1380
- if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) {
1381
- throw new Error(`Invalid SQL identifier: "${name}". Only letters, digits, and underscores are allowed.`);
1382
- }
1383
- return `"${name}"`;
1384
- }
1385
- const RLSEditor = ({
1386
- apiUrl = ""
1387
- }) => {
1388
- const {
1389
- databaseAdmin
1390
- } = useRebaseContext();
1391
- const snackbarController = useSnackbarController();
1392
- const collectionRegistry = useStudioCollectionRegistry();
1393
- const {
1394
- t
1395
- } = useTranslation();
1396
- const [isLoading, setIsLoading] = useState(true);
1397
- const [error, setError] = useState(null);
1398
- const [tables, setTables] = useState([]);
1399
- const [selectedTable, setSelectedTable] = useState(null);
1400
- const [activeTab, setActiveTab] = useState(0);
1401
- const [editingPolicy, setEditingPolicy] = useState(null);
1402
- const [sidebarSize, setSidebarSize] = useState(() => {
1403
- try {
1404
- const saved = localStorage.getItem("rebase_rls_editor_sidebar_size");
1405
- return saved !== null ? parseFloat(saved) : 20;
1406
- } catch (e) {
1407
- return 20;
1408
- }
1409
- });
1410
- const [expandedSchemas, setExpandedSchemas] = useState({
1411
- public: true
1412
- });
1413
- const [sidebarTab, setSidebarTab] = useState("tables");
1414
- useEffect(() => {
1415
- try {
1416
- localStorage.setItem("rebase_rls_editor_sidebar_size", sidebarSize.toString());
1417
- } catch (e_0) {
1418
- }
1419
- }, [sidebarSize]);
1420
- const fetchRLSData = useCallback(async () => {
1421
- if (!databaseAdmin?.executeSql) {
1422
- setError(t("studio_sql_sql_not_supported"));
1423
- setIsLoading(false);
1424
- return;
1425
- }
1426
- setIsLoading(true);
1427
- setError(null);
1428
- try {
1429
- const tablesSql = `
1430
- SELECT
1431
- schemaname,
1432
- tablename,
1433
- rowsecurity
1434
- FROM pg_tables
1435
- WHERE schemaname NOT IN ('information_schema', 'pg_catalog')
1436
- ORDER BY schemaname, tablename;
1437
- `;
1438
- const tablesResult = await databaseAdmin.executeSql(tablesSql);
1439
- const policiesSql = `
1440
- SELECT
1441
- schemaname,
1442
- tablename,
1443
- policyname,
1444
- permissive,
1445
- roles,
1446
- cmd,
1447
- qual,
1448
- with_check
1449
- FROM pg_policies
1450
- WHERE schemaname NOT IN ('information_schema', 'pg_catalog');
1451
- `;
1452
- const policiesResult = await databaseAdmin.executeSql(policiesSql);
1453
- const extractRows = (result) => {
1454
- if (result && typeof result === "object" && "rows" in result && Array.isArray(result.rows)) {
1455
- return result.rows;
1456
- }
1457
- if (Array.isArray(result)) return result;
1458
- return [];
1459
- };
1460
- const tRows = extractRows(tablesResult);
1461
- const pRows = extractRows(policiesResult);
1462
- const tableMap = {};
1463
- tRows.forEach((tRow) => {
1464
- const t_0 = tRow;
1465
- const schema = t_0.schemaname || t_0.SCHEMANAME || "public";
1466
- const table = t_0.tablename || t_0.TABLENAME || "";
1467
- const rlsEnabled = t_0.rowsecurity || t_0.ROWSECURITY || false;
1468
- const key = `${schema}.${table}`;
1469
- tableMap[key] = {
1470
- schemaName: schema,
1471
- tableName: table,
1472
- rlsEnabled,
1473
- policies: []
1474
- };
1475
- });
1476
- pRows.forEach((pRow) => {
1477
- const p = pRow;
1478
- const schema_0 = p.schemaname || p.SCHEMANAME || "public";
1479
- const table_0 = p.tablename || p.TABLENAME || "";
1480
- const key_0 = `${schema_0}.${table_0}`;
1481
- if (tableMap[key_0]) {
1482
- let parsedRoles = [];
1483
- const r = p.roles || p.ROLES;
1484
- if (Array.isArray(r)) {
1485
- parsedRoles = r;
1486
- } else if (typeof r === "string") {
1487
- parsedRoles = r.replace(/^{|}$/g, "").split(",").map((s) => s.trim());
1488
- }
1489
- tableMap[key_0].policies.push({
1490
- policyname: p.policyname || p.POLICYNAME || "",
1491
- tablename: table_0,
1492
- permissive: p.permissive || p.PERMISSIVE || "PERMISSIVE",
1493
- roles: parsedRoles,
1494
- cmd: p.cmd || p.CMD || "ALL",
1495
- qual: p.qual || p.QUAL || null,
1496
- with_check: p.with_check || p.WITH_CHECK || null
1497
- });
1498
- }
1499
- });
1500
- const sortedTables = Object.values(tableMap).sort((a, b) => a.tableName.localeCompare(b.tableName));
1501
- setTables(sortedTables);
1502
- if (sortedTables.length > 0 && !selectedTable) {
1503
- setSelectedTable(`${sortedTables[0].schemaName}.${sortedTables[0].tableName}`);
1504
- }
1505
- } catch (e_1) {
1506
- console.error("RLS fetch error:", e_1);
1507
- setError("Failed to fetch RLS policies: " + (e_1 instanceof Error ? e_1.message : String(e_1)));
1508
- } finally {
1509
- setIsLoading(false);
1510
- }
1511
- }, [databaseAdmin, selectedTable]);
1512
- useEffect(() => {
1513
- setEditingPolicy(null);
1514
- }, [selectedTable]);
1515
- useEffect(() => {
1516
- fetchRLSData();
1517
- }, [fetchRLSData]);
1518
- const activeTableData = useMemo(() => {
1519
- if (!selectedTable) return null;
1520
- return tables.find((t_1) => `${t_1.schemaName}.${t_1.tableName}` === selectedTable) || null;
1521
- }, [selectedTable, tables]);
1522
- const groupedTables = useMemo(() => {
1523
- const groups = {};
1524
- tables.forEach((table_1) => {
1525
- if (!groups[table_1.schemaName]) {
1526
- groups[table_1.schemaName] = [];
1527
- }
1528
- groups[table_1.schemaName].push(table_1);
1529
- });
1530
- return groups;
1531
- }, [tables]);
1532
- const activeCollection = useMemo(() => {
1533
- if (!activeTableData) return null;
1534
- return collectionRegistry.collections?.find((c2) => c2.id === activeTableData.tableName || c2.path === activeTableData.tableName || c2.table === activeTableData.tableName || c2.slug === activeTableData.tableName || c2.collectionId === activeTableData.tableName) || null;
1535
- }, [activeTableData, collectionRegistry.collections]);
1536
- const mergedPolicies = useMemo(() => {
1537
- if (!activeTableData) return [];
1538
- const policiesMap = {};
1539
- (activeTableData.policies || []).forEach((p_0) => {
1540
- policiesMap[p_0.policyname] = {
1541
- ...p_0,
1542
- status: "live"
1543
- };
1544
- });
1545
- if (activeCollection && isPostgresCollection(activeCollection) && activeCollection.securityRules) {
1546
- activeCollection.securityRules.forEach((rule) => {
1547
- const ruleName = rule.name;
1548
- if (!ruleName) return;
1549
- if (policiesMap[ruleName]) {
1550
- policiesMap[ruleName] = {
1551
- policyname: ruleName,
1552
- tablename: activeTableData.tableName,
1553
- permissive: (rule.mode || "permissive").toUpperCase(),
1554
- cmd: (rule.operation || "ALL").toUpperCase(),
1555
- roles: rule.roles || ["public"],
1556
- qual: rule.using || null,
1557
- with_check: rule.withCheck || null,
1558
- status: "both"
1559
- };
1560
- } else {
1561
- policiesMap[ruleName] = {
1562
- policyname: ruleName,
1563
- tablename: activeTableData.tableName,
1564
- permissive: (rule.mode || "permissive").toUpperCase(),
1565
- cmd: (rule.operation || "ALL").toUpperCase(),
1566
- roles: rule.roles || ["public"],
1567
- qual: rule.using || null,
1568
- with_check: rule.withCheck || null,
1569
- status: "code_only"
1570
- };
1571
- }
1572
- });
1573
- }
1574
- return Object.values(policiesMap).sort((a_0, b_0) => a_0.policyname.localeCompare(b_0.policyname));
1575
- }, [activeTableData, activeCollection]);
1576
- const rlsStats = useMemo(() => {
1577
- const total = tables.length;
1578
- const enabled = tables.filter((t_2) => t_2.rlsEnabled).length;
1579
- const withPolicies = tables.filter((t_3) => t_3.policies.length > 0).length;
1580
- const totalPolicies = tables.reduce((sum, t_4) => sum + t_4.policies.length, 0);
1581
- return {
1582
- total,
1583
- enabled,
1584
- withPolicies,
1585
- totalPolicies
1586
- };
1587
- }, [tables]);
1588
- const renderPolicyTag = (label, value) => {
1589
- return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 px-2 py-1 rounded-md bg-surface-100 dark:bg-surface-950 border border-surface-200 dark:border-surface-700/50", children: [
1590
- /* @__PURE__ */ jsxs("span", { className: "text-[10px] uppercase text-text-secondary dark:text-text-secondary-dark font-medium tracking-wider", children: [
1591
- label,
1592
- ":"
1593
- ] }),
1594
- /* @__PURE__ */ jsx("span", { className: "font-mono text-xs text-text-primary dark:text-text-primary-dark break-all", children: value })
1595
- ] });
1596
- };
1597
- return /* @__PURE__ */ jsx("div", { className: "flex h-full w-full bg-white dark:bg-surface-950 overflow-hidden text-text-primary dark:text-text-primary-dark", children: /* @__PURE__ */ jsx(ResizablePanels, { orientation: "horizontal", panelSizePercent: sidebarSize, onPanelSizeChange: setSidebarSize, minPanelSizePx: 220, firstPanel: /* @__PURE__ */ jsxs("div", { className: cls("flex flex-col h-full w-full bg-white dark:bg-surface-950 border-r", defaultBorderMixin), children: [
1598
- /* @__PURE__ */ jsxs(Tabs, { value: sidebarTab, onValueChange: (v) => setSidebarTab(v), variant: "boxy", className: "border-b border-surface-200 dark:border-surface-950", children: [
1599
- /* @__PURE__ */ jsx(Tab, { value: "tables", children: "Tables" }),
1600
- /* @__PURE__ */ jsx(Tab, { value: "info", children: "Info" })
1601
- ] }),
1602
- /* @__PURE__ */ jsxs("div", { className: "flex-grow overflow-hidden relative", children: [
1603
- sidebarTab === "tables" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
1604
- /* @__PURE__ */ jsxs("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: [
1605
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "font-bold uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark", children: t("studio_schema_tables") }),
1606
- /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: fetchRLSData, title: "Refresh", children: /* @__PURE__ */ jsx(RefreshCwIcon, { size: iconSize.smallest }) })
1607
- ] }),
1608
- /* @__PURE__ */ jsx("div", { className: "flex-grow overflow-y-auto no-scrollbar p-1", children: isLoading && tables.length === 0 ? /* @__PURE__ */ jsx("div", { className: "flex justify-center p-4", children: /* @__PURE__ */ jsx(CircularProgress, { size: "small" }) }) : Object.keys(groupedTables).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 italic", children: t("studio_rls_no_tables") }) }) : Object.entries(groupedTables).map(([schemaName, schemaTables]) => /* @__PURE__ */ jsxs("div", { className: "mb-2", children: [
1609
- /* @__PURE__ */ jsxs("div", { className: "flex items-center p-1 cursor-pointer hover:bg-surface-100 dark:hover:bg-surface-950 rounded transition-colors", onClick: () => setExpandedSchemas((prev) => ({
1610
- ...prev,
1611
- [schemaName]: !prev[schemaName]
1612
- })), children: [
1613
- /* @__PURE__ */ jsx("svg", { className: cls("w-3 h-3 mr-1 transition-transform", expandedSchemas[schemaName] ? "rotate-90" : ""), fill: "currentColor", viewBox: "0 0 20 20", children: /* @__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" }) }),
1614
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-text-primary dark:text-text-primary-dark font-medium text-xs truncate flex-grow", children: schemaName })
1615
- ] }),
1616
- expandedSchemas[schemaName] && /* @__PURE__ */ jsx("div", { className: "ml-3 mt-1 space-y-0.5", children: schemaTables.map((table_2) => {
1617
- const key_1 = `${table_2.schemaName}.${table_2.tableName}`;
1618
- const isSelected = selectedTable === key_1;
1619
- return /* @__PURE__ */ jsxs("div", { onClick: () => setSelectedTable(key_1), className: cls("flex items-center p-1 cursor-pointer rounded transition-colors group relative", isSelected ? "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"), children: [
1620
- /* @__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: "M3 10h18M3 14h18m-9-4v8m-7 0h14a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" }) }),
1621
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-xs truncate flex-1 min-w-0", children: table_2.tableName }),
1622
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 shrink-0 ml-2", children: [
1623
- table_2.rlsEnabled ? /* @__PURE__ */ jsx(Tooltip, { title: t("studio_rls_enabled"), children: /* @__PURE__ */ jsx("div", { className: "w-1.5 h-1.5 rounded-full bg-green-500" }) }) : /* @__PURE__ */ jsx(Tooltip, { title: t("studio_rls_disabled"), children: /* @__PURE__ */ jsx("div", { className: "w-1.5 h-1.5 rounded-full bg-orange-400 opacity-50" }) }),
1624
- /* @__PURE__ */ jsx("span", { className: "text-[10px] opacity-40 group-hover:opacity-100 min-w-[1.2rem] text-right font-medium", children: table_2.policies.length })
1625
- ] })
1626
- ] }, key_1);
1627
- }) })
1628
- ] }, schemaName)) })
1629
- ] }),
1630
- sidebarTab === "info" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
1631
- /* @__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: "Overview" }) }),
1632
- /* @__PURE__ */ jsxs("div", { className: "flex-grow overflow-y-auto p-3 space-y-3 no-scrollbar", children: [
1633
- /* @__PURE__ */ jsxs("div", { className: cls("p-3 rounded-lg border bg-white dark:bg-surface-900", defaultBorderMixin), children: [
1634
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mb-2", children: [
1635
- /* @__PURE__ */ jsx(ShieldIcon, { size: iconSize.smallest, className: "text-primary" }),
1636
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "font-semibold text-[13px]", children: "RLS Studio" })
1637
- ] }),
1638
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary dark:text-text-secondary-dark text-[11px] leading-relaxed block", children: "Manage Row Level Security policies for your PostgreSQL tables. Enable RLS and create fine-grained access policies." })
1639
- ] }),
1640
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
1641
- /* @__PURE__ */ jsxs("div", { className: cls("p-2.5 rounded border bg-white dark:bg-surface-900 flex items-center justify-between", defaultBorderMixin), children: [
1642
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary dark:text-text-secondary-dark text-[11px]", children: "Total tables" }),
1643
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "font-mono text-[13px] font-medium", children: rlsStats.total })
1644
- ] }),
1645
- /* @__PURE__ */ jsxs("div", { className: cls("p-2.5 rounded border bg-white dark:bg-surface-900 flex items-center justify-between", defaultBorderMixin), children: [
1646
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary dark:text-text-secondary-dark text-[11px]", children: "RLS enabled" }),
1647
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
1648
- /* @__PURE__ */ jsx("div", { className: "w-1.5 h-1.5 rounded-full bg-green-500" }),
1649
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "font-mono text-[13px] font-medium", children: rlsStats.enabled })
1650
- ] })
1651
- ] }),
1652
- /* @__PURE__ */ jsxs("div", { className: cls("p-2.5 rounded border bg-white dark:bg-surface-900 flex items-center justify-between", defaultBorderMixin), children: [
1653
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary dark:text-text-secondary-dark text-[11px]", children: "Tables with policies" }),
1654
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "font-mono text-[13px] font-medium", children: rlsStats.withPolicies })
1655
- ] }),
1656
- /* @__PURE__ */ jsxs("div", { className: cls("p-2.5 rounded border bg-white dark:bg-surface-900 flex items-center justify-between", defaultBorderMixin), children: [
1657
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary dark:text-text-secondary-dark text-[11px]", children: "Total policies" }),
1658
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "font-mono text-[13px] font-medium", children: rlsStats.totalPolicies })
1659
- ] })
1660
- ] }),
1661
- rlsStats.total - rlsStats.enabled > 0 && /* @__PURE__ */ jsxs("div", { className: cls("p-2.5 rounded border border-yellow-200 dark:border-yellow-900/50 bg-yellow-50 dark:bg-yellow-900/20 flex items-start gap-2", defaultBorderMixin), children: [
1662
- /* @__PURE__ */ jsx(AlertTriangleIcon, { size: 14, className: "text-yellow-600 dark:text-yellow-500 mt-0.5 shrink-0" }),
1663
- /* @__PURE__ */ jsxs("div", { children: [
1664
- /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-yellow-800 dark:text-yellow-400 text-[11px] font-semibold block", children: [
1665
- rlsStats.total - rlsStats.enabled,
1666
- " table",
1667
- rlsStats.total - rlsStats.enabled > 1 ? "s" : "",
1668
- " without RLS"
1669
- ] }),
1670
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-yellow-700 dark:text-yellow-600 text-[10px] block mt-0.5", children: "These tables have no row-level access control. If auth enforcement is disabled, data may be publicly accessible." })
1671
- ] })
1672
- ] }),
1673
- rlsStats.enabled > 0 && rlsStats.enabled - rlsStats.withPolicies > 0 && /* @__PURE__ */ jsxs("div", { className: cls("p-2.5 rounded border border-blue-200 dark:border-blue-900/50 bg-blue-50 dark:bg-blue-900/20 flex items-start gap-2", defaultBorderMixin), children: [
1674
- /* @__PURE__ */ jsx(ShieldIcon, { size: 14, className: "text-blue-600 dark:text-blue-400 mt-0.5 shrink-0" }),
1675
- /* @__PURE__ */ jsxs("div", { children: [
1676
- /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-blue-800 dark:text-blue-300 text-[11px] font-semibold block", children: [
1677
- rlsStats.enabled - rlsStats.withPolicies,
1678
- " table",
1679
- rlsStats.enabled - rlsStats.withPolicies > 1 ? "s" : "",
1680
- " with RLS but no policies"
1681
- ] }),
1682
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-blue-700 dark:text-blue-500 text-[10px] block mt-0.5", children: "RLS is enabled but no permissive policies exist. All access is denied by default (Postgres deny-all)." })
1683
- ] })
1684
- ] })
1685
- ] })
1686
- ] })
1687
- ] })
1688
- ] }), secondPanel: /* @__PURE__ */ jsxs("div", { className: "flex-grow flex flex-col min-w-0 h-full w-full bg-white dark:bg-surface-950", children: [
1689
- /* @__PURE__ */ jsxs("div", { className: cls("flex items-center justify-between pr-2 border-b bg-white dark:bg-surface-950 min-h-[46px]", defaultBorderMixin), children: [
1690
- /* @__PURE__ */ jsxs("div", { className: "flex items-center flex-grow overflow-hidden px-4", children: [
1691
- /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "font-mono text-text-secondary dark:text-text-secondary-dark truncate", children: activeTableData ? `${activeTableData.schemaName}.${activeTableData.tableName}` : t("studio_rls_select_table") }),
1692
- activeTableData && /* @__PURE__ */ jsx("div", { className: "ml-3", children: activeTableData.rlsEnabled ? /* @__PURE__ */ jsx(Chip, { size: "smallest", className: "bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400 border-green-200 dark:border-green-800", children: t("studio_rls_enabled") }) : /* @__PURE__ */ jsx(Chip, { size: "smallest", className: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400 border-yellow-200 dark:border-yellow-800", children: t("studio_rls_disabled") }) })
1693
- ] }),
1694
- /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center justify-end gap-1.5", children: activeTableData && /* @__PURE__ */ jsxs(Fragment, { children: [
1695
- /* @__PURE__ */ jsx(Button, { variant: "text", size: "small", onClick: async () => {
1696
- const table_3 = activeTableData.tableName;
1697
- const action = activeTableData.rlsEnabled ? "DISABLE" : "ENABLE";
1698
- if (!confirm(`Are you sure you want to ${action.toLowerCase()} Row Level Security on "${table_3}"?`)) return;
1699
- try {
1700
- await databaseAdmin.executeSql(`ALTER TABLE ${sanitizeSqlIdentifier(table_3)} ${action} ROW LEVEL SECURITY`);
1701
- snackbarController.open({
1702
- type: "success",
1703
- message: `RLS ${action.toLowerCase()}d on ${table_3}`
1704
- });
1705
- fetchRLSData();
1706
- } catch (e_2) {
1707
- snackbarController.open({
1708
- type: "error",
1709
- message: e_2 instanceof Error ? e_2.message : String(e_2)
1710
- });
1711
- }
1712
- }, children: activeTableData.rlsEnabled ? t("studio_rls_disable_rls") : t("studio_rls_enable_rls") }),
1713
- /* @__PURE__ */ jsx("div", { className: "h-4 w-px bg-surface-200 dark:bg-surface-950 mx-1" }),
1714
- /* @__PURE__ */ jsx(Button, { variant: "text", size: "small", onClick: fetchRLSData, startIcon: /* @__PURE__ */ jsx(RefreshCwIcon, { size: iconSize.smallest }), children: "Refresh" }),
1715
- /* @__PURE__ */ jsx("div", { className: "h-4 w-px bg-surface-200 dark:bg-surface-950 mx-1" }),
1716
- /* @__PURE__ */ jsx(Button, { size: "small", color: "primary", disabled: !activeCollection, onClick: () => setEditingPolicy("new"), children: t("studio_rls_create_policy") })
1717
- ] }) })
1718
- ] }),
1719
- isLoading && !activeTableData ? /* @__PURE__ */ jsx("div", { className: "flex-grow flex items-center justify-center h-full", children: /* @__PURE__ */ jsx(CircularProgress, { size: "small" }) }) : error ? /* @__PURE__ */ jsx("div", { className: "p-6 h-full flex items-center justify-center", children: /* @__PURE__ */ jsx(ErrorView, { title: t("studio_rls_error"), error, onRetry: fetchRLSData }) }) : !activeTableData ? /* @__PURE__ */ jsx("div", { className: "flex-grow flex items-center justify-center text-text-disabled h-full", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
1720
- /* @__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: "M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" }) }),
1721
- /* @__PURE__ */ jsx(Typography, { variant: "body2", children: t("studio_rls_select_table") })
1722
- ] }) }) : editingPolicy ? /* @__PURE__ */ jsx(PolicyEditor, { policy: editingPolicy === "new" ? void 0 : editingPolicy, schema: activeTableData.schemaName, table: activeTableData.tableName, onSave: async (newPolicy) => {
1723
- if (!activeCollection) return;
1724
- const rule_0 = {
1725
- name: newPolicy.policyname,
1726
- operation: newPolicy.cmd?.toLowerCase(),
1727
- mode: newPolicy.permissive?.toLowerCase(),
1728
- using: newPolicy.qual || void 0,
1729
- withCheck: newPolicy.with_check || void 0,
1730
- roles: newPolicy.roles
1731
- };
1732
- const existingRules = (isPostgresCollection(activeCollection) ? activeCollection.securityRules : void 0) || [];
1733
- let newRules;
1734
- if (editingPolicy === "new") {
1735
- newRules = [...existingRules, rule_0];
1736
- } else {
1737
- newRules = existingRules.map((r_0) => r_0.name === editingPolicy.policyname ? rule_0 : r_0);
1738
- }
1739
- try {
1740
- const response = await fetch(`${apiUrl}/api/schema-editor/collection/save`, {
1741
- method: "POST",
1742
- headers: {
1743
- "Content-Type": "application/json"
1744
- },
1745
- body: JSON.stringify({
1746
- collectionId: activeCollection.id || activeCollection.path || activeCollection.alias || activeTableData.tableName,
1747
- collectionData: {
1748
- securityRules: newRules
1749
- }
1750
- })
1751
- });
1752
- if (!response.ok) throw new Error("Failed to save policy");
1753
- snackbarController.open({
1754
- type: "success",
1755
- message: "Policy saved successfully"
1756
- });
1757
- setEditingPolicy(null);
1758
- fetchRLSData();
1759
- } catch (e_3) {
1760
- snackbarController.open({
1761
- type: "error",
1762
- message: e_3 instanceof Error ? e_3.message : String(e_3)
1763
- });
1764
- }
1765
- }, onCancel: () => setEditingPolicy(null) }) : /* @__PURE__ */ jsx("div", { className: "flex-grow flex flex-col overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "p-6 pt-4 flex-grow overflow-auto bg-surface-50 dark:bg-surface-900", children: /* @__PURE__ */ jsxs("div", { className: "max-w-4xl mx-auto flex flex-col gap-6", children: [
1766
- activeTableData && !activeCollection && /* @__PURE__ */ jsxs(Alert, { color: "warning", children: [
1767
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "mb-1", children: "Table not managed by Rebase" }),
1768
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "opacity-80", children: "This table is not mapped to a Rebase Schema via code. To edit security policies visually, you must first import this table into a Schema configuration file." })
1769
- ] }),
1770
- activeTableData && !activeTableData.rlsEnabled && /* @__PURE__ */ jsxs("div", { className: cls("p-4 sm:p-5 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-900/50 rounded-lg flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between", defaultBorderMixin), children: [
1771
- /* @__PURE__ */ jsxs("div", { className: "flex gap-3 items-start", children: [
1772
- /* @__PURE__ */ jsx("div", { className: "mt-1 bg-yellow-100 dark:bg-yellow-900/50 p-1.5 rounded-md shrink-0 flex items-center justify-center", children: /* @__PURE__ */ jsx(AlertTriangleIcon, { size: iconSize.smallest }) }),
1773
- /* @__PURE__ */ jsxs("div", { children: [
1774
- /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "text-yellow-800 dark:text-yellow-500", children: "Row Level Security (RLS) is disabled" }),
1775
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-yellow-700 dark:text-yellow-600/90 mt-1 max-w-2xl", children: "Your table is completely readable and writable by anyone with access privileges. Enable RLS to create policies that restrict access to specific rows." })
1776
- ] })
1777
- ] }),
1778
- /* @__PURE__ */ jsx(Button, { size: "medium", variant: "filled", color: "neutral", onClick: () => setEditingPolicy("new"), className: "shrink-0 whitespace-nowrap", disabled: !activeCollection, children: t("studio_rls_create_policy") })
1779
- ] }),
1780
- activeTableData && mergedPolicies && mergedPolicies.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
1781
- /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "text-text-secondary dark:text-text-secondary-dark uppercase tracking-wider mb-1", children: t("studio_rls_policies") }),
1782
- mergedPolicies.map((policy) => /* @__PURE__ */ jsxs(Paper, { className: cls("p-3 sm:px-4 sm:py-3 flex flex-col sm:flex-row sm:items-center justify-between gap-4 border rounded-lg", defaultBorderMixin), children: [
1783
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 min-w-0", children: [
1784
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1785
- /* @__PURE__ */ jsx(KeyIcon, { size: iconSize.smallest, className: "text-text-secondary dark:text-text-secondary-dark shrink-0" }),
1786
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "truncate", children: policy.policyname }),
1787
- policy.status === "code_only" && /* @__PURE__ */ jsx(Tooltip, { title: "This policy is defined in your code but hasn't been applied to the database yet.", children: /* @__PURE__ */ jsx("div", { className: "px-1.5 py-0.5 rounded text-[10px] uppercase bg-primary/10 text-primary border border-primary/20 shrink-0", children: "Unapplied" }) }),
1788
- policy.status === "live" && /* @__PURE__ */ jsx(Tooltip, { title: "This policy is live in the database but missing from your codebase schema.", children: /* @__PURE__ */ jsx("div", { className: "px-1.5 py-0.5 rounded text-[10px] uppercase bg-orange-500/10 text-orange-600 border border-orange-500/20 shrink-0", children: "DB Only" }) })
1789
- ] }),
1790
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1.5 text-sm", children: [
1791
- renderPolicyTag("Action", policy.cmd),
1792
- renderPolicyTag("Roles", Array.isArray(policy.roles) ? policy.roles.join(", ") : policy.roles)
1793
- ] })
1794
- ] }),
1795
- /* @__PURE__ */ jsxs("div", { className: "flex gap-2 shrink-0 items-center", children: [
1796
- policy.status === "live" && activeCollection && /* @__PURE__ */ jsx(Button, { size: "small", variant: "outlined", color: "primary", onClick: async () => {
1797
- const rule_1 = {
1798
- name: policy.policyname,
1799
- operation: policy.cmd?.toLowerCase(),
1800
- mode: policy.permissive?.toLowerCase(),
1801
- using: policy.qual || void 0,
1802
- withCheck: policy.with_check || void 0,
1803
- roles: policy.roles
1804
- };
1805
- const existingRules_0 = (isPostgresCollection(activeCollection) ? activeCollection.securityRules : void 0) || [];
1806
- const newRules_0 = [...existingRules_0, rule_1];
1807
- try {
1808
- const response_0 = await fetch(`${apiUrl}/api/schema-editor/collection/save`, {
1809
- method: "POST",
1810
- headers: {
1811
- "Content-Type": "application/json"
1812
- },
1813
- body: JSON.stringify({
1814
- collectionId: activeCollection.id || activeCollection.path || activeCollection.alias || activeTableData.tableName,
1815
- collectionData: {
1816
- securityRules: newRules_0
1817
- }
1818
- })
1819
- });
1820
- if (!response_0.ok) throw new Error("Failed to save policy");
1821
- snackbarController.open({
1822
- type: "success",
1823
- message: "Policy imported successfully"
1824
- });
1825
- fetchRLSData();
1826
- } catch (e_4) {
1827
- snackbarController.open({
1828
- type: "error",
1829
- message: e_4 instanceof Error ? e_4.message : String(e_4)
1830
- });
1831
- }
1832
- }, children: "Import to codebase" }),
1833
- /* @__PURE__ */ jsx(Button, { size: "small", variant: "text", color: "primary", onClick: () => setEditingPolicy(policy), disabled: !activeCollection, children: t("studio_rls_edit") }),
1834
- policy.status !== "code_only" && /* @__PURE__ */ jsx(Tooltip, { title: t("studio_rls_delete"), asChild: true, children: /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: async () => {
1835
- const table_4 = activeTableData.tableName;
1836
- if (!confirm(`Drop policy "${policy.policyname}" from table "${table_4}"?`)) return;
1837
- try {
1838
- await databaseAdmin.executeSql(`DROP POLICY ${sanitizeSqlIdentifier(policy.policyname)} ON ${sanitizeSqlIdentifier(table_4)}`);
1839
- snackbarController.open({
1840
- type: "success",
1841
- message: `Policy "${policy.policyname}" dropped`
1842
- });
1843
- fetchRLSData();
1844
- } catch (e_5) {
1845
- snackbarController.open({
1846
- type: "error",
1847
- message: e_5 instanceof Error ? e_5.message : String(e_5)
1848
- });
1849
- }
1850
- }, children: /* @__PURE__ */ jsx(Trash2Icon, { size: iconSize.smallest }) }) })
1851
- ] })
1852
- ] }, policy.policyname))
1853
- ] }),
1854
- activeTableData && mergedPolicies.length === 0 && activeTableData.rlsEnabled && /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-12 text-center", children: [
1855
- /* @__PURE__ */ jsx(ShieldIcon, { size: 40, className: "text-surface-300 dark:text-surface-600 mb-4" }),
1856
- /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "text-text-secondary dark:text-text-secondary-dark mb-2", children: "No policies defined" }),
1857
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-disabled dark:text-text-disabled-dark max-w-sm mb-4", children: "RLS is enabled on this table but no policies exist. All access is denied by default (Postgres deny-all). Create a policy to allow specific access." }),
1858
- activeCollection && /* @__PURE__ */ jsx(Button, { size: "small", variant: "filled", color: "primary", onClick: () => setEditingPolicy("new"), children: t("studio_rls_create_policy") })
1859
- ] }),
1860
- activeTableData && mergedPolicies.length === 0 && !activeTableData.rlsEnabled && activeCollection && /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-12 text-center", children: [
1861
- /* @__PURE__ */ jsx(AlertTriangleIcon, { size: 40, className: "text-yellow-400 dark:text-yellow-600 mb-4" }),
1862
- /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "text-text-secondary dark:text-text-secondary-dark mb-2", children: "No access control" }),
1863
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-disabled dark:text-text-disabled-dark max-w-sm", children: "This table has neither RLS nor policies. Enable RLS and create policies to restrict row-level access." })
1864
- ] })
1865
- ] }) }) })
1866
- ] }) }) });
1867
- };
1868
- export {
1869
- RLSEditor
1870
- };
1871
- //# sourceMappingURL=RLSEditor-CHEExeSB.js.map