@rebasepro/cms 0.30.1 → 0.31.0-canary.g902a0ce

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 (583) hide show
  1. package/README.md +8 -8
  2. package/dist/collection_editor/ConfigControllerProvider.js +25 -22
  3. package/dist/collection_editor/ConfigControllerProvider.js.map +1 -1
  4. package/dist/collection_editor/firestore_callee.d.ts +10 -0
  5. package/dist/collection_editor/firestore_callee.js +15 -0
  6. package/dist/collection_editor/firestore_callee.js.map +1 -0
  7. package/dist/collection_editor/firestore_edit.d.ts +62 -0
  8. package/dist/collection_editor/firestore_edit.js +339 -0
  9. package/dist/collection_editor/firestore_edit.js.map +1 -0
  10. package/dist/collection_editor/index.d.ts +2 -3
  11. package/dist/collection_editor/liveSchemaClient.d.ts +44 -22
  12. package/dist/collection_editor/liveSchemaClient.js +9 -3
  13. package/dist/collection_editor/liveSchemaClient.js.map +1 -1
  14. package/dist/collection_editor/property_column.d.ts +86 -0
  15. package/dist/collection_editor/property_column.js +719 -0
  16. package/dist/collection_editor/property_column.js.map +1 -0
  17. package/dist/collection_editor/serializable_types.d.ts +2 -24
  18. package/dist/collection_editor/serializable_utils.d.ts +1 -1
  19. package/dist/collection_editor/serializable_utils.js +2 -1
  20. package/dist/collection_editor/serializable_utils.js.map +1 -1
  21. package/dist/collection_editor/split_edit.d.ts +106 -0
  22. package/dist/collection_editor/split_edit.js +564 -0
  23. package/dist/collection_editor/split_edit.js.map +1 -0
  24. package/dist/collection_editor/split_edit_error.d.ts +25 -0
  25. package/dist/collection_editor/split_edit_error.js +35 -0
  26. package/dist/collection_editor/split_edit_error.js.map +1 -0
  27. package/dist/collection_editor/types/collection_editor_controller.d.ts +1 -1
  28. package/dist/collection_editor/types/config_controller.d.ts +67 -1
  29. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.d.ts +6 -5
  30. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js +44 -12
  31. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js.map +1 -1
  32. package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js +18 -3
  33. package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js.map +1 -1
  34. package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js +94 -55
  35. package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js.map +1 -1
  36. package/dist/collection_editor/ui/collection_editor/CollectionRelationsTab.d.ts +2 -1
  37. package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js.map +1 -1
  38. package/dist/collection_editor/ui/collection_editor/EnumForm.d.ts +1 -1
  39. package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -1
  40. package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js +3 -3
  41. package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js.map +1 -1
  42. package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js.map +1 -1
  43. package/dist/collection_editor/ui/collection_editor/PropertyEditView.d.ts +2 -3
  44. package/dist/collection_editor/ui/collection_editor/PropertyEditView.js +1 -1
  45. package/dist/collection_editor/ui/collection_editor/PropertyEditView.js.map +1 -1
  46. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.d.ts +1 -1
  47. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js +1 -1
  48. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js.map +1 -1
  49. package/dist/collection_editor/ui/collection_editor/PropertyTree.d.ts +7 -4
  50. package/dist/collection_editor/ui/collection_editor/PropertyTree.js +15 -5
  51. package/dist/collection_editor/ui/collection_editor/PropertyTree.js.map +1 -1
  52. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +1 -1
  53. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
  54. package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.d.ts +20 -0
  55. package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js +74 -0
  56. package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js.map +1 -0
  57. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.d.ts +1 -1
  58. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
  59. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js.map +1 -1
  60. package/dist/collection_editor/ui/collection_editor/import/clean_import_data.d.ts +1 -1
  61. package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js.map +1 -1
  62. package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js.map +1 -1
  63. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -1
  64. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +1 -1
  65. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -1
  66. package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js.map +1 -1
  67. package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js.map +1 -1
  68. package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js.map +1 -1
  69. package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js.map +1 -1
  70. package/dist/collection_editor/ui/collection_editor/properties/conditions/ConditionsEditor.d.ts +1 -1
  71. package/dist/collection_editor/ui/collection_editor/properties/conditions/EnumConditionsEditor.d.ts +1 -1
  72. package/dist/collection_editor/ui/collection_editor/properties/conditions/property_paths.d.ts +1 -1
  73. package/dist/collection_editor/ui/collection_editor/rlsRuleForm.d.ts +34 -0
  74. package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js +50 -0
  75. package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js.map +1 -0
  76. package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.d.ts +1 -2
  77. package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js.map +1 -1
  78. package/dist/collection_editor/useDetachRulesConfirmation.d.ts +16 -0
  79. package/dist/collection_editor/useDetachRulesConfirmation.js +48 -0
  80. package/dist/collection_editor/useDetachRulesConfirmation.js.map +1 -0
  81. package/dist/collection_editor/useLiveSchemaEditing.d.ts +2 -2
  82. package/dist/collection_editor/useLiveSchemaEditing.js +1 -1
  83. package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -1
  84. package/dist/collection_editor/useLocalCollectionsConfigController.d.ts +54 -10
  85. package/dist/collection_editor/useLocalCollectionsConfigController.js +394 -122
  86. package/dist/collection_editor/useLocalCollectionsConfigController.js.map +1 -1
  87. package/dist/collection_editor/validateCollectionJson.js.map +1 -1
  88. package/dist/components/CollectionPanel.d.ts +10 -9
  89. package/dist/components/CollectionPanel.js +5 -2
  90. package/dist/components/CollectionPanel.js.map +1 -1
  91. package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +1 -2
  92. package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
  93. package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
  94. package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +3 -5
  95. package/dist/components/CollectionTableBinding/PropertyTableCell.d.ts +2 -2
  96. package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
  97. package/dist/components/CollectionTableBinding/column_utils.d.ts +1 -1
  98. package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
  99. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.d.ts +2 -2
  100. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +1 -2
  101. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
  102. package/dist/components/CollectionTableBinding/fields/TableReferenceField.d.ts +2 -2
  103. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +2 -2
  104. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
  105. package/dist/components/CollectionTableBinding/fields/TableRelationField.d.ts +2 -2
  106. package/dist/components/CollectionTableBinding/fields/TableRelationField.js +1 -2
  107. package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
  108. package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.d.ts +2 -1
  109. package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js.map +1 -1
  110. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.d.ts +2 -2
  111. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -1
  112. package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.d.ts +1 -1
  113. package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js +1 -1
  114. package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js.map +1 -1
  115. package/dist/components/CollectionTableBinding/internal/common.d.ts +1 -2
  116. package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
  117. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.d.ts +1 -1
  118. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +2 -2
  119. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
  120. package/dist/components/CollectionTableBinding/table_bindings.d.ts +2 -2
  121. package/dist/components/CollectionTableBinding/table_bindings.js.map +1 -1
  122. package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +1 -1
  123. package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
  124. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +1 -2
  125. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -5
  126. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
  127. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +1 -2
  128. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
  129. package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +1 -1
  130. package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -1
  131. package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +1 -2
  132. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +1 -1
  133. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
  134. package/dist/components/CollectionViewBinding/CollectionToolbar.js +1 -1
  135. package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -1
  136. package/dist/components/CollectionViewBinding/CollectionViewActions.js +2 -4
  137. package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
  138. package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +6 -6
  139. package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
  140. package/dist/components/CollectionViewBinding/CollectionViewContent.js +1 -2
  141. package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -1
  142. package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +1 -1
  143. package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
  144. package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +1 -2
  145. package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -1
  146. package/dist/components/CollectionViewBinding/EntitiesCount.js +3 -3
  147. package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -1
  148. package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +1 -2
  149. package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
  150. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +1 -1
  151. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -1
  152. package/dist/components/CollectionViewBinding/FilterPresetsButton.d.ts +1 -2
  153. package/dist/components/CollectionViewBinding/FilterPresetsButton.js +1 -1
  154. package/dist/components/CollectionViewBinding/FilterPresetsButton.js.map +1 -1
  155. package/dist/components/CollectionViewBinding/FiltersButton.d.ts +1 -2
  156. package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -1
  157. package/dist/components/CollectionViewBinding/FiltersDialog.d.ts +1 -1
  158. package/dist/components/CollectionViewBinding/FiltersDialog.js.map +1 -1
  159. package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +1 -2
  160. package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -1
  161. package/dist/components/CollectionViewBinding/RowActions.d.ts +1 -2
  162. package/dist/components/CollectionViewBinding/RowActions.js.map +1 -1
  163. package/dist/components/CollectionViewBinding/SortButton.d.ts +1 -1
  164. package/dist/components/CollectionViewBinding/SortButton.js.map +1 -1
  165. package/dist/components/CollectionViewBinding/SplitListView.d.ts +1 -2
  166. package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
  167. package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.d.ts +1 -2
  168. package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js +1 -1
  169. package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js.map +1 -1
  170. package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.d.ts +1 -2
  171. package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js.map +1 -1
  172. package/dist/components/CollectionViewBinding/useBoardDataController.d.ts +2 -1
  173. package/dist/components/CollectionViewBinding/useBoardDataController.js +3 -3
  174. package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
  175. package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +2 -4
  176. package/dist/components/CollectionViewBinding/useCollectionViewState.js +14 -19
  177. package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -1
  178. package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +1 -3
  179. package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
  180. package/dist/components/CollectionViewBinding/useSelectionController.d.ts +1 -2
  181. package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
  182. package/dist/components/CollectionsProvider.d.ts +23 -8
  183. package/dist/components/CollectionsProvider.js +23 -7
  184. package/dist/components/CollectionsProvider.js.map +1 -1
  185. package/dist/components/DefaultDrawer.js +1 -1
  186. package/dist/components/DeleteEntityDialog.d.ts +1 -1
  187. package/dist/components/DeleteEntityDialog.js +1 -1
  188. package/dist/components/DeleteEntityDialog.js.map +1 -1
  189. package/dist/components/DetailViewBinding.js +3 -3
  190. package/dist/components/DetailViewBinding.js.map +1 -1
  191. package/dist/components/EditFormActions.js.map +1 -1
  192. package/dist/components/EditViewBinding.d.ts +2 -1
  193. package/dist/components/EditViewBinding.js +6 -6
  194. package/dist/components/EditViewBinding.js.map +1 -1
  195. package/dist/components/EntityDisplayHeader.d.ts +1 -2
  196. package/dist/components/EntityDisplayHeader.js.map +1 -1
  197. package/dist/components/EntityInspector.d.ts +1 -2
  198. package/dist/components/EntityInspector.js.map +1 -1
  199. package/dist/components/EntityPreviewBinding.d.ts +1 -1
  200. package/dist/components/EntityPreviewBinding.js +1 -1
  201. package/dist/components/EntityPreviewBinding.js.map +1 -1
  202. package/dist/components/EntityViewBinding.d.ts +1 -1
  203. package/dist/components/EntityViewBinding.js.map +1 -1
  204. package/dist/components/EntityViewBody.d.ts +1 -1
  205. package/dist/components/EntityViewBody.js +3 -4
  206. package/dist/components/EntityViewBody.js.map +1 -1
  207. package/dist/components/FieldValue.js +2 -2
  208. package/dist/components/FieldValue.js.map +1 -1
  209. package/dist/components/HomePage/ContentHomePage.js +12 -3
  210. package/dist/components/HomePage/ContentHomePage.js.map +1 -1
  211. package/dist/components/InlineEntityPreview.d.ts +1 -1
  212. package/dist/components/InlineEntityPreview.js.map +1 -1
  213. package/dist/components/PropertyCollectionView.d.ts +2 -2
  214. package/dist/components/PropertyCollectionView.js.map +1 -1
  215. package/dist/components/PropertyConfigBadge.js.map +1 -1
  216. package/dist/components/RebaseCMS.d.ts +22 -3
  217. package/dist/components/RebaseCMS.js +32 -14
  218. package/dist/components/RebaseCMS.js.map +1 -1
  219. package/dist/components/RebaseNavigation.js +106 -31
  220. package/dist/components/RebaseNavigation.js.map +1 -1
  221. package/dist/components/RecordDetail.js +4 -1
  222. package/dist/components/RecordDetail.js.map +1 -1
  223. package/dist/components/RecordForm.d.ts +5 -5
  224. package/dist/components/RecordForm.js +5 -2
  225. package/dist/components/RecordForm.js.map +1 -1
  226. package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +2 -2
  227. package/dist/components/ReferenceTable/SelectionTableBinding.js +1 -1
  228. package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
  229. package/dist/components/ReferenceWidget.d.ts +2 -1
  230. package/dist/components/ReferenceWidget.js +2 -2
  231. package/dist/components/ReferenceWidget.js.map +1 -1
  232. package/dist/components/RelationSelector.d.ts +2 -1
  233. package/dist/components/RelationSelector.js +2 -3
  234. package/dist/components/RelationSelector.js.map +1 -1
  235. package/dist/components/SelectableTable/SelectableTable.d.ts +2 -2
  236. package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
  237. package/dist/components/SelectableTable/filters/FilterFieldBinding.d.ts +2 -1
  238. package/dist/components/SelectableTable/filters/FilterFieldBinding.js +3 -3
  239. package/dist/components/SelectableTable/filters/FilterFieldBinding.js.map +1 -1
  240. package/dist/components/SelectableTable/filters/ReferenceFilterField.js +2 -2
  241. package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -1
  242. package/dist/components/SelectableTable/filters/RelationFilterField.d.ts +1 -1
  243. package/dist/components/SelectableTable/filters/RelationFilterField.js +1 -1
  244. package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -1
  245. package/dist/components/SelectableTable/filters/StringNumberFilterField.d.ts +1 -1
  246. package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -1
  247. package/dist/components/SelectableTable/filters/null_filter.d.ts +1 -3
  248. package/dist/components/SelectableTable/filters/null_filter.js.map +1 -1
  249. package/dist/components/SidePanelBinding.js +1 -1
  250. package/dist/components/SidePanelBinding.js.map +1 -1
  251. package/dist/components/field_configs.d.ts +1 -2
  252. package/dist/components/field_configs.js.map +1 -1
  253. package/dist/components/field_ids.d.ts +1 -1
  254. package/dist/components/field_ids.js +1 -1
  255. package/dist/components/field_ids.js.map +1 -1
  256. package/dist/components/history/EntityHistoryEntry.js.map +1 -1
  257. package/dist/components/history/EntityHistoryView.d.ts +1 -2
  258. package/dist/components/history/EntityHistoryView.js +1 -1
  259. package/dist/components/history/EntityHistoryView.js.map +1 -1
  260. package/dist/data_export/export/BasicExportAction.d.ts +1 -1
  261. package/dist/data_export/export/BasicExportAction.js.map +1 -1
  262. package/dist/data_export/export/ExportCollectionAction.js +2 -2
  263. package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
  264. package/dist/data_export/export/additional_fields.d.ts +1 -1
  265. package/dist/data_export/export/additional_fields.js.map +1 -1
  266. package/dist/data_export/export/export.d.ts +1 -1
  267. package/dist/data_export/export/export.js +1 -1
  268. package/dist/data_export/export/export.js.map +1 -1
  269. package/dist/data_export/export/fetch_export_data.d.ts +3 -2
  270. package/dist/data_export/export/fetch_export_data.js.map +1 -1
  271. package/dist/data_import/components/DataNewPropertiesMapping.d.ts +1 -1
  272. package/dist/data_import/components/DataNewPropertiesMapping.js.map +1 -1
  273. package/dist/data_import/components/ImportNewPropertyFieldPreview.d.ts +1 -1
  274. package/dist/data_import/components/ImportNewPropertyFieldPreview.js.map +1 -1
  275. package/dist/data_import/hooks/useImportConfig.js.map +1 -1
  276. package/dist/data_import/import/ImportCollectionAction.d.ts +2 -2
  277. package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
  278. package/dist/data_import/types/column_mapping.d.ts +1 -1
  279. package/dist/data_import/utils/data.d.ts +1 -2
  280. package/dist/data_import/utils/data.js +1 -2
  281. package/dist/data_import/utils/data.js.map +1 -1
  282. package/dist/data_import/utils/get_import_inference_type.d.ts +1 -1
  283. package/dist/data_import/utils/get_import_inference_type.js.map +1 -1
  284. package/dist/data_import/utils/id_column.d.ts +1 -1
  285. package/dist/data_import/utils/id_column.js.map +1 -1
  286. package/dist/data_import/utils/import_columns.d.ts +1 -1
  287. package/dist/data_import/utils/import_columns.js.map +1 -1
  288. package/dist/data_import/utils/save_entities.d.ts +3 -3
  289. package/dist/data_import/utils/save_entities.js +1 -1
  290. package/dist/data_import/utils/save_entities.js.map +1 -1
  291. package/dist/form/EntityForm.js +2 -1
  292. package/dist/form/EntityForm.js.map +1 -1
  293. package/dist/form/EntityFormActions.js.map +1 -1
  294. package/dist/form/EntityFormBinding.js +2 -2
  295. package/dist/form/EntityFormBinding.js.map +1 -1
  296. package/dist/form/FormFieldsContext.d.ts +1 -4
  297. package/dist/form/FormFieldsContext.js +1 -1
  298. package/dist/form/FormFieldsContext.js.map +1 -1
  299. package/dist/form/PropertyFieldBinding.js +6 -8
  300. package/dist/form/PropertyFieldBinding.js.map +1 -1
  301. package/dist/form/components/FieldBlock.d.ts +1 -2
  302. package/dist/form/components/FieldBlock.js.map +1 -1
  303. package/dist/form/components/FieldHelperText.d.ts +1 -1
  304. package/dist/form/components/FieldHelperText.js.map +1 -1
  305. package/dist/form/components/FormRail.d.ts +1 -1
  306. package/dist/form/components/FormRail.js.map +1 -1
  307. package/dist/form/components/LocalChangesMenu.d.ts +1 -1
  308. package/dist/form/components/LocalChangesMenu.js.map +1 -1
  309. package/dist/form/components/StorageItemPreview.d.ts +1 -1
  310. package/dist/form/components/StorageItemPreview.js.map +1 -1
  311. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
  312. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js +1 -1
  313. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js.map +1 -1
  314. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +2 -2
  315. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
  316. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
  317. package/dist/form/field_bindings/BinaryFieldBinding.d.ts +1 -1
  318. package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -1
  319. package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
  320. package/dist/form/field_bindings/BlockFieldBinding.js +1 -1
  321. package/dist/form/field_bindings/BlockFieldBinding.js.map +1 -1
  322. package/dist/form/field_bindings/DateTimeFieldBinding.d.ts +1 -1
  323. package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -1
  324. package/dist/form/field_bindings/GeopointFieldBinding.d.ts +1 -1
  325. package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -1
  326. package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
  327. package/dist/form/field_bindings/KeyValueFieldBinding.js +1 -2
  328. package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -1
  329. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  330. package/dist/form/field_bindings/MapFieldBinding.js.map +1 -1
  331. package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +1 -1
  332. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +1 -1
  333. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -1
  334. package/dist/form/field_bindings/MultiSelectFieldBinding.d.ts +1 -1
  335. package/dist/form/field_bindings/MultiSelectFieldBinding.js +1 -1
  336. package/dist/form/field_bindings/MultiSelectFieldBinding.js.map +1 -1
  337. package/dist/form/field_bindings/MultipleRelationFieldBinding.d.ts +1 -1
  338. package/dist/form/field_bindings/MultipleRelationFieldBinding.js +2 -2
  339. package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
  340. package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
  341. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
  342. package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +1 -1
  343. package/dist/form/field_bindings/ReferenceFieldBinding.js +2 -2
  344. package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -1
  345. package/dist/form/field_bindings/RelationFieldBinding.d.ts +1 -1
  346. package/dist/form/field_bindings/RelationFieldBinding.js +2 -2
  347. package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
  348. package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
  349. package/dist/form/field_bindings/RepeatFieldBinding.js +1 -1
  350. package/dist/form/field_bindings/RepeatFieldBinding.js.map +1 -1
  351. package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
  352. package/dist/form/field_bindings/SelectFieldBinding.js +1 -1
  353. package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -1
  354. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +2 -2
  355. package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
  356. package/dist/form/field_bindings/SwitchFieldBinding.d.ts +1 -1
  357. package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -1
  358. package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
  359. package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
  360. package/dist/form/field_bindings/UserSelectFieldBinding.d.ts +1 -1
  361. package/dist/form/field_bindings/UserSelectFieldBinding.js.map +1 -1
  362. package/dist/form/field_bindings/VectorFieldBinding.d.ts +1 -1
  363. package/dist/form/field_bindings/VectorFieldBinding.js.map +1 -1
  364. package/dist/form/form_utils.d.ts +3 -3
  365. package/dist/form/form_utils.js +1 -2
  366. package/dist/form/form_utils.js.map +1 -1
  367. package/dist/form/label_placement.d.ts +1 -2
  368. package/dist/form/label_placement.js.map +1 -1
  369. package/dist/form/resolve_cell_property.d.ts +1 -2
  370. package/dist/form/resolve_cell_property.js +1 -1
  371. package/dist/form/resolve_cell_property.js.map +1 -1
  372. package/dist/form/resolve_form_properties.d.ts +2 -2
  373. package/dist/form/resolve_form_properties.js +1 -1
  374. package/dist/form/resolve_form_properties.js.map +1 -1
  375. package/dist/form/useClearRestoreValue.d.ts +1 -1
  376. package/dist/form/useClearRestoreValue.js.map +1 -1
  377. package/dist/form/validation.d.ts +2 -2
  378. package/dist/form/validation.js +1 -1
  379. package/dist/form/validation.js.map +1 -1
  380. package/dist/hooks/navigation/compose_collections.d.ts +59 -0
  381. package/dist/hooks/navigation/compose_collections.js +48 -0
  382. package/dist/hooks/navigation/compose_collections.js.map +1 -0
  383. package/dist/hooks/navigation/compose_collections_input.d.ts +8 -0
  384. package/dist/hooks/navigation/compose_collections_input.js +17 -0
  385. package/dist/hooks/navigation/compose_collections_input.js.map +1 -0
  386. package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +1 -1
  387. package/dist/hooks/navigation/contexts/CollectionRegistryContext.js.map +1 -1
  388. package/dist/hooks/navigation/registered_collection.d.ts +15 -0
  389. package/dist/hooks/navigation/registered_collection.js +20 -0
  390. package/dist/hooks/navigation/registered_collection.js.map +1 -0
  391. package/dist/hooks/navigation/ui_preferences.d.ts +47 -0
  392. package/dist/hooks/navigation/ui_preferences.js +179 -0
  393. package/dist/hooks/navigation/ui_preferences.js.map +1 -0
  394. package/dist/hooks/navigation/useAsyncResolver.d.ts +8 -1
  395. package/dist/hooks/navigation/useAsyncResolver.js +9 -3
  396. package/dist/hooks/navigation/useAsyncResolver.js.map +1 -1
  397. package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +1 -3
  398. package/dist/hooks/navigation/useBuildCollectionRegistryController.js +3 -3
  399. package/dist/hooks/navigation/useBuildCollectionRegistryController.js.map +1 -1
  400. package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +9 -5
  401. package/dist/hooks/navigation/useBuildNavigationStateController.js +2 -1
  402. package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
  403. package/dist/hooks/navigation/useBuildUrlController.d.ts +1 -1
  404. package/dist/hooks/navigation/useBuildUrlController.js.map +1 -1
  405. package/dist/hooks/navigation/useNavigationResolution.js +1 -2
  406. package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
  407. package/dist/hooks/navigation/usePanelTables.d.ts +11 -0
  408. package/dist/hooks/navigation/usePanelTables.js +33 -0
  409. package/dist/hooks/navigation/usePanelTables.js.map +1 -0
  410. package/dist/hooks/navigation/useResolvedCollections.d.ts +8 -3
  411. package/dist/hooks/navigation/useResolvedCollections.js +3 -2
  412. package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
  413. package/dist/hooks/navigation/useResolvedViews.d.ts +1 -2
  414. package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
  415. package/dist/hooks/navigation/useTopLevelNavigation.d.ts +1 -2
  416. package/dist/hooks/navigation/useTopLevelNavigation.js.map +1 -1
  417. package/dist/hooks/navigation/user_preferences_overlay.d.ts +21 -0
  418. package/dist/hooks/navigation/user_preferences_overlay.js +101 -0
  419. package/dist/hooks/navigation/user_preferences_overlay.js.map +1 -0
  420. package/dist/hooks/navigation/utils.js +1 -1
  421. package/dist/hooks/navigation/utils.js.map +1 -1
  422. package/dist/hooks/useAdminContext.d.ts +1 -2
  423. package/dist/hooks/useAdminContext.js.map +1 -1
  424. package/dist/hooks/useBuildSidePanel.d.ts +1 -2
  425. package/dist/hooks/useBuildSidePanel.js +2 -1
  426. package/dist/hooks/useBuildSidePanel.js.map +1 -1
  427. package/dist/hooks/useChildViewSource.d.ts +1 -1
  428. package/dist/hooks/useChildViewSource.js +1 -1
  429. package/dist/hooks/useChildViewSource.js.map +1 -1
  430. package/dist/hooks/useEntityDisplay.d.ts +1 -2
  431. package/dist/hooks/useEntityDisplay.js +1 -1
  432. package/dist/hooks/useEntityDisplay.js.map +1 -1
  433. package/dist/hooks/useEntityDisplayTitle.d.ts +2 -2
  434. package/dist/hooks/useEntityDisplayTitle.js.map +1 -1
  435. package/dist/hooks/useHistory.js +1 -1
  436. package/dist/hooks/useHistory.js.map +1 -1
  437. package/dist/hooks/useRecordActions.d.ts +1 -2
  438. package/dist/hooks/useRecordActions.js.map +1 -1
  439. package/dist/hooks/useReferencePaths.d.ts +21 -7
  440. package/dist/hooks/useReferencePaths.js +23 -6
  441. package/dist/hooks/useReferencePaths.js.map +1 -1
  442. package/dist/hooks/useResolvedNavigationFrom.d.ts +3 -3
  443. package/dist/hooks/useResolvedNavigationFrom.js +1 -1
  444. package/dist/hooks/useResolvedNavigationFrom.js.map +1 -1
  445. package/dist/index.d.ts +11 -0
  446. package/dist/index.js +8 -2
  447. package/dist/mcp_view/app_modules.d.ts +2 -2
  448. package/dist/mcp_view/app_modules.js +4 -4
  449. package/dist/mcp_view/app_modules.js.map +1 -1
  450. package/dist/mcp_view/index.d.ts +16 -19
  451. package/dist/mcp_view/index.js +43 -62
  452. package/dist/mcp_view/index.js.map +1 -1
  453. package/dist/mcp_view/payload.d.ts +54 -18
  454. package/dist/mcp_view/payload.js +49 -24
  455. package/dist/mcp_view/payload.js.map +1 -1
  456. package/dist/mcp_view/screen.js +11 -11
  457. package/dist/mcp_view/screen.js.map +1 -1
  458. package/dist/mcp_view/tool_driver.d.ts +5 -34
  459. package/dist/mcp_view/tool_driver.js +17 -16
  460. package/dist/mcp_view/tool_driver.js.map +1 -1
  461. package/dist/mcp_view/write_review.d.ts +1 -2
  462. package/dist/mcp_view/write_review.js +1 -1
  463. package/dist/mcp_view/write_review.js.map +1 -1
  464. package/dist/preview/PropertyPreview.d.ts +1 -1
  465. package/dist/preview/PropertyPreview.js +4 -3
  466. package/dist/preview/PropertyPreview.js.map +1 -1
  467. package/dist/preview/components/ArrayEnumPreview.d.ts +1 -1
  468. package/dist/preview/components/ArrayEnumPreview.js.map +1 -1
  469. package/dist/preview/components/BooleanPreview.d.ts +1 -1
  470. package/dist/preview/components/BooleanPreview.js.map +1 -1
  471. package/dist/preview/components/EnumValuesChip.d.ts +1 -1
  472. package/dist/preview/components/EnumValuesChip.js +1 -1
  473. package/dist/preview/components/EnumValuesChip.js.map +1 -1
  474. package/dist/preview/components/ReferencePreview.d.ts +1 -1
  475. package/dist/preview/components/ReferencePreview.js.map +1 -1
  476. package/dist/preview/components/RelationPreview.d.ts +1 -1
  477. package/dist/preview/components/RelationPreview.js.map +1 -1
  478. package/dist/preview/components/StorageThumbnail.js +2 -1
  479. package/dist/preview/components/StorageThumbnail.js.map +1 -1
  480. package/dist/preview/components/UserPreview.d.ts +1 -1
  481. package/dist/preview/components/UserPreview.js.map +1 -1
  482. package/dist/preview/property_previews/ArrayOfMapsPreview.d.ts +1 -1
  483. package/dist/preview/property_previews/ArrayOfMapsPreview.js.map +1 -1
  484. package/dist/preview/property_previews/ArrayOfReferencesPreview.d.ts +1 -1
  485. package/dist/preview/property_previews/ArrayOfReferencesPreview.js.map +1 -1
  486. package/dist/preview/property_previews/ArrayOfRelationsPreview.d.ts +1 -1
  487. package/dist/preview/property_previews/ArrayOfRelationsPreview.js +2 -1
  488. package/dist/preview/property_previews/ArrayOfRelationsPreview.js.map +1 -1
  489. package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.d.ts +1 -1
  490. package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js.map +1 -1
  491. package/dist/preview/property_previews/ArrayOfStringsPreview.d.ts +1 -1
  492. package/dist/preview/property_previews/ArrayOfStringsPreview.js.map +1 -1
  493. package/dist/preview/property_previews/ArrayOneOfPreview.d.ts +1 -1
  494. package/dist/preview/property_previews/ArrayOneOfPreview.js +1 -1
  495. package/dist/preview/property_previews/ArrayOneOfPreview.js.map +1 -1
  496. package/dist/preview/property_previews/ArrayPropertyEnumPreview.d.ts +1 -1
  497. package/dist/preview/property_previews/ArrayPropertyEnumPreview.js +1 -1
  498. package/dist/preview/property_previews/ArrayPropertyEnumPreview.js.map +1 -1
  499. package/dist/preview/property_previews/ArrayPropertyPreview.d.ts +1 -1
  500. package/dist/preview/property_previews/ArrayPropertyPreview.js +1 -1
  501. package/dist/preview/property_previews/ArrayPropertyPreview.js.map +1 -1
  502. package/dist/preview/property_previews/MapPropertyPreview.d.ts +1 -1
  503. package/dist/preview/property_previews/MapPropertyPreview.js.map +1 -1
  504. package/dist/preview/property_previews/NumberPropertyPreview.d.ts +1 -1
  505. package/dist/preview/property_previews/NumberPropertyPreview.js +1 -1
  506. package/dist/preview/property_previews/NumberPropertyPreview.js.map +1 -1
  507. package/dist/preview/property_previews/SkeletonPropertyComponent.d.ts +1 -1
  508. package/dist/preview/property_previews/SkeletonPropertyComponent.js.map +1 -1
  509. package/dist/preview/property_previews/StringPropertyPreview.d.ts +1 -1
  510. package/dist/preview/property_previews/StringPropertyPreview.js.map +1 -1
  511. package/dist/preview/util.d.ts +1 -1
  512. package/dist/preview/util.js.map +1 -1
  513. package/dist/routes/RebaseRoute.js +2 -2
  514. package/dist/routes/RebaseRoute.js.map +1 -1
  515. package/dist/saved_apps/SavedAppsView.d.ts +1 -1
  516. package/dist/saved_apps/SavedAppsView.js +1 -1
  517. package/dist/saved_apps/SavedAppsView.js.map +1 -1
  518. package/dist/selection/SelectionMenu.d.ts +1 -1
  519. package/dist/selection/SelectionMenu.js.map +1 -1
  520. package/dist/selection/resolve_selection.d.ts +3 -3
  521. package/dist/selection/resolve_selection.js +3 -2
  522. package/dist/selection/resolve_selection.js.map +1 -1
  523. package/dist/tables/apply_customization.d.ts +65 -0
  524. package/dist/tables/apply_customization.js +644 -0
  525. package/dist/tables/apply_customization.js.map +1 -0
  526. package/dist/tables/column_property.d.ts +64 -0
  527. package/dist/tables/column_property.js +549 -0
  528. package/dist/tables/column_property.js.map +1 -0
  529. package/dist/tables/customize_table.d.ts +39 -0
  530. package/dist/tables/customize_table.js +247 -0
  531. package/dist/tables/customize_table.js.map +1 -0
  532. package/dist/tables/index.d.ts +12 -0
  533. package/dist/tables/labels.d.ts +18 -0
  534. package/dist/tables/labels.js +18 -0
  535. package/dist/tables/labels.js.map +1 -0
  536. package/dist/tables/project_table.d.ts +79 -0
  537. package/dist/tables/project_table.js +148 -0
  538. package/dist/tables/project_table.js.map +1 -0
  539. package/dist/tables/relations.d.ts +47 -0
  540. package/dist/tables/relations.js +112 -0
  541. package/dist/tables/relations.js.map +1 -0
  542. package/dist/tables/rls.d.ts +39 -0
  543. package/dist/tables/rls.js +111 -0
  544. package/dist/tables/rls.js.map +1 -0
  545. package/dist/tables/update_record.d.ts +32 -0
  546. package/dist/tables/update_record.js +40 -0
  547. package/dist/tables/update_record.js.map +1 -0
  548. package/dist/types/components/EntityFormActionsProps.d.ts +1 -1
  549. package/dist/types/components/PropertyPreviewProps.d.ts +2 -2
  550. package/dist/types/fields.d.ts +2 -2
  551. package/dist/util/dataControllerAdapter.js.map +1 -1
  552. package/dist/util/entity_pages.d.ts +2 -1
  553. package/dist/util/entity_pages.js.map +1 -1
  554. package/dist/util/find_entities_by_ids.d.ts +2 -2
  555. package/dist/util/find_entities_by_ids.js +1 -1
  556. package/dist/util/find_entities_by_ids.js.map +1 -1
  557. package/dist/util/format_collection_date.d.ts +1 -1
  558. package/dist/util/format_collection_date.js.map +1 -1
  559. package/dist/util/identity.d.ts +8 -0
  560. package/dist/util/identity.js +16 -0
  561. package/dist/util/identity.js.map +1 -0
  562. package/dist/util/navigation_utils.js +1 -1
  563. package/dist/util/navigation_utils.js.map +1 -1
  564. package/dist/util/previews.js +1 -1
  565. package/dist/util/previews.js.map +1 -1
  566. package/dist/util/propertyConfigMapper.d.ts +1 -1
  567. package/dist/util/propertyConfigMapper.js.map +1 -1
  568. package/dist/util/property_utils.d.ts +1 -3
  569. package/dist/util/property_utils.js +1 -1
  570. package/dist/util/property_utils.js.map +1 -1
  571. package/dist/util/relations.d.ts +18 -0
  572. package/dist/util/relations.js +32 -0
  573. package/dist/util/relations.js.map +1 -0
  574. package/package.json +12 -10
  575. package/recipes/README.md +4 -4
  576. package/recipes/my-preferences.tsx +34 -26
  577. package/recipes/site-settings.tsx +34 -27
  578. package/dist/collection_editor/collection_wire.d.ts +0 -13
  579. package/dist/collection_editor/collection_wire.js +0 -49
  580. package/dist/collection_editor/collection_wire.js.map +0 -1
  581. package/dist/collection_editor/useJsonCollectionsConfigController.d.ts +0 -37
  582. package/dist/collection_editor/useJsonCollectionsConfigController.js +0 -191
  583. package/dist/collection_editor/useJsonCollectionsConfigController.js.map +0 -1
@@ -1,11 +1,13 @@
1
1
  import { useCollectionsConfigController } from "../../useCollectionsConfigController.js";
2
+ import { describeCondition, isEditableInForm, rlsRuleForm } from "./rlsRuleForm.js";
2
3
  import { useEffect, useMemo, useState } from "react";
3
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
5
  import { Button, Chip, CircularProgress, Container, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, KeyIcon, MultiSelect, MultiSelectItem, Paper, Select, SelectItem, TextField, Tooltip, Trash2Icon, Typography, cls, defaultBorderMixin, iconSize } from "@rebasepro/ui";
5
- import { getGeneratedPolicyNames, getTableName, policyToSecurityRule } from "@rebasepro/common";
6
+ import { getGeneratedPolicyNamesOnce, getTableName, isPostgresCollectionConfig } from "@rebasepro/cms-types";
6
7
  import { useRebaseContext, useTranslation } from "@rebasepro/app";
7
8
  import { useFormex } from "@rebasepro/forms";
8
- import { RLS_ROLES_SQL, RLS_UID_SQL, isPostgresCollectionConfig } from "@rebasepro/types";
9
+ import { RLS_ROLES_SQL, RLS_UID_SQL } from "@rebasepro/types";
10
+ import { policyToSecurityRule } from "@rebasepro/common";
9
11
  import { getPolicyNamesForRule } from "@rebasepro/utils";
10
12
  //#region src/collection_editor/ui/collection_editor/CollectionRLSTab.tsx
11
13
  /**
@@ -193,8 +195,9 @@ function CollectionRLSTab() {
193
195
  }, [databaseAdmin]);
194
196
  const generatedPolicyNames = useMemo(() => {
195
197
  if (!tableName) return /* @__PURE__ */ new Set();
196
- return getGeneratedPolicyNames(values);
198
+ return getGeneratedPolicyNamesOnce(values);
197
199
  }, [tableName, values]);
200
+ const ruleCollection = values;
198
201
  const unmappedPolicies = dbPolicies.filter((dp) => !generatedPolicyNames.has(dp.policyname));
199
202
  const handleSave = (newPolicy) => {
200
203
  if (!editing) return;
@@ -234,65 +237,101 @@ function CollectionRLSTab() {
234
237
  })
235
238
  }) : /* @__PURE__ */ jsx("div", {
236
239
  className: "flex flex-col gap-3",
237
- children: rules.map((rule, index) => /* @__PURE__ */ jsxs(Paper, {
238
- className: "p-4 border border-transparent hover:border-surface-200 dark:hover:border-surface-700 rounded-lg flex flex-col sm:flex-row sm:items-center justify-between gap-4 transition-colors bg-surface-card shadow-sm",
239
- children: [/* @__PURE__ */ jsxs("div", {
240
- className: "flex flex-col gap-1.5 min-w-0",
240
+ children: rules.map((rule, index) => {
241
+ const form = rlsRuleForm(rule);
242
+ const editable = isEditableInForm(form);
243
+ const lockedTitle = form === "redacted" ? t("studio_rls_rule_defined_on_server") : t("studio_rls_rule_edit_in_code");
244
+ return /* @__PURE__ */ jsxs(Paper, {
245
+ className: "p-4 border border-transparent hover:border-surface-200 dark:hover:border-surface-700 rounded-lg flex flex-col sm:flex-row sm:items-center justify-between gap-4 transition-colors bg-surface-card shadow-sm",
241
246
  children: [/* @__PURE__ */ jsxs("div", {
242
- className: "flex items-center gap-2",
243
- children: [/* @__PURE__ */ jsx(KeyIcon, {
244
- size: iconSize.smallest,
245
- className: "text-text-disabled dark:text-text-disabled-dark shrink-0"
246
- }), /* @__PURE__ */ jsx(Typography, {
247
- variant: "subtitle2",
248
- className: "truncate",
249
- children: rule.name || (tableName ? getPolicyNamesForRule(rule, tableName).join(", ") : "Unnamed policy")
247
+ className: "flex flex-col gap-1.5 min-w-0",
248
+ children: [/* @__PURE__ */ jsxs("div", {
249
+ className: "flex items-center gap-2",
250
+ children: [/* @__PURE__ */ jsx(KeyIcon, {
251
+ size: iconSize.smallest,
252
+ className: "text-text-disabled dark:text-text-disabled-dark shrink-0"
253
+ }), /* @__PURE__ */ jsx(Typography, {
254
+ variant: "subtitle2",
255
+ className: "truncate",
256
+ children: rule.name || (tableName ? getPolicyNamesForRule(rule, tableName).join(", ") : "Unnamed policy")
257
+ })]
258
+ }), /* @__PURE__ */ jsxs("div", {
259
+ className: "flex gap-2 text-xs pl-6 overflow-x-auto hide-scrollbar",
260
+ children: [
261
+ /* @__PURE__ */ jsxs(Chip, {
262
+ size: "small",
263
+ className: "bg-surface-raised text-text-secondary border-none",
264
+ children: ["Action: ", rule.operation || "ALL"]
265
+ }),
266
+ /* @__PURE__ */ jsxs(Chip, {
267
+ size: "small",
268
+ className: "bg-surface-raised text-text-secondary border-none",
269
+ children: ["Roles: ", Array.isArray(rule.roles) ? rule.roles.join(", ") : rule.roles]
270
+ }),
271
+ rule.access && /* @__PURE__ */ jsx(Chip, {
272
+ size: "small",
273
+ className: "bg-surface-raised text-text-secondary border-none",
274
+ children: rule.access === "authenticated" ? t("studio_rls_rule_who_authenticated") : rule.access === "registered" ? t("studio_rls_rule_who_registered") : t("studio_rls_rule_who_public")
275
+ }),
276
+ form !== "redacted" && rule.condition != null && /* @__PURE__ */ jsx(Chip, {
277
+ size: "small",
278
+ className: "bg-surface-raised text-text-secondary border-none font-mono",
279
+ children: t("studio_rls_rule_rows", { condition: describeCondition(rule.condition, ruleCollection) })
280
+ }),
281
+ form !== "redacted" && rule.check != null && /* @__PURE__ */ jsx(Chip, {
282
+ size: "small",
283
+ className: "bg-surface-raised text-text-secondary border-none font-mono",
284
+ children: t("studio_rls_rule_writes", { condition: describeCondition(rule.check, ruleCollection) })
285
+ }),
286
+ form === "redacted" && /* @__PURE__ */ jsx(Chip, {
287
+ size: "small",
288
+ className: "bg-surface-raised text-text-secondary border-none",
289
+ children: t("studio_rls_rule_redacted")
290
+ })
291
+ ]
250
292
  })]
251
293
  }), /* @__PURE__ */ jsxs("div", {
252
- className: "flex gap-2 text-xs pl-6 overflow-x-auto hide-scrollbar",
253
- children: [/* @__PURE__ */ jsxs(Chip, {
294
+ className: "flex items-center gap-1 sm:gap-2 shrink-0",
295
+ children: [editable ? /* @__PURE__ */ jsx(Button, {
254
296
  size: "small",
255
- className: "bg-surface-raised text-text-secondary border-none",
256
- children: ["Action: ", rule.operation || "ALL"]
257
- }), /* @__PURE__ */ jsxs(Chip, {
297
+ variant: "text",
298
+ disabled: readOnly,
299
+ onClick: () => setEditing({
300
+ index,
301
+ policy: {
302
+ policyname: rule.name ?? "",
303
+ tablename: tableName || "your_table",
304
+ permissive: (rule.mode || "permissive").toUpperCase(),
305
+ cmd: (rule.operation || "ALL").toUpperCase(),
306
+ roles: [...rule.roles ?? []],
307
+ qual: rule.using || null,
308
+ with_check: rule.withCheck || null
309
+ }
310
+ }),
311
+ children: "EDIT"
312
+ }) : /* @__PURE__ */ jsx(Tooltip, {
313
+ title: lockedTitle,
314
+ children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, {
315
+ size: "small",
316
+ variant: "text",
317
+ disabled: true,
318
+ children: "EDIT"
319
+ }) })
320
+ }), /* @__PURE__ */ jsx(IconButton, {
321
+ "aria-label": t("delete"),
258
322
  size: "small",
259
- className: "bg-surface-raised text-text-secondary border-none",
260
- children: ["Roles: ", Array.isArray(rule.roles) ? rule.roles.join(", ") : rule.roles]
323
+ disabled: readOnly,
324
+ onClick: () => {
325
+ setFieldValue("securityRules", rules.filter((_r, i) => i !== index));
326
+ },
327
+ children: /* @__PURE__ */ jsx(Trash2Icon, {
328
+ size: iconSize.smallest,
329
+ className: "text-text-secondary dark:text-text-secondary-dark hover:text-red-500 dark:hover:text-red-500 transition-colors"
330
+ })
261
331
  })]
262
332
  })]
263
- }), /* @__PURE__ */ jsxs("div", {
264
- className: "flex items-center gap-1 sm:gap-2 shrink-0",
265
- children: [/* @__PURE__ */ jsx(Button, {
266
- size: "small",
267
- variant: "text",
268
- disabled: readOnly,
269
- onClick: () => setEditing({
270
- index,
271
- policy: {
272
- policyname: rule.name ?? "",
273
- tablename: tableName || "your_table",
274
- permissive: (rule.mode || "permissive").toUpperCase(),
275
- cmd: (rule.operation || "ALL").toUpperCase(),
276
- roles: [...rule.roles ?? []],
277
- qual: rule.using || null,
278
- with_check: rule.withCheck || null
279
- }
280
- }),
281
- children: "EDIT"
282
- }), /* @__PURE__ */ jsx(IconButton, {
283
- "aria-label": t("delete"),
284
- size: "small",
285
- disabled: readOnly,
286
- onClick: () => {
287
- setFieldValue("securityRules", rules.filter((_r, i) => i !== index));
288
- },
289
- children: /* @__PURE__ */ jsx(Trash2Icon, {
290
- size: iconSize.smallest,
291
- className: "text-text-secondary dark:text-text-secondary-dark hover:text-red-500 dark:hover:text-red-500 transition-colors"
292
- })
293
- })]
294
- })]
295
- }, `${index}:${rule.name ?? ""}`))
333
+ }, `${index}:${rule.name ?? ""}`);
334
+ })
296
335
  }),
297
336
  isLoadingDb && unmappedPolicies.length === 0 && /* @__PURE__ */ jsx("div", {
298
337
  className: "flex justify-center mt-8",
@@ -1 +1 @@
1
- {"version":3,"file":"CollectionRLSTab.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/CollectionRLSTab.tsx"],"sourcesContent":["\nimport { getPolicyNamesForRule, getPolicyNamesForRules } from \"@rebasepro/utils\";\nimport { getGeneratedPolicyNames, getTableName, policyToSecurityRule } from \"@rebasepro/common\";\nimport React, { useState, useEffect, useMemo } from \"react\";\n\n/**\n * Validates and double-quotes a SQL identifier to prevent injection.\n * Only allows safe Postgres identifiers (letters, digits, underscores).\n * Throws if the identifier contains unsafe characters.\n */\nfunction sanitizeSqlIdentifier(name: string): string {\n if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) {\n throw new Error(`Invalid SQL identifier: \"${name}\". Only letters, digits, and underscores are allowed.`);\n }\n return `\"${name}\"`;\n}\nimport {\n Button,\n Chip,\n CircularProgress,\n cls,\n Container,\n defaultBorderMixin,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n IconButton,\n iconSize,\n KeyIcon,\n MultiSelect,\n MultiSelectItem,\n Paper,\n Select,\n SelectItem,\n TextField,\n Tooltip,\n Trash2Icon,\n Typography\n} from \"@rebasepro/ui\";\nimport { useFormex } from \"@rebasepro/forms\";\nimport { useCollectionsConfigController } from \"../../useCollectionsConfigController\";\nimport { useRebaseContext, useTranslation } from \"@rebasepro/app\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport {\n isPostgresCollectionConfig,\n RLS_ROLES_SQL,\n RLS_UID_SQL,\n type PolicyExpression,\n type PostgresPolicy,\n type SecurityOperation,\n type SecurityRule,\n type SecurityRuleBase\n} from \"@rebasepro/types\";\n\nexport type { PostgresPolicy } from \"@rebasepro/types\";\n\ntype CollectionWithSecurity = AdminCollection & {\n securityRules?: SecurityRule[];\n};\n\n/**\n * The security-rule fields a {@link PostgresPolicy} describes, and the ones an\n * edit carries over from the rule it changes.\n *\n * Wider than any one `SecurityRule` variant on purpose — the same shape as\n * Studio's `PolicyRule`: an edit starts from the rule as written and deletes\n * and assigns the fields that changed one at a time, and the variants are\n * exclusive about which fields go together.\n */\ntype PolicyRule = SecurityRuleBase & {\n using?: string;\n withCheck?: string;\n ownerField?: string;\n access?: \"public\";\n condition?: PolicyExpression;\n check?: PolicyExpression;\n};\n\n/**\n * `pg_policies` reports the operation and the permissive flag in upper case;\n * `SecurityRule` names them in lower case. These two used to be `.toLowerCase()`\n * assigned straight into a `SecurityRule`, which typechecks only against a\n * `string` field — and this file declared its own local `SecurityRule` with\n * `operation?: string`, so it did. Against the real type it does not: an\n * unrecognised `cmd` would have been written into the collection as a policy\n * operation that compiles to nothing.\n */\nfunction toSecurityOperation(cmd: PostgresPolicy[\"cmd\"] | undefined): SecurityOperation | undefined {\n switch (cmd) {\n case \"SELECT\": return \"select\";\n case \"INSERT\": return \"insert\";\n case \"UPDATE\": return \"update\";\n case \"DELETE\": return \"delete\";\n case \"ALL\": return \"all\";\n default: return undefined;\n }\n}\n\nfunction toSecurityMode(permissive: PostgresPolicy[\"permissive\"] | undefined): SecurityRule[\"mode\"] {\n // Absent stays absent. `permissive` is the default, so writing it out\n // changes nothing semantically — but this value is serialized into the\n // user's collection file, and defaulting here would grow a `mode:\n // \"permissive\"` on every rule the editor touches. The `.toLowerCase()`\n // this replaced returned `undefined` for an absent value; that part was\n // right, and only the widened type was wrong.\n if (!permissive) return undefined;\n return permissive === \"RESTRICTIVE\" ? \"restrictive\" : \"permissive\";\n}\n\n/**\n * Build a rule from what the inline editor saved. Its `roles` are application\n * roles; a live policy's are its `TO` list, which `policyToSecurityRule` reads.\n *\n * The WITH CHECK is kept whether or not there is a USING: every INSERT-only\n * policy has only a check, and a roles-only rule with no roles compiles to\n * `WITH CHECK (false)`, which stops every insert.\n */\nfunction toSecurityRule(policy: Partial<PostgresPolicy>): PolicyRule {\n return {\n name: policy.policyname ?? \"\",\n operation: toSecurityOperation(policy.cmd),\n mode: toSecurityMode(policy.permissive),\n roles: policy.roles ? [...policy.roles] : undefined,\n ...(policy.qual ? { using: policy.qual } : {}),\n ...(policy.with_check ? { withCheck: policy.with_check } : {})\n };\n}\n\n/**\n * The rule with what the editor changed, and nothing else.\n *\n * The editor shows a rule as a policy — name, command, mode, application roles\n * and raw USING / WITH CHECK — and has no field for `ownerField`, `access`, a\n * structured `condition`, `operations` (it shows them as ALL) or `pgRoles`.\n * The rule used to be rebuilt from the form, which dropped all of them:\n * renaming an owner rule saved a roles-only rule with no roles, which compiles\n * to `USING (false)`. So a field is only written when it differs from what the\n * editor was opened with. A condition typed in replaces the rule's condition\n * whole — the forms are exclusive.\n *\n * Studio's RLS editor does the same in `policyRules.ts`; there the editor's\n * roles are the policy's `TO` list, `pgRoles`, and here they are `roles`.\n */\nfunction editedRule(rule: SecurityRule, original: PostgresPolicy, edited: Partial<PostgresPolicy>): PolicyRule {\n const next = toSecurityRule(edited);\n const result: PolicyRule = { ...rule };\n\n if ((edited.policyname ?? \"\") !== original.policyname) {\n if (next.name) result.name = next.name;\n else delete result.name;\n }\n if (edited.cmd !== original.cmd) {\n // `operations` wins over `operation`, so it has to go for the new\n // command to mean anything.\n delete result.operations;\n result.operation = next.operation;\n }\n if (edited.permissive !== original.permissive) {\n result.mode = next.mode;\n }\n if (!sameRoles(edited.roles, original.roles)) {\n if (next.roles && next.roles.length > 0) result.roles = next.roles;\n else delete result.roles;\n }\n if ((edited.qual || null) !== (original.qual || null) || (edited.with_check || null) !== (original.with_check || null)) {\n delete result.ownerField;\n delete result.access;\n delete result.condition;\n delete result.check;\n delete result.using;\n delete result.withCheck;\n if (next.using) result.using = next.using;\n if (next.withCheck) result.withCheck = next.withCheck;\n }\n return result;\n}\n\nfunction sameRoles(a: readonly string[] | undefined, b: readonly string[] | undefined): boolean {\n const left = [...(a ?? [])].sort();\n const right = [...(b ?? [])].sort();\n return left.length === right.length && left.every((role, i) => role === right[i]);\n}\n\nexport function CollectionRLSTab() {\n const { t } = useTranslation();\n const { values, setFieldValue } = useFormex<CollectionWithSecurity>();\n // The rule being edited is held by its position: an unnamed rule has no\n // name to find it by, and matching `rule.name` against the editor's empty\n // name found nothing, so the save wrote the rules back unchanged.\n const [editing, setEditing] = useState<{ index: number; policy: PostgresPolicy } | \"new\" | null>(null);\n\n // Every other tab in this dialog disables its inputs when the backend will\n // not accept an edit — the general and display forms behind a `fieldset\n // disabled`, the properties editor per control. This one did not, so a\n // read-only panel still invited you to write a policy, delete one, and\n // reorder the lot, and only said no at the submit button on the way out.\n const { readOnly, readOnlyReason } = useCollectionsConfigController();\n const readOnlyTitle = readOnlyReason || \"This backend does not accept collection edits.\";\n\n const rules: SecurityRule[] = values.securityRules || [];\n\n const { databaseAdmin } = useRebaseContext();\n const [dbPolicies, setDbPolicies] = useState<PostgresPolicy[]>([]);\n const [isLoadingDb, setIsLoadingDb] = useState(false);\n\n // The table `db push` writes this collection's policies on, resolved the\n // way the planner resolves it: `getTableName`, in the collection's schema\n // or `public`. This read `id || table || alias` — none of which a\n // collection that leaves `table` to its slug has, so it loaded no live\n // policies at all — and matched the name in every schema, offering another\n // schema's same-named table's policies for import into this collection.\n const tableName = getTableName(values);\n const schemaName = isPostgresCollectionConfig(values) && values.schema ? values.schema : \"public\";\n\n useEffect(() => {\n const fetchLivePolicies = async () => {\n if (!tableName || !databaseAdmin?.executeSql) return;\n\n setIsLoadingDb(true);\n try {\n // Both validated to be [a-zA-Z_][a-zA-Z0-9_]* — safe inside a\n // string literal once the double quotes are stripped.\n const rawTableName = sanitizeSqlIdentifier(tableName).slice(1, -1);\n const rawSchemaName = sanitizeSqlIdentifier(schemaName).slice(1, -1);\n const sql = `\n SELECT policyname, permissive, roles, cmd, qual, with_check\n FROM pg_policies\n WHERE schemaname = '${rawSchemaName}' AND tablename = '${rawTableName}';\n `;\n const result = await databaseAdmin.executeSql(sql);\n const extractRows = (res: unknown): Record<string, unknown>[] => {\n if (res && typeof res === \"object\" && \"rows\" in res && Array.isArray((res as { rows: Record<string, unknown>[] }).rows)) {\n return (res as { rows: Record<string, unknown>[] }).rows;\n }\n if (Array.isArray(res)) return res as Record<string, unknown>[];\n return [];\n };\n const pRows = extractRows(result);\n const policies: PostgresPolicy[] = pRows.map((p: Record<string, unknown>) => {\n let parsedRoles: string[] = [];\n const r = p.roles || p.ROLES;\n if (Array.isArray(r)) {\n parsedRoles = r as string[];\n } else if (typeof r === \"string\") {\n parsedRoles = r.replace(/^{|}$/g, \"\").split(\",\").map((s: string) => s.trim());\n }\n return {\n policyname: (p.policyname || p.POLICYNAME || \"\") as string,\n tablename: tableName,\n permissive: (p.permissive || p.PERMISSIVE || \"PERMISSIVE\") as \"PERMISSIVE\" | \"RESTRICTIVE\",\n roles: parsedRoles,\n cmd: (p.cmd || p.CMD || \"ALL\") as \"SELECT\" | \"INSERT\" | \"UPDATE\" | \"DELETE\" | \"ALL\",\n qual: (p.qual || p.QUAL || null) as string | null,\n with_check: (p.with_check || p.WITH_CHECK || null) as string | null\n };\n });\n setDbPolicies(policies);\n } catch (e) {\n console.error(\"Failed to fetch DB policies\", e);\n } finally {\n setIsLoadingDb(false);\n }\n };\n fetchLivePolicies();\n }, [databaseAdmin, tableName, schemaName]);\n\n /**\n * Application roles available to `SecurityRule.roles`.\n *\n * Deliberately NOT `fetchAvailableRoles` — that returns native pg_roles\n * (postgres, rebase_user, …), which can never satisfy an application-role\n * condition.\n */\n const [availableRoles, setAvailableRoles] = useState<string[]>([]);\n const [rolesUnavailable, setRolesUnavailable] = useState(false);\n\n useEffect(() => {\n let mounted = true;\n const fetchRoles = async () => {\n if (!databaseAdmin?.fetchApplicationRoles) {\n // Older backend, or a driver with no application-role concept.\n if (mounted) setRolesUnavailable(true);\n return;\n }\n try {\n const fetched = await databaseAdmin.fetchApplicationRoles();\n if (mounted) {\n setAvailableRoles(fetched);\n setRolesUnavailable(false);\n }\n } catch (e) {\n console.error(\"Failed to fetch application roles\", e);\n if (mounted) setRolesUnavailable(true);\n }\n };\n fetchRoles();\n return () => {\n mounted = false;\n };\n }, [databaseAdmin]);\n\n // Every policy name `rebase db push` would write for this collection — see\n // `getGeneratedPolicyNames`. This used to be derived here by hand, and the\n // Studio's RLS editor derived a different subset of it by hand, which is\n // exactly how the two came to disagree about which policies were drift.\n const generatedPolicyNames = useMemo(() => {\n if (!tableName) return new Set<string>();\n return getGeneratedPolicyNames(values as AdminCollection);\n }, [tableName, values]);\n\n const unmappedPolicies = dbPolicies.filter(dp => !generatedPolicyNames.has(dp.policyname));\n\n const handleSave = (newPolicy: Partial<PostgresPolicy>) => {\n if (!editing) return;\n const newRules: PolicyRule[] = editing === \"new\"\n ? [...rules, toSecurityRule(newPolicy)]\n : rules.map((r, i) => (i === editing.index ? editedRule(r, editing.policy, newPolicy) : r));\n setFieldValue(\"securityRules\", newRules);\n setEditing(null);\n };\n\n return (\n <div className={\"overflow-auto my-auto\"}>\n <Container maxWidth={\"4xl\"} className={\"flex flex-col gap-4 p-8 m-auto\"}>\n <div className=\"w-full flex flex-col\">\n <div className=\"flex items-center justify-between mb-8\">\n <Typography variant=\"h5\">Row Level Security</Typography>\n <Tooltip title={readOnly ? readOnlyTitle : undefined}>\n <div>\n <Button variant=\"filled\" color=\"neutral\" disabled={readOnly} onClick={() => setEditing(\"new\")}>\n CREATE POLICY\n </Button>\n </div>\n </Tooltip>\n </div>\n\n {rules.length === 0 ? (\n <div className=\"flex-grow flex items-center justify-center text-text-disabled py-12\">\n <Typography variant=\"body2\">No RLS policies defined for this collection.</Typography>\n </div>\n ) : (\n <div className=\"flex flex-col gap-3\">\n {rules.map((rule: SecurityRule, index: number) => (\n <Paper key={`${index}:${rule.name ?? \"\"}`}\n className={\"p-4 border border-transparent hover:border-surface-200 dark:hover:border-surface-700 rounded-lg flex flex-col sm:flex-row sm:items-center justify-between gap-4 transition-colors bg-surface-card shadow-sm\"}>\n <div className=\"flex flex-col gap-1.5 min-w-0\">\n <div className=\"flex items-center gap-2\">\n <KeyIcon size={iconSize.smallest} className=\"text-text-disabled dark:text-text-disabled-dark shrink-0\"/>\n <Typography variant=\"subtitle2\" className=\"truncate\">\n {/* Unnamed rules are still named in Postgres — show what they compile to\n rather than an empty heading. */}\n {rule.name || (tableName\n ? getPolicyNamesForRule(rule, tableName).join(\", \")\n : \"Unnamed policy\")}\n </Typography>\n </div>\n <div className=\"flex gap-2 text-xs pl-6 overflow-x-auto hide-scrollbar\">\n <Chip size=\"small\" className=\"bg-surface-raised text-text-secondary border-none\">Action: {rule.operation || \"ALL\"}</Chip>\n <Chip size=\"small\" className=\"bg-surface-raised text-text-secondary border-none\">Roles: {Array.isArray(rule.roles) ? rule.roles.join(\", \") : rule.roles}</Chip>\n </div>\n </div>\n <div className=\"flex items-center gap-1 sm:gap-2 shrink-0\">\n <Button size=\"small\" variant=\"text\" disabled={readOnly} onClick={() => setEditing({\n index,\n policy: {\n policyname: rule.name ?? \"\",\n tablename: tableName || \"your_table\",\n permissive: (rule.mode || \"permissive\").toUpperCase() as PostgresPolicy[\"permissive\"],\n cmd: (rule.operation || \"ALL\").toUpperCase() as PostgresPolicy[\"cmd\"],\n roles: [...(rule.roles ?? [])],\n qual: rule.using || null,\n with_check: rule.withCheck || null\n }\n })}>\n EDIT\n </Button>\n <IconButton aria-label={t(\"delete\")} size=\"small\" disabled={readOnly} onClick={() => {\n // By position, for the reason editing is: filtered\n // by `name`, every unnamed rule went with this one.\n setFieldValue(\"securityRules\", rules.filter((_r: SecurityRule, i: number) => i !== index));\n }}>\n <Trash2Icon size={iconSize.smallest} className=\"text-text-secondary dark:text-text-secondary-dark hover:text-red-500 dark:hover:text-red-500 transition-colors\"/>\n </IconButton>\n </div>\n </Paper>\n ))}\n </div>\n )}\n\n {isLoadingDb && unmappedPolicies.length === 0 && (\n <div className=\"flex justify-center mt-8\">\n <CircularProgress size=\"small\"/>\n </div>\n )}\n\n {!isLoadingDb && unmappedPolicies.length > 0 && (\n <div className=\"mt-12 flex flex-col gap-4\">\n <Typography variant=\"h6\" className=\"text-text-secondary\">Unmapped Database Policies</Typography>\n <Typography variant=\"body2\" className=\"text-text-secondary opacity-80 -mt-2\">\n These policies exist in your Postgres database but are not mapped to this collection&apos;s codebase configuration.\n </Typography>\n <div className=\"flex flex-col gap-3\">\n {unmappedPolicies.map(dp => (\n <Paper key={dp.policyname}\n className={\"p-4 border border-orange-200 dark:border-orange-900/50 bg-orange-50/50 dark:bg-orange-900/10 rounded-lg flex flex-col sm:flex-row sm:items-center justify-between gap-4 transition-colors\"}>\n <div className=\"flex flex-col gap-1.5 min-w-0\">\n <div className=\"flex items-center gap-2\">\n <KeyIcon size={iconSize.smallest} className=\"text-orange-500 shrink-0\"/>\n <Typography variant=\"subtitle2\" className=\"truncate\">{dp.policyname}</Typography>\n <Tooltip title=\"This policy is live in the database but missing from your codebase schema.\">\n <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\">\n DB Only\n </div>\n </Tooltip>\n </div>\n <div className=\"flex gap-2 text-xs pl-6 overflow-x-auto hide-scrollbar\">\n <Chip size=\"small\" className=\"bg-surface-card text-text-secondary border-none\">Action: {dp.cmd || \"ALL\"}</Chip>\n <Chip size=\"small\" className=\"bg-surface-card text-text-secondary border-none\">Roles: {Array.isArray(dp.roles) ? dp.roles.join(\", \") : dp.roles}</Chip>\n </div>\n </div>\n <div className=\"flex items-center gap-1 sm:gap-2 shrink-0\">\n {/* \"Import to codebase\" is the one action here that\n names its destination, and it is the one the\n backend refuses when it has no codebase to write. */}\n <Tooltip title={readOnly ? readOnlyTitle : undefined}>\n <div>\n <Button size=\"small\" variant=\"outlined\" color=\"primary\" disabled={readOnly} onClick={() => {\n // Not `toSecurityRule`: the inline editor's `roles`\n // are application roles, and a live policy's are its\n // `TO` list — database roles, `pgRoles`.\n const rule: SecurityRule = policyToSecurityRule(dp);\n setFieldValue(\"securityRules\", [...rules, rule]);\n }}>\n Import to codebase\n </Button>\n </div>\n </Tooltip>\n </div>\n </Paper>\n ))}\n </div>\n </div>\n )}\n </div>\n <Dialog open={!!editing} onOpenChange={(open) => !open && setEditing(null)} maxWidth=\"4xl\">\n {editing && (\n <InlinePolicyEditor\n policy={editing === \"new\" ? undefined : editing.policy}\n table={tableName || \"your_table\"}\n schema={schemaName}\n availableRoles={availableRoles}\n rolesUnavailable={rolesUnavailable}\n onSave={handleSave}\n onCancel={() => setEditing(null)}\n />\n )}\n </Dialog>\n </Container>\n </div>\n );\n}\n\n// ─── Inline Policy Editor (no Monaco dependency) ────────────────────\n\ntype PolicyCommand = \"ALL\" | \"SELECT\" | \"INSERT\" | \"UPDATE\" | \"DELETE\";\nconst COMMAND_OPTIONS: PolicyCommand[] = [\"ALL\", \"SELECT\", \"INSERT\", \"UPDATE\", \"DELETE\"];\n\nfunction InlinePolicyEditor({\n policy,\n table,\n schema,\n availableRoles,\n rolesUnavailable,\n onSave,\n onCancel\n}: {\n policy?: PostgresPolicy;\n table: string;\n schema: string;\n availableRoles: string[];\n rolesUnavailable: boolean;\n onSave: (policyData: Partial<PostgresPolicy>) => void;\n onCancel: () => void;\n}) {\n const { t } = useTranslation();\n const [name, setName] = useState(policy?.policyname || \"\");\n const [behavior, setBehavior] = useState<\"PERMISSIVE\" | \"RESTRICTIVE\">(policy?.permissive || \"PERMISSIVE\");\n const [command, setCommand] = useState<PolicyCommand>((policy?.cmd as PolicyCommand) || \"ALL\");\n // No roles means \"not restricted by role\". Seeding a value here would\n // silently narrow every new policy to it.\n const [roles, setRoles] = useState<string[]>(\n policy?.roles ? (Array.isArray(policy.roles) ? policy.roles : [policy.roles]) : []\n );\n const [customRole, setCustomRole] = useState(\"\");\n const [usingExpr, setUsingExpr] = useState(policy?.qual || \"\");\n const [checkExpr, setCheckExpr] = useState(policy?.with_check || \"\");\n\n const showCheck = command === \"ALL\" || command === \"INSERT\" || command === \"UPDATE\";\n\n /**\n * Roles offered in the dropdown: those in use in the project, plus any the\n * rule already carries. The union matters — application roles are derived\n * from what users hold, so a role that is referenced here but assigned to\n * nobody would otherwise vanish from its own policy on the next save.\n */\n const roleOptions = useMemo(\n () => Array.from(new Set([...availableRoles, ...roles])).sort(),\n [availableRoles, roles]\n );\n\n const addCustomRole = () => {\n const trimmed = customRole.trim();\n if (!trimmed || roles.includes(trimmed)) {\n setCustomRole(\"\");\n return;\n }\n setRoles([...roles, trimmed]);\n setCustomRole(\"\");\n };\n\n return (\n <>\n <DialogTitle variant=\"h6\">\n {policy ? \"Edit Policy\" : \"Create Policy\"}\n <div className=\"text-sm font-normal text-text-secondary dark:text-text-secondary-dark tracking-wide mt-1\">\n Define RLS rules for <span className=\"font-mono text-primary bg-primary-bg px-1 py-0.5 rounded\">{schema}.{table}</span>\n </div>\n </DialogTitle>\n <DialogContent className=\"p-4 md:p-6 border-t dark:border-surface-700 bg-surface-sheet\" includeMargin={false}>\n <Paper className={cls(\"p-4 md:p-6 flex flex-col gap-6 bg-surface-card border-none sm:border-solid rounded-none sm:rounded-xl\", defaultBorderMixin)}>\n <div className=\"grid grid-cols-1 md:grid-cols-2 gap-4\">\n <div className=\"flex flex-col gap-1.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">{t(\"studio_policy_name\")}</Typography>\n <TextField aria-label={t(\"studio_policy_name\")} value={name} onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => setName(e.target.value)} placeholder=\"e.g. allow_read_all\"/>\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">Behavior</Typography>\n <Select value={behavior} onValueChange={(val: string) => setBehavior(val as \"PERMISSIVE\" | \"RESTRICTIVE\")} position=\"item-aligned\">\n <SelectItem value=\"PERMISSIVE\">Permissive</SelectItem>\n <SelectItem value=\"RESTRICTIVE\">Restrictive</SelectItem>\n </Select>\n </div>\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">Command</Typography>\n <div className=\"flex flex-wrap gap-1.5\">\n {COMMAND_OPTIONS.map(cmd => (\n <Button key={cmd} size=\"small\" variant={command === cmd ? \"filled\" : \"text\"} color=\"neutral\" onClick={() => setCommand(cmd)}>\n {cmd}\n </Button>\n ))}\n </div>\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">Application Roles</Typography>\n <Typography variant=\"caption\" className=\"text-text-secondary opacity-80 -mt-1\">\n Roles held by users of this project, matched via <span className=\"font-mono\">{RLS_ROLES_SQL}</span>.\n These are not PostgreSQL roles — leave empty to apply the policy to everyone.\n </Typography>\n {roleOptions.length > 0 && (\n <MultiSelect size=\"small\" value={roles} onValueChange={setRoles} placeholder=\"Select roles\">\n {roleOptions.map(r => <MultiSelectItem key={r} value={r}>{r}</MultiSelectItem>)}\n </MultiSelect>\n )}\n {rolesUnavailable && roleOptions.length === 0 && (\n <Typography variant=\"caption\" className=\"text-text-secondary opacity-80\">\n Could not load the project&apos;s roles — enter them manually below.\n </Typography>\n )}\n {!rolesUnavailable && roleOptions.length === 0 && (\n <Typography variant=\"caption\" className=\"text-text-secondary opacity-80\">\n No roles are assigned to any user yet — enter one manually below.\n </Typography>\n )}\n <div className=\"flex gap-2 items-center\">\n <TextField size=\"small\" aria-label=\"Add a custom role\" value={customRole}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => setCustomRole(e.target.value)}\n onKeyDown={(e: React.KeyboardEvent) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n addCustomRole();\n }\n }}\n placeholder=\"Add a role not listed, e.g. editor\"/>\n <Button size=\"small\" variant=\"outlined\" color=\"neutral\"\n disabled={!customRole.trim()} onClick={addCustomRole}>\n Add\n </Button>\n </div>\n </div>\n {command !== \"INSERT\" && (\n <div className=\"flex flex-col gap-1.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">{t(\"studio_policy_using_expr\")}</Typography>\n <TextField aria-label={t(\"studio_policy_using_expr\")} value={usingExpr} onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => setUsingExpr(e.target.value)} placeholder={`e.g. ${RLS_UID_SQL} = uid`}/>\n </div>\n )}\n {showCheck && (\n <div className=\"flex flex-col gap-1.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">{t(\"studio_policy_check_expr\")}</Typography>\n <TextField aria-label={t(\"studio_policy_check_expr\")} value={checkExpr} onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => setCheckExpr(e.target.value)} placeholder={`e.g. ${RLS_UID_SQL} = uid`}/>\n </div>\n )}\n </Paper>\n </DialogContent>\n <DialogActions>\n <Button size=\"small\" variant=\"text\" color=\"neutral\" onClick={onCancel}>Cancel</Button>\n <Button size=\"small\" variant=\"filled\" color=\"primary\" disabled={!name}\n onClick={() => onSave({ policyname: name,\npermissive: behavior,\ncmd: command,\nroles,\nqual: usingExpr,\nwith_check: showCheck ? checkExpr : null })}\n >Save</Button>\n </DialogActions>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAUA,SAAS,sBAAsB,MAAsB;CACjD,IAAI,CAAC,2BAA2B,KAAK,IAAI,GACrC,MAAM,IAAI,MAAM,4BAA4B,KAAK,sDAAsD;CAE3G,OAAO,IAAI,KAAK;AACpB;;;;;;;;;;AAyEA,SAAS,oBAAoB,KAAuE;CAChG,QAAQ,KAAR;EACI,KAAK,UAAU,OAAO;EACtB,KAAK,UAAU,OAAO;EACtB,KAAK,UAAU,OAAO;EACtB,KAAK,UAAU,OAAO;EACtB,KAAK,OAAO,OAAO;EACnB,SAAS;CACb;AACJ;AAEA,SAAS,eAAe,YAA4E;CAOhG,IAAI,CAAC,YAAY,OAAO,KAAA;CACxB,OAAO,eAAe,gBAAgB,gBAAgB;AAC1D;;;;;;;;;AAUA,SAAS,eAAe,QAA6C;CACjE,OAAO;EACH,MAAM,O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,WAAU;gBAAf,CACI,oBAAC,YAAD;OAAY,SAAQ;OAAU,WAAU;iBAAgD,EAAE,0BAA0B;MAAc,CAAA,GAClI,oBAAC,WAAD;OAAW,cAAY,EAAE,0BAA0B;OAAG,OAAO;OAAW,WAAW,MAAiE,aAAa,EAAE,OAAO,KAAK;OAAG,aAAa,QAAQ,YAAY;MAAS,CAAA,CAC3N;;IAEN;;EACI,CAAA;EACf,qBAAC,eAAD,EAAA,UAAA,CACI,oBAAC,QAAD;GAAQ,MAAK;GAAQ,SAAQ;GAAO,OAAM;GAAU,SAAS;aAAU;EAAc,CAAA,GACrF,oBAAC,QAAD;GAAQ,MAAK;GAAQ,SAAQ;GAAS,OAAM;GAAU,UAAU,CAAC;GAC7D,eAAe,OAAO;IAAE,YAAY;IACxD,YAAY;IACZ,KAAK;IACL;IACA,MAAM;IACN,YAAY,YAAY,YAAY;GAAK,CAAC;aACzB;EAAY,CAAA,CACF,EAAA,CAAA;CACjB,EAAA,CAAA;AAEV"}
1
+ {"version":3,"file":"CollectionRLSTab.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/CollectionRLSTab.tsx"],"sourcesContent":["\nimport { getPolicyNamesForRule, getPolicyNamesForRules } from \"@rebasepro/utils\";\nimport { policyToSecurityRule } from \"@rebasepro/common\";\nimport { getGeneratedPolicyNamesOnce, getTableName, isPostgresCollectionConfig, type CollectionConfig } from \"@rebasepro/cms-types\";\nimport React, { useState, useEffect, useMemo } from \"react\";\n\n/**\n * Validates and double-quotes a SQL identifier to prevent injection.\n * Only allows safe Postgres identifiers (letters, digits, underscores).\n * Throws if the identifier contains unsafe characters.\n */\nfunction sanitizeSqlIdentifier(name: string): string {\n if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) {\n throw new Error(`Invalid SQL identifier: \"${name}\". Only letters, digits, and underscores are allowed.`);\n }\n return `\"${name}\"`;\n}\nimport {\n Button,\n Chip,\n CircularProgress,\n cls,\n Container,\n defaultBorderMixin,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n IconButton,\n iconSize,\n KeyIcon,\n MultiSelect,\n MultiSelectItem,\n Paper,\n Select,\n SelectItem,\n TextField,\n Tooltip,\n Trash2Icon,\n Typography\n} from \"@rebasepro/ui\";\nimport { useFormex } from \"@rebasepro/forms\";\nimport { useCollectionsConfigController } from \"../../useCollectionsConfigController\";\nimport { useRebaseContext, useTranslation } from \"@rebasepro/app\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport {\n RLS_ROLES_SQL,\n RLS_UID_SQL,\n type PolicyCondition,\n type PostgresPolicy,\n type SecurityOperation,\n type SecurityRule,\n type SecurityRuleAccess,\n type SecurityRuleBase\n} from \"@rebasepro/types\";\nimport { describeCondition, isEditableInForm, rlsRuleForm } from \"./rlsRuleForm\";\n\nexport type { PostgresPolicy } from \"@rebasepro/types\";\n\ntype CollectionWithSecurity = AdminCollection & {\n securityRules?: SecurityRule[];\n};\n\n/**\n * The security-rule fields a {@link PostgresPolicy} describes, and the ones an\n * edit carries over from the rule it changes.\n *\n * Wider than any one `SecurityRule` variant on purpose — the same shape as\n * Studio's `PolicyRule`: an edit starts from the rule as written and deletes\n * and assigns the fields that changed one at a time, and the variants are\n * exclusive about which fields go together.\n */\ntype PolicyRule = SecurityRuleBase & {\n using?: string;\n withCheck?: string;\n ownerField?: string;\n access?: SecurityRuleAccess;\n condition?: PolicyCondition;\n check?: PolicyCondition;\n /** Carried through untouched; a redacted rule is never edited (see `rlsRuleForm`). */\n redacted?: true;\n};\n\n/**\n * `pg_policies` reports the operation and the permissive flag in upper case;\n * `SecurityRule` names them in lower case. These two used to be `.toLowerCase()`\n * assigned straight into a `SecurityRule`, which typechecks only against a\n * `string` field — and this file declared its own local `SecurityRule` with\n * `operation?: string`, so it did. Against the real type it does not: an\n * unrecognised `cmd` would have been written into the collection as a policy\n * operation that compiles to nothing.\n */\nfunction toSecurityOperation(cmd: PostgresPolicy[\"cmd\"] | undefined): SecurityOperation | undefined {\n switch (cmd) {\n case \"SELECT\": return \"select\";\n case \"INSERT\": return \"insert\";\n case \"UPDATE\": return \"update\";\n case \"DELETE\": return \"delete\";\n case \"ALL\": return \"all\";\n default: return undefined;\n }\n}\n\nfunction toSecurityMode(permissive: PostgresPolicy[\"permissive\"] | undefined): SecurityRule[\"mode\"] {\n // Absent stays absent. `permissive` is the default, so writing it out\n // changes nothing semantically — but this value is serialized into the\n // user's collection file, and defaulting here would grow a `mode:\n // \"permissive\"` on every rule the editor touches. The `.toLowerCase()`\n // this replaced returned `undefined` for an absent value; that part was\n // right, and only the widened type was wrong.\n if (!permissive) return undefined;\n return permissive === \"RESTRICTIVE\" ? \"restrictive\" : \"permissive\";\n}\n\n/**\n * Build a rule from what the inline editor saved. Its `roles` are application\n * roles; a live policy's are its `TO` list, which `policyToSecurityRule` reads.\n *\n * The WITH CHECK is kept whether or not there is a USING: every INSERT-only\n * policy has only a check, and a roles-only rule with no roles compiles to\n * `WITH CHECK (false)`, which stops every insert.\n */\nfunction toSecurityRule(policy: Partial<PostgresPolicy>): PolicyRule {\n return {\n name: policy.policyname ?? \"\",\n operation: toSecurityOperation(policy.cmd),\n mode: toSecurityMode(policy.permissive),\n roles: policy.roles ? [...policy.roles] : undefined,\n ...(policy.qual ? { using: policy.qual } : {}),\n ...(policy.with_check ? { withCheck: policy.with_check } : {})\n };\n}\n\n/**\n * The rule with what the editor changed, and nothing else.\n *\n * The editor shows a rule as a policy — name, command, mode, application roles\n * and raw USING / WITH CHECK — and has no field for `ownerField`, `access`, a\n * structured `condition`, `operations` (it shows them as ALL) or `pgRoles`.\n * The rule used to be rebuilt from the form, which dropped all of them:\n * renaming an owner rule saved a roles-only rule with no roles, which compiles\n * to `USING (false)`. So a field is only written when it differs from what the\n * editor was opened with. A condition typed in replaces the rule's condition\n * whole — the forms are exclusive.\n *\n * Studio's RLS editor does the same in `policyRules.ts`; there the editor's\n * roles are the policy's `TO` list, `pgRoles`, and here they are `roles`.\n */\nfunction editedRule(rule: SecurityRule, original: PostgresPolicy, edited: Partial<PostgresPolicy>): PolicyRule {\n const next = toSecurityRule(edited);\n const result: PolicyRule = { ...rule };\n\n if ((edited.policyname ?? \"\") !== original.policyname) {\n if (next.name) result.name = next.name;\n else delete result.name;\n }\n if (edited.cmd !== original.cmd) {\n // `operations` wins over `operation`, so it has to go for the new\n // command to mean anything.\n delete result.operations;\n result.operation = next.operation;\n }\n if (edited.permissive !== original.permissive) {\n result.mode = next.mode;\n }\n if (!sameRoles(edited.roles, original.roles)) {\n if (next.roles && next.roles.length > 0) result.roles = next.roles;\n else delete result.roles;\n }\n if ((edited.qual || null) !== (original.qual || null) || (edited.with_check || null) !== (original.with_check || null)) {\n delete result.ownerField;\n delete result.access;\n delete result.condition;\n delete result.check;\n delete result.using;\n delete result.withCheck;\n if (next.using) result.using = next.using;\n if (next.withCheck) result.withCheck = next.withCheck;\n }\n return result;\n}\n\nfunction sameRoles(a: readonly string[] | undefined, b: readonly string[] | undefined): boolean {\n const left = [...(a ?? [])].sort();\n const right = [...(b ?? [])].sort();\n return left.length === right.length && left.every((role, i) => role === right[i]);\n}\n\nexport function CollectionRLSTab() {\n const { t } = useTranslation();\n const { values, setFieldValue } = useFormex<CollectionWithSecurity>();\n // The rule being edited is held by its position: an unnamed rule has no\n // name to find it by, and matching `rule.name` against the editor's empty\n // name found nothing, so the save wrote the rules back unchanged.\n const [editing, setEditing] = useState<{ index: number; policy: PostgresPolicy } | \"new\" | null>(null);\n\n // Every other tab in this dialog disables its inputs when the backend will\n // not accept an edit — the general and display forms behind a `fieldset\n // disabled`, the properties editor per control. This one did not, so a\n // read-only panel still invited you to write a policy, delete one, and\n // reorder the lot, and only said no at the submit button on the way out.\n const { readOnly, readOnlyReason } = useCollectionsConfigController();\n const readOnlyTitle = readOnlyReason || \"This backend does not accept collection edits.\";\n\n const rules: SecurityRule[] = values.securityRules || [];\n\n const { databaseAdmin } = useRebaseContext();\n const [dbPolicies, setDbPolicies] = useState<PostgresPolicy[]>([]);\n const [isLoadingDb, setIsLoadingDb] = useState(false);\n\n // The table `db push` writes this collection's policies on, resolved the\n // way the planner resolves it: `getTableName`, in the collection's schema\n // or `public`. This read `id || table || alias` — none of which a\n // collection that leaves `table` to its slug has, so it loaded no live\n // policies at all — and matched the name in every schema, offering another\n // schema's same-named table's policies for import into this collection.\n const tableName = getTableName(values);\n const schemaName = isPostgresCollectionConfig(values) && values.schema ? values.schema : \"public\";\n\n useEffect(() => {\n const fetchLivePolicies = async () => {\n if (!tableName || !databaseAdmin?.executeSql) return;\n\n setIsLoadingDb(true);\n try {\n // Both validated to be [a-zA-Z_][a-zA-Z0-9_]* — safe inside a\n // string literal once the double quotes are stripped.\n const rawTableName = sanitizeSqlIdentifier(tableName).slice(1, -1);\n const rawSchemaName = sanitizeSqlIdentifier(schemaName).slice(1, -1);\n const sql = `\n SELECT policyname, permissive, roles, cmd, qual, with_check\n FROM pg_policies\n WHERE schemaname = '${rawSchemaName}' AND tablename = '${rawTableName}';\n `;\n const result = await databaseAdmin.executeSql(sql);\n const extractRows = (res: unknown): Record<string, unknown>[] => {\n if (res && typeof res === \"object\" && \"rows\" in res && Array.isArray((res as { rows: Record<string, unknown>[] }).rows)) {\n return (res as { rows: Record<string, unknown>[] }).rows;\n }\n if (Array.isArray(res)) return res as Record<string, unknown>[];\n return [];\n };\n const pRows = extractRows(result);\n const policies: PostgresPolicy[] = pRows.map((p: Record<string, unknown>) => {\n let parsedRoles: string[] = [];\n const r = p.roles || p.ROLES;\n if (Array.isArray(r)) {\n parsedRoles = r as string[];\n } else if (typeof r === \"string\") {\n parsedRoles = r.replace(/^{|}$/g, \"\").split(\",\").map((s: string) => s.trim());\n }\n return {\n policyname: (p.policyname || p.POLICYNAME || \"\") as string,\n tablename: tableName,\n permissive: (p.permissive || p.PERMISSIVE || \"PERMISSIVE\") as \"PERMISSIVE\" | \"RESTRICTIVE\",\n roles: parsedRoles,\n cmd: (p.cmd || p.CMD || \"ALL\") as \"SELECT\" | \"INSERT\" | \"UPDATE\" | \"DELETE\" | \"ALL\",\n qual: (p.qual || p.QUAL || null) as string | null,\n with_check: (p.with_check || p.WITH_CHECK || null) as string | null\n };\n });\n setDbPolicies(policies);\n } catch (e) {\n console.error(\"Failed to fetch DB policies\", e);\n } finally {\n setIsLoadingDb(false);\n }\n };\n fetchLivePolicies();\n }, [databaseAdmin, tableName, schemaName]);\n\n /**\n * Application roles available to `SecurityRule.roles`.\n *\n * Deliberately NOT `fetchAvailableRoles` — that returns native pg_roles\n * (postgres, rebase_user, …), which can never satisfy an application-role\n * condition.\n */\n const [availableRoles, setAvailableRoles] = useState<string[]>([]);\n const [rolesUnavailable, setRolesUnavailable] = useState(false);\n\n useEffect(() => {\n let mounted = true;\n const fetchRoles = async () => {\n if (!databaseAdmin?.fetchApplicationRoles) {\n // Older backend, or a driver with no application-role concept.\n if (mounted) setRolesUnavailable(true);\n return;\n }\n try {\n const fetched = await databaseAdmin.fetchApplicationRoles();\n if (mounted) {\n setAvailableRoles(fetched);\n setRolesUnavailable(false);\n }\n } catch (e) {\n console.error(\"Failed to fetch application roles\", e);\n if (mounted) setRolesUnavailable(true);\n }\n };\n fetchRoles();\n return () => {\n mounted = false;\n };\n }, [databaseAdmin]);\n\n // Every policy name `rebase db push` would write for this collection — see\n // `getGeneratedPolicyNames`. This used to be derived here by hand, and the\n // Studio's RLS editor derived a different subset of it by hand, which is\n // exactly how the two came to disagree about which policies were drift.\n const generatedPolicyNames = useMemo(() => {\n if (!tableName) return new Set<string>();\n // Once: a collection projected from a served table already carries its injected rules.\n return getGeneratedPolicyNamesOnce(values as AdminCollection);\n }, [tableName, values]);\n\n // The collection the rules' column keys resolve against, to show a\n // condition as the SQL it compiles to.\n const ruleCollection: CollectionConfig = values;\n\n const unmappedPolicies = dbPolicies.filter(dp => !generatedPolicyNames.has(dp.policyname));\n\n const handleSave = (newPolicy: Partial<PostgresPolicy>) => {\n if (!editing) return;\n const newRules: PolicyRule[] = editing === \"new\"\n ? [...rules, toSecurityRule(newPolicy)]\n : rules.map((r, i) => (i === editing.index ? editedRule(r, editing.policy, newPolicy) : r));\n setFieldValue(\"securityRules\", newRules);\n setEditing(null);\n };\n\n return (\n <div className={\"overflow-auto my-auto\"}>\n <Container maxWidth={\"4xl\"} className={\"flex flex-col gap-4 p-8 m-auto\"}>\n <div className=\"w-full flex flex-col\">\n <div className=\"flex items-center justify-between mb-8\">\n <Typography variant=\"h5\">Row Level Security</Typography>\n <Tooltip title={readOnly ? readOnlyTitle : undefined}>\n <div>\n <Button variant=\"filled\" color=\"neutral\" disabled={readOnly} onClick={() => setEditing(\"new\")}>\n CREATE POLICY\n </Button>\n </div>\n </Tooltip>\n </div>\n\n {rules.length === 0 ? (\n <div className=\"flex-grow flex items-center justify-center text-text-disabled py-12\">\n <Typography variant=\"body2\">No RLS policies defined for this collection.</Typography>\n </div>\n ) : (\n <div className=\"flex flex-col gap-3\">\n {rules.map((rule: SecurityRule, index: number) => {\n const form = rlsRuleForm(rule);\n const editable = isEditableInForm(form);\n // Why EDIT is off for this rule, when it is: the form\n // has no field for what the rule says, so the rule is\n // edited where it is written — or, redacted, on the server.\n const lockedTitle = form === \"redacted\" ? t(\"studio_rls_rule_defined_on_server\") : t(\"studio_rls_rule_edit_in_code\");\n return (\n <Paper key={`${index}:${rule.name ?? \"\"}`}\n className={\"p-4 border border-transparent hover:border-surface-200 dark:hover:border-surface-700 rounded-lg flex flex-col sm:flex-row sm:items-center justify-between gap-4 transition-colors bg-surface-card shadow-sm\"}>\n <div className=\"flex flex-col gap-1.5 min-w-0\">\n <div className=\"flex items-center gap-2\">\n <KeyIcon size={iconSize.smallest} className=\"text-text-disabled dark:text-text-disabled-dark shrink-0\"/>\n <Typography variant=\"subtitle2\" className=\"truncate\">\n {/* Unnamed rules are still named in Postgres — show what they compile to\n rather than an empty heading. */}\n {rule.name || (tableName\n ? getPolicyNamesForRule(rule, tableName).join(\", \")\n : \"Unnamed policy\")}\n </Typography>\n </div>\n <div className=\"flex gap-2 text-xs pl-6 overflow-x-auto hide-scrollbar\">\n <Chip size=\"small\" className=\"bg-surface-raised text-text-secondary border-none\">Action: {rule.operation || \"ALL\"}</Chip>\n <Chip size=\"small\" className=\"bg-surface-raised text-text-secondary border-none\">Roles: {Array.isArray(rule.roles) ? rule.roles.join(\", \") : rule.roles}</Chip>\n {rule.access && (\n <Chip size=\"small\" className=\"bg-surface-raised text-text-secondary border-none\">\n {rule.access === \"authenticated\"\n ? t(\"studio_rls_rule_who_authenticated\")\n : rule.access === \"registered\"\n ? t(\"studio_rls_rule_who_registered\")\n : t(\"studio_rls_rule_who_public\")}\n </Chip>\n )}\n {form !== \"redacted\" && rule.condition != null && (\n <Chip size=\"small\" className=\"bg-surface-raised text-text-secondary border-none font-mono\">\n {t(\"studio_rls_rule_rows\", { condition: describeCondition(rule.condition, ruleCollection) })}\n </Chip>\n )}\n {form !== \"redacted\" && rule.check != null && (\n <Chip size=\"small\" className=\"bg-surface-raised text-text-secondary border-none font-mono\">\n {t(\"studio_rls_rule_writes\", { condition: describeCondition(rule.check, ruleCollection) })}\n </Chip>\n )}\n {form === \"redacted\" && (\n <Chip size=\"small\" className=\"bg-surface-raised text-text-secondary border-none\">\n {t(\"studio_rls_rule_redacted\")}\n </Chip>\n )}\n </div>\n </div>\n <div className=\"flex items-center gap-1 sm:gap-2 shrink-0\">\n {editable ? (\n <Button size=\"small\" variant=\"text\" disabled={readOnly} onClick={() => setEditing({\n index,\n policy: {\n policyname: rule.name ?? \"\",\n tablename: tableName || \"your_table\",\n permissive: (rule.mode || \"permissive\").toUpperCase() as PostgresPolicy[\"permissive\"],\n cmd: (rule.operation || \"ALL\").toUpperCase() as PostgresPolicy[\"cmd\"],\n roles: [...(rule.roles ?? [])],\n qual: rule.using || null,\n with_check: rule.withCheck || null\n }\n })}>\n EDIT\n </Button>\n ) : (\n // Read-only: the form has no field for what this rule\n // says. The button stays, disabled, saying where the\n // rule is edited instead.\n <Tooltip title={lockedTitle}>\n <div>\n <Button size=\"small\" variant=\"text\" disabled={true}>EDIT</Button>\n </div>\n </Tooltip>\n )}\n <IconButton aria-label={t(\"delete\")} size=\"small\" disabled={readOnly} onClick={() => {\n // By position, for the reason editing is: filtered\n // by `name`, every unnamed rule went with this one.\n setFieldValue(\"securityRules\", rules.filter((_r: SecurityRule, i: number) => i !== index));\n }}>\n <Trash2Icon size={iconSize.smallest} className=\"text-text-secondary dark:text-text-secondary-dark hover:text-red-500 dark:hover:text-red-500 transition-colors\"/>\n </IconButton>\n </div>\n </Paper>\n );\n })}\n </div>\n )}\n\n {isLoadingDb && unmappedPolicies.length === 0 && (\n <div className=\"flex justify-center mt-8\">\n <CircularProgress size=\"small\"/>\n </div>\n )}\n\n {!isLoadingDb && unmappedPolicies.length > 0 && (\n <div className=\"mt-12 flex flex-col gap-4\">\n <Typography variant=\"h6\" className=\"text-text-secondary\">Unmapped Database Policies</Typography>\n <Typography variant=\"body2\" className=\"text-text-secondary opacity-80 -mt-2\">\n These policies exist in your Postgres database but are not mapped to this collection&apos;s codebase configuration.\n </Typography>\n <div className=\"flex flex-col gap-3\">\n {unmappedPolicies.map(dp => (\n <Paper key={dp.policyname}\n className={\"p-4 border border-orange-200 dark:border-orange-900/50 bg-orange-50/50 dark:bg-orange-900/10 rounded-lg flex flex-col sm:flex-row sm:items-center justify-between gap-4 transition-colors\"}>\n <div className=\"flex flex-col gap-1.5 min-w-0\">\n <div className=\"flex items-center gap-2\">\n <KeyIcon size={iconSize.smallest} className=\"text-orange-500 shrink-0\"/>\n <Typography variant=\"subtitle2\" className=\"truncate\">{dp.policyname}</Typography>\n <Tooltip title=\"This policy is live in the database but missing from your codebase schema.\">\n <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\">\n DB Only\n </div>\n </Tooltip>\n </div>\n <div className=\"flex gap-2 text-xs pl-6 overflow-x-auto hide-scrollbar\">\n <Chip size=\"small\" className=\"bg-surface-card text-text-secondary border-none\">Action: {dp.cmd || \"ALL\"}</Chip>\n <Chip size=\"small\" className=\"bg-surface-card text-text-secondary border-none\">Roles: {Array.isArray(dp.roles) ? dp.roles.join(\", \") : dp.roles}</Chip>\n </div>\n </div>\n <div className=\"flex items-center gap-1 sm:gap-2 shrink-0\">\n {/* \"Import to codebase\" is the one action here that\n names its destination, and it is the one the\n backend refuses when it has no codebase to write. */}\n <Tooltip title={readOnly ? readOnlyTitle : undefined}>\n <div>\n <Button size=\"small\" variant=\"outlined\" color=\"primary\" disabled={readOnly} onClick={() => {\n // Not `toSecurityRule`: the inline editor's `roles`\n // are application roles, and a live policy's are its\n // `TO` list — database roles, `pgRoles`.\n const rule: SecurityRule = policyToSecurityRule(dp);\n setFieldValue(\"securityRules\", [...rules, rule]);\n }}>\n Import to codebase\n </Button>\n </div>\n </Tooltip>\n </div>\n </Paper>\n ))}\n </div>\n </div>\n )}\n </div>\n <Dialog open={!!editing} onOpenChange={(open) => !open && setEditing(null)} maxWidth=\"4xl\">\n {editing && (\n <InlinePolicyEditor\n policy={editing === \"new\" ? undefined : editing.policy}\n table={tableName || \"your_table\"}\n schema={schemaName}\n availableRoles={availableRoles}\n rolesUnavailable={rolesUnavailable}\n onSave={handleSave}\n onCancel={() => setEditing(null)}\n />\n )}\n </Dialog>\n </Container>\n </div>\n );\n}\n\n// ─── Inline Policy Editor (no Monaco dependency) ────────────────────\n\ntype PolicyCommand = \"ALL\" | \"SELECT\" | \"INSERT\" | \"UPDATE\" | \"DELETE\";\nconst COMMAND_OPTIONS: PolicyCommand[] = [\"ALL\", \"SELECT\", \"INSERT\", \"UPDATE\", \"DELETE\"];\n\nfunction InlinePolicyEditor({\n policy,\n table,\n schema,\n availableRoles,\n rolesUnavailable,\n onSave,\n onCancel\n}: {\n policy?: PostgresPolicy;\n table: string;\n schema: string;\n availableRoles: string[];\n rolesUnavailable: boolean;\n onSave: (policyData: Partial<PostgresPolicy>) => void;\n onCancel: () => void;\n}) {\n const { t } = useTranslation();\n const [name, setName] = useState(policy?.policyname || \"\");\n const [behavior, setBehavior] = useState<\"PERMISSIVE\" | \"RESTRICTIVE\">(policy?.permissive || \"PERMISSIVE\");\n const [command, setCommand] = useState<PolicyCommand>((policy?.cmd as PolicyCommand) || \"ALL\");\n // No roles means \"not restricted by role\". Seeding a value here would\n // silently narrow every new policy to it.\n const [roles, setRoles] = useState<string[]>(\n policy?.roles ? (Array.isArray(policy.roles) ? policy.roles : [policy.roles]) : []\n );\n const [customRole, setCustomRole] = useState(\"\");\n const [usingExpr, setUsingExpr] = useState(policy?.qual || \"\");\n const [checkExpr, setCheckExpr] = useState(policy?.with_check || \"\");\n\n const showCheck = command === \"ALL\" || command === \"INSERT\" || command === \"UPDATE\";\n\n /**\n * Roles offered in the dropdown: those in use in the project, plus any the\n * rule already carries. The union matters — application roles are derived\n * from what users hold, so a role that is referenced here but assigned to\n * nobody would otherwise vanish from its own policy on the next save.\n */\n const roleOptions = useMemo(\n () => Array.from(new Set([...availableRoles, ...roles])).sort(),\n [availableRoles, roles]\n );\n\n const addCustomRole = () => {\n const trimmed = customRole.trim();\n if (!trimmed || roles.includes(trimmed)) {\n setCustomRole(\"\");\n return;\n }\n setRoles([...roles, trimmed]);\n setCustomRole(\"\");\n };\n\n return (\n <>\n <DialogTitle variant=\"h6\">\n {policy ? \"Edit Policy\" : \"Create Policy\"}\n <div className=\"text-sm font-normal text-text-secondary dark:text-text-secondary-dark tracking-wide mt-1\">\n Define RLS rules for <span className=\"font-mono text-primary bg-primary-bg px-1 py-0.5 rounded\">{schema}.{table}</span>\n </div>\n </DialogTitle>\n <DialogContent className=\"p-4 md:p-6 border-t dark:border-surface-700 bg-surface-sheet\" includeMargin={false}>\n <Paper className={cls(\"p-4 md:p-6 flex flex-col gap-6 bg-surface-card border-none sm:border-solid rounded-none sm:rounded-xl\", defaultBorderMixin)}>\n <div className=\"grid grid-cols-1 md:grid-cols-2 gap-4\">\n <div className=\"flex flex-col gap-1.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">{t(\"studio_policy_name\")}</Typography>\n <TextField aria-label={t(\"studio_policy_name\")} value={name} onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => setName(e.target.value)} placeholder=\"e.g. allow_read_all\"/>\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">Behavior</Typography>\n <Select value={behavior} onValueChange={(val: string) => setBehavior(val as \"PERMISSIVE\" | \"RESTRICTIVE\")} position=\"item-aligned\">\n <SelectItem value=\"PERMISSIVE\">Permissive</SelectItem>\n <SelectItem value=\"RESTRICTIVE\">Restrictive</SelectItem>\n </Select>\n </div>\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">Command</Typography>\n <div className=\"flex flex-wrap gap-1.5\">\n {COMMAND_OPTIONS.map(cmd => (\n <Button key={cmd} size=\"small\" variant={command === cmd ? \"filled\" : \"text\"} color=\"neutral\" onClick={() => setCommand(cmd)}>\n {cmd}\n </Button>\n ))}\n </div>\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">Application Roles</Typography>\n <Typography variant=\"caption\" className=\"text-text-secondary opacity-80 -mt-1\">\n Roles held by users of this project, matched via <span className=\"font-mono\">{RLS_ROLES_SQL}</span>.\n These are not PostgreSQL roles — leave empty to apply the policy to everyone.\n </Typography>\n {roleOptions.length > 0 && (\n <MultiSelect size=\"small\" value={roles} onValueChange={setRoles} placeholder=\"Select roles\">\n {roleOptions.map(r => <MultiSelectItem key={r} value={r}>{r}</MultiSelectItem>)}\n </MultiSelect>\n )}\n {rolesUnavailable && roleOptions.length === 0 && (\n <Typography variant=\"caption\" className=\"text-text-secondary opacity-80\">\n Could not load the project&apos;s roles — enter them manually below.\n </Typography>\n )}\n {!rolesUnavailable && roleOptions.length === 0 && (\n <Typography variant=\"caption\" className=\"text-text-secondary opacity-80\">\n No roles are assigned to any user yet — enter one manually below.\n </Typography>\n )}\n <div className=\"flex gap-2 items-center\">\n <TextField size=\"small\" aria-label=\"Add a custom role\" value={customRole}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => setCustomRole(e.target.value)}\n onKeyDown={(e: React.KeyboardEvent) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n addCustomRole();\n }\n }}\n placeholder=\"Add a role not listed, e.g. editor\"/>\n <Button size=\"small\" variant=\"outlined\" color=\"neutral\"\n disabled={!customRole.trim()} onClick={addCustomRole}>\n Add\n </Button>\n </div>\n </div>\n {command !== \"INSERT\" && (\n <div className=\"flex flex-col gap-1.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">{t(\"studio_policy_using_expr\")}</Typography>\n <TextField aria-label={t(\"studio_policy_using_expr\")} value={usingExpr} onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => setUsingExpr(e.target.value)} placeholder={`e.g. ${RLS_UID_SQL} = uid`}/>\n </div>\n )}\n {showCheck && (\n <div className=\"flex flex-col gap-1.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">{t(\"studio_policy_check_expr\")}</Typography>\n <TextField aria-label={t(\"studio_policy_check_expr\")} value={checkExpr} onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => setCheckExpr(e.target.value)} placeholder={`e.g. ${RLS_UID_SQL} = uid`}/>\n </div>\n )}\n </Paper>\n </DialogContent>\n <DialogActions>\n <Button size=\"small\" variant=\"text\" color=\"neutral\" onClick={onCancel}>Cancel</Button>\n <Button size=\"small\" variant=\"filled\" color=\"primary\" disabled={!name}\n onClick={() => onSave({ policyname: name,\npermissive: behavior,\ncmd: command,\nroles,\nqual: usingExpr,\nwith_check: showCheck ? checkExpr : null })}\n >Save</Button>\n </DialogActions>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAWA,SAAS,sBAAsB,MAAsB;CACj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W,cAAY,EAAE,0BAA0B;OAAG,OAAO;OAAW,WAAW,MAAiE,aAAa,EAAE,OAAO,KAAK;OAAG,aAAa,QAAQ,YAAY;MAAS,CAAA,CAC3N;;KAER,aACG,qBAAC,OAAD;MAAK,WAAU;gBAAf,CACI,oBAAC,YAAD;OAAY,SAAQ;OAAU,WAAU;iBAAgD,EAAE,0BAA0B;MAAc,CAAA,GAClI,oBAAC,WAAD;OAAW,cAAY,EAAE,0BAA0B;OAAG,OAAO;OAAW,WAAW,MAAiE,aAAa,EAAE,OAAO,KAAK;OAAG,aAAa,QAAQ,YAAY;MAAS,CAAA,CAC3N;;IAEN;;EACI,CAAA;EACf,qBAAC,eAAD,EAAA,UAAA,CACI,oBAAC,QAAD;GAAQ,MAAK;GAAQ,SAAQ;GAAO,OAAM;GAAU,SAAS;aAAU;EAAc,CAAA,GACrF,oBAAC,QAAD;GAAQ,MAAK;GAAQ,SAAQ;GAAS,OAAM;GAAU,UAAU,CAAC;GAC7D,eAAe,OAAO;IAAE,YAAY;IACxD,YAAY;IACZ,KAAK;IACL;IACA,MAAM;IACN,YAAY,YAAY,YAAY;GAAK,CAAC;aACzB;EAAY,CAAA,CACF,EAAA,CAAA;CACjB,EAAA,CAAA;AAEV"}
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- import { Relation, RelationKind, JoinStep, OnAction } from "@rebasepro/types";
2
+ import { RelationKind, JoinStep, OnAction } from "@rebasepro/types";
3
+ import { Relation } from "@rebasepro/cms-types";
3
4
  /**
4
5
  * A relation being edited.
5
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"DisplaySettingsForm.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/DisplaySettingsForm.tsx"],"sourcesContent":["\nimport { FieldCaption } from \"../../_cms_internals\";\nimport React, { useMemo, useState } from \"react\";\nimport { useCustomizationController, useTranslation } from \"@rebasepro/app\";\nimport { getFieldConfig } from \"../../../components/field_configs\";\nimport { PropertyConfigBadge } from \"../../../components/PropertyConfigBadge\";\nimport { Property } from \"@rebasepro/types\";\nimport {\n BooleanSwitchWithLabel,\n Button,\n Container,\n IconButton,\n iconSize,\n Select,\n SelectItem,\n TextField,\n Typography,\n XIcon\n} from \"@rebasepro/ui\";\n\nimport { useFormex } from \"@rebasepro/forms\";\nimport { LayoutModeSwitch } from \"./LayoutModeSwitch\";\nimport { ViewModeSwitch } from \"./ViewModeSwitch\";\nimport { KanbanConfigSection } from \"./KanbanConfigSection\";\nimport { PropertyFormDialog } from \"./PropertyEditView\";\nimport { useCollectionsConfigController } from \"../../useCollectionsConfigController\";\nimport { unslugify } from \"@rebasepro/utils\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport function DisplaySettingsForm({\n expandKanban,\n standalone,\n}: {\n expandKanban?: boolean;\n standalone?: boolean;\n}) {\n const { t } = useTranslation();\n\n const {\n values,\n setFieldValue,\n handleChange,\n submitCount\n } = useFormex<AdminCollection>();\n\n const [orderPropertyDialogOpen, setOrderPropertyDialogOpen] = useState(false);\n\n const customizationController = useCustomizationController();\n const configControllerFromContext = useCollectionsConfigController();\n const configController = standalone ? { readOnly: false } : configControllerFromContext;\n\n // Get text properties (for orderProperty - uses string fractional indexing keys)\n const textProperties = useMemo(() => {\n const result: { key: string; label: string; property: Property; }[] = [];\n if (!values.properties) return result;\n\n Object.entries(values.properties).forEach(([key, prop]) => {\n if (prop && \"type\" in prop && prop.type === \"string\") {\n result.push({\n key,\n label: (prop as Property).name || key,\n property: prop as Property\n });\n }\n });\n return result;\n }, [values.properties]);\n\n const showErrors = submitCount > 0;\n\n return (\n <div className={\"overflow-auto my-auto\"}>\n <Container maxWidth={\"4xl\"} className={\"flex flex-col gap-4 p-8 m-auto\"}>\n\n <div>\n <Typography variant={\"h5\"} className={\"flex-grow\"}>\n Display settings\n </Typography>\n </div>\n\n <fieldset disabled={configController?.readOnly} className=\"contents\">\n <div className={\"grid grid-cols-12 gap-4\"}>\n\n {/* Layout Mode (Side dialog vs Full screen) */}\n <LayoutModeSwitch\n className={\"col-span-12\"}\n value={values.openEntityMode ?? \"side_panel\"}\n onChange={(value) => setFieldValue(\"openEntityMode\", value)}/>\n\n {/* View Mode (Table/Cards/Kanban) */}\n <ViewModeSwitch\n className={\"col-span-12\"}\n value={values.defaultViewMode ?? \"table\"}\n onChange={(value) => setFieldValue(\"defaultViewMode\", value)}/>\n\n {/* Kanban Column Property */}\n <KanbanConfigSection className={\"col-span-12\"} forceExpanded={expandKanban}/>\n\n {/* Order Property */}\n <div className={\"col-span-12 mt-4\"}>\n {(() => {\n const orderPropertyMissing = Boolean(values.orderProperty) &&\n !textProperties.some(p => p.key === values.orderProperty);\n\n return (\n <>\n <Select\n key={`order-select-${textProperties.length}`}\n name=\"orderProperty\"\n label=\"Order Property\"\n fullWidth={true}\n position={\"item-aligned\"}\n disabled={textProperties.length === 0}\n error={orderPropertyMissing}\n value={values.orderProperty ?? \"\"}\n onValueChange={(v) => {\n setFieldValue(\"orderProperty\", v || undefined);\n }}\n renderValue={(value) => {\n if (orderPropertyMissing) {\n return <span className=\"text-red-500\">{value} (not found)</span>;\n }\n const prop = textProperties.find(p => p.key === value);\n if (!prop) return \"Select a property\";\n const fieldConfig = getFieldConfig(prop.property, customizationController?.propertyConfigs ?? {});\n return (\n <div className=\"flex items-center gap-2\">\n <PropertyConfigBadge propertyConfig={fieldConfig}/>\n <span>{prop.label}</span>\n </div>\n );\n }}\n endAdornment={values.orderProperty ? (\n <IconButton aria-label={t(\"clear\")}\n size=\"small\"\n onClick={(e) => {\n e.stopPropagation();\n setFieldValue(\"orderProperty\", undefined);\n }}\n >\n <XIcon size={iconSize.smallest}/>\n </IconButton>\n ) : undefined}\n >\n {textProperties.map((prop) => {\n const fieldConfig = getFieldConfig(prop.property, customizationController?.propertyConfigs ?? {});\n return (\n <SelectItem key={prop.key} value={prop.key}>\n <div className=\"flex items-center gap-3\">\n <PropertyConfigBadge propertyConfig={fieldConfig}/>\n <div>\n <div>{prop.label}</div>\n <Typography variant=\"caption\" color=\"secondary\">\n {fieldConfig?.name || \"Text\"}\n </Typography>\n </div>\n </div>\n </SelectItem>\n );\n })}\n </Select>\n <FieldCaption error={orderPropertyMissing}>\n {orderPropertyMissing\n ? `Property \"${values.orderProperty}\" does not exist or is not a text property. Please select a valid property or clear the selection.`\n : textProperties.length === 0\n ? \"No text properties found. Add a text property to enable ordering.\"\n : \"Select a text property to persist the order of items\"\n }\n </FieldCaption>\n </>\n );\n })()}\n {(() => {\n const orderPropertyMissing = Boolean(values.orderProperty) &&\n !textProperties.some(p => p.key === values.orderProperty);\n const showCreateButton = !values.orderProperty || orderPropertyMissing;\n\n const dialogPropertyKey = orderPropertyMissing && values.orderProperty\n ? values.orderProperty\n : \"__order\";\n const dialogPropertyName = orderPropertyMissing && values.orderProperty\n ? unslugify(values.orderProperty)\n : \"Order\";\n\n if (!showCreateButton) return null;\n\n return (\n <>\n <Button\n variant=\"text\"\n size=\"small\"\n className=\"ml-3.5 mt-2\"\n onClick={() => setOrderPropertyDialogOpen(true)}\n >\n + Create &quot;{dialogPropertyKey}&quot; property\n </Button>\n <PropertyFormDialog\n open={orderPropertyDialogOpen}\n onCancel={() => setOrderPropertyDialogOpen(false)}\n property={{\n type: \"string\",\n name: dialogPropertyName,\n admin: { disabled: true,\nhideFromCollection: true }\n }}\n propertyKey={dialogPropertyKey}\n existingProperty={false}\n autoOpenTypeSelect={false}\n autoUpdateId={false}\n inArray={false}\n allowDataInference={false}\n propertyConfigs={customizationController?.propertyConfigs ?? {}}\n\n existingPropertyKeys={Object.keys(values.properties ?? {})}\n onPropertyChanged={({ id, property }) => {\n const newProperties = {\n ...values.properties,\n [id!]: property\n };\n const newPropertiesOrder = [...(values.propertiesOrder ?? Object.keys(values.properties ?? {})), id];\n setFieldValue(\"properties\", newProperties);\n setFieldValue(\"propertiesOrder\", newPropertiesOrder);\n setFieldValue(\"orderProperty\", id);\n setOrderPropertyDialogOpen(false);\n }}\n />\n </>\n );\n })()}\n </div>\n\n {/* Default row size */}\n <div className={\"col-span-12\"}>\n <Select\n name=\"defaultSize\"\n fullWidth={true}\n label=\"Default row size\"\n position={\"item-aligned\"}\n onChange={handleChange}\n value={values.defaultSize ?? \"\"}\n renderValue={(value: string) => value.toUpperCase()}\n >\n {[\"xs\", \"s\", \"m\", \"l\", \"xl\"].map((value) => (\n <SelectItem\n key={`size-select-${value}`}\n value={value}>\n {value.toUpperCase()}\n </SelectItem>\n ))}\n </Select>\n </div>\n\n {/* Side dialog width */}\n <div className={\"col-span-12\"}>\n <TextField\n name={\"sideDialogWidth\"}\n type={\"number\"}\n aria-describedby={\"sideDialogWidth-helper\"}\n onChange={(e) => {\n const value = e.target.value;\n if (!value) {\n setFieldValue(\"sideDialogWidth\", null);\n } else if (!isNaN(Number(value))) {\n setFieldValue(\"sideDialogWidth\", Number(value));\n }\n }}\n endAdornment={<IconButton aria-label={t(\"clear\")}\n size={\"small\"}\n onClick={() => {\n setFieldValue(\"sideDialogWidth\", null);\n }}\n disabled={!values.sideDialogWidth}>\n <XIcon size={iconSize.small}/>\n </IconButton>}\n value={values.sideDialogWidth ?? \"\"}\n label={\"Side dialog width\"}/>\n <FieldCaption>\n Optionally define the width (in pixels) of entities side dialog. Default is 768px\n </FieldCaption>\n </div>\n\n {/* Inline editing */}\n <div className={\"col-span-12\"}>\n <BooleanSwitchWithLabel\n position={\"start\"}\n label={values.inlineEditing === undefined || values.inlineEditing ? \"Data can be edited directly in the table view\" : \"Data can be edited only in the form view\"}\n onValueChange={(v) => setFieldValue(\"inlineEditing\", v)}\n value={values.inlineEditing === undefined ? true : values.inlineEditing}\n />\n <FieldCaption>\n Allow editing data directly in the table view, without opening the form view.\n </FieldCaption>\n </div>\n\n {/* Include JSON view */}\n <div className={\"col-span-12\"}>\n <BooleanSwitchWithLabel\n position={\"start\"}\n label={values.includeJsonView === undefined || values.includeJsonView ? \"Include JSON view\" : \"Do not include JSON view\"}\n onValueChange={(v) => setFieldValue(\"includeJsonView\", v)}\n value={values.includeJsonView === undefined ? true : values.includeJsonView}\n />\n <FieldCaption>\n Allows removing the form view JSON tab if you think it is confusing for your users.\n </FieldCaption>\n </div>\n\n </div>\n </fieldset>\n\n <div style={{ height: \"52px\" }}/>\n\n </Container>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AA6BA,SAAgB,oBAAoB,EAChC,cACA,cAID;CACC,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,EACF,QACA,eACA,cACA,gBACA,UAA2B;CAE/B,MAAM,CAAC,yBAAyB,8BAA8B,SAAS,KAAK;CAE5E,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,8BAA8B,+BAA+B;CACnE,MAAM,mBAAmB,aAAa,EAAE,UAAU,MAAM,IAAI;CAG5D,MAAM,iBAAiB,cAAc;EACjC,MAAM,SAAgE,CAAC;EACvE,IAAI,CAAC,OAAO,YAAY,OAAO;EAE/B,OAAO,QAAQ,OAAO,UAAU,CAAC,CAAC,SAAS,CAAC,KAAK,UAAU;GACvD,IAAI,QAAQ,UAAU,QAAQ,KAAK,SAAS,UACxC,OAAO,KAAK;IACR;IACA,OAAQ,KAAkB,QAAQ;IAClC,UAAU;GACd,CAAC;EAET,CAAC;EACD,OAAO;CACX,GAAG,CAAC,OAAO,UAAU,CAAC;CAItB,OACI,oBAAC,OAAD;EAAK,WAAW;YACZ,qBAAC,WAAD;GAAW,UAAU;GAAO,WAAW;aAAvC;IAEI,oBAAC,OAAD,EAAA,UACI,oBAAC,YAAD;KAAY,SAAS;KAAM,WAAW;eAAa;IAEvC,CAAA,EACX,CAAA;IAEL,oBAAC,YAAD;KAAU,UAAU,kBAAkB;KAAU,WAAU;eACtD,qBAAC,OAAD;MAAK,WAAW;gBAAhB;OAGI,oBAAC,kBAAD;QACI,WAAW;QACX,OAAO,OAAO,kBAAkB;QAChC,WAAW,UAAU,cAAc,kBAAkB,KAAK;OAAG,CAAA;OAGjE,oBAAC,gBAAD;QACI,WAAW;QACX,OAAO,OAAO,mBAAmB;QACjC,WAAW,U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I,oBAAC,wBAAD;SACI,UAAU;SACV,OAAO,OAAO,kBAAkB,KAAA,KAAa,OAAO,gBAAgB,kDAAkD;SACtH,gBAAgB,MAAM,cAAc,iBAAiB,CAAC;SACtD,OAAO,OAAO,kBAAkB,KAAA,IAAY,OAAO,OAAO;QAC7D,CAAA,GACD,oBAAC,cAAD,EAAA,UAAc,gFAEA,CAAA,CACb;;OAGL,qBAAC,OAAD;QAAK,WAAW;kBAAhB,CACI,oBAAC,wBAAD;SACI,UAAU;SACV,OAAO,OAAO,oBAAoB,KAAA,KAAa,OAAO,kBAAkB,sBAAsB;SAC9F,gBAAgB,MAAM,cAAc,mBAAmB,CAAC;SACxD,OAAO,OAAO,oBAAoB,KAAA,IAAY,OAAO,OAAO;QAC/D,CAAA,GACD,oBAAC,cAAD,EAAA,UAAc,sFAEA,CAAA,CACb;;MAEJ;;IACC,CAAA;IAEV,oBAAC,OAAD,EAAK,OAAO,EAAE,QAAQ,OAAO,EAAG,CAAA;GAEzB;;CACV,CAAA;AAEb"}
1
+ {"version":3,"file":"DisplaySettingsForm.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/DisplaySettingsForm.tsx"],"sourcesContent":["\nimport { FieldCaption } from \"../../_cms_internals\";\nimport React, { useMemo, useState } from \"react\";\nimport { useCustomizationController, useTranslation } from \"@rebasepro/app\";\nimport { getFieldConfig } from \"../../../components/field_configs\";\nimport { PropertyConfigBadge } from \"../../../components/PropertyConfigBadge\";\nimport { Property } from \"@rebasepro/cms-types\";\nimport {\n BooleanSwitchWithLabel,\n Button,\n Container,\n IconButton,\n iconSize,\n Select,\n SelectItem,\n TextField,\n Typography,\n XIcon\n} from \"@rebasepro/ui\";\n\nimport { useFormex } from \"@rebasepro/forms\";\nimport { LayoutModeSwitch } from \"./LayoutModeSwitch\";\nimport { ViewModeSwitch } from \"./ViewModeSwitch\";\nimport { KanbanConfigSection } from \"./KanbanConfigSection\";\nimport { PropertyFormDialog } from \"./PropertyEditView\";\nimport { useCollectionsConfigController } from \"../../useCollectionsConfigController\";\nimport { unslugify } from \"@rebasepro/utils\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport function DisplaySettingsForm({\n expandKanban,\n standalone,\n}: {\n expandKanban?: boolean;\n standalone?: boolean;\n}) {\n const { t } = useTranslation();\n\n const {\n values,\n setFieldValue,\n handleChange,\n submitCount\n } = useFormex<AdminCollection>();\n\n const [orderPropertyDialogOpen, setOrderPropertyDialogOpen] = useState(false);\n\n const customizationController = useCustomizationController();\n const configControllerFromContext = useCollectionsConfigController();\n const configController = standalone ? { readOnly: false } : configControllerFromContext;\n\n // Get text properties (for orderProperty - uses string fractional indexing keys)\n const textProperties = useMemo(() => {\n const result: { key: string; label: string; property: Property; }[] = [];\n if (!values.properties) return result;\n\n Object.entries(values.properties).forEach(([key, prop]) => {\n if (prop && \"type\" in prop && prop.type === \"string\") {\n result.push({\n key,\n label: (prop as Property).name || key,\n property: prop as Property\n });\n }\n });\n return result;\n }, [values.properties]);\n\n const showErrors = submitCount > 0;\n\n return (\n <div className={\"overflow-auto my-auto\"}>\n <Container maxWidth={\"4xl\"} className={\"flex flex-col gap-4 p-8 m-auto\"}>\n\n <div>\n <Typography variant={\"h5\"} className={\"flex-grow\"}>\n Display settings\n </Typography>\n </div>\n\n <fieldset disabled={configController?.readOnly} className=\"contents\">\n <div className={\"grid grid-cols-12 gap-4\"}>\n\n {/* Layout Mode (Side dialog vs Full screen) */}\n <LayoutModeSwitch\n className={\"col-span-12\"}\n value={values.openEntityMode ?? \"side_panel\"}\n onChange={(value) => setFieldValue(\"openEntityMode\", value)}/>\n\n {/* View Mode (Table/Cards/Kanban) */}\n <ViewModeSwitch\n className={\"col-span-12\"}\n value={values.defaultViewMode ?? \"table\"}\n onChange={(value) => setFieldValue(\"defaultViewMode\", value)}/>\n\n {/* Kanban Column Property */}\n <KanbanConfigSection className={\"col-span-12\"} forceExpanded={expandKanban}/>\n\n {/* Order Property */}\n <div className={\"col-span-12 mt-4\"}>\n {(() => {\n const orderPropertyMissing = Boolean(values.orderProperty) &&\n !textProperties.some(p => p.key === values.orderProperty);\n\n return (\n <>\n <Select\n key={`order-select-${textProperties.length}`}\n name=\"orderProperty\"\n label=\"Order Property\"\n fullWidth={true}\n position={\"item-aligned\"}\n disabled={textProperties.length === 0}\n error={orderPropertyMissing}\n value={values.orderProperty ?? \"\"}\n onValueChange={(v) => {\n setFieldValue(\"orderProperty\", v || undefined);\n }}\n renderValue={(value) => {\n if (orderPropertyMissing) {\n return <span className=\"text-red-500\">{value} (not found)</span>;\n }\n const prop = textProperties.find(p => p.key === value);\n if (!prop) return \"Select a property\";\n const fieldConfig = getFieldConfig(prop.property, customizationController?.propertyConfigs ?? {});\n return (\n <div className=\"flex items-center gap-2\">\n <PropertyConfigBadge propertyConfig={fieldConfig}/>\n <span>{prop.label}</span>\n </div>\n );\n }}\n endAdornment={values.orderProperty ? (\n <IconButton aria-label={t(\"clear\")}\n size=\"small\"\n onClick={(e) => {\n e.stopPropagation();\n setFieldValue(\"orderProperty\", undefined);\n }}\n >\n <XIcon size={iconSize.smallest}/>\n </IconButton>\n ) : undefined}\n >\n {textProperties.map((prop) => {\n const fieldConfig = getFieldConfig(prop.property, customizationController?.propertyConfigs ?? {});\n return (\n <SelectItem key={prop.key} value={prop.key}>\n <div className=\"flex items-center gap-3\">\n <PropertyConfigBadge propertyConfig={fieldConfig}/>\n <div>\n <div>{prop.label}</div>\n <Typography variant=\"caption\" color=\"secondary\">\n {fieldConfig?.name || \"Text\"}\n </Typography>\n </div>\n </div>\n </SelectItem>\n );\n })}\n </Select>\n <FieldCaption error={orderPropertyMissing}>\n {orderPropertyMissing\n ? `Property \"${values.orderProperty}\" does not exist or is not a text property. Please select a valid property or clear the selection.`\n : textProperties.length === 0\n ? \"No text properties found. Add a text property to enable ordering.\"\n : \"Select a text property to persist the order of items\"\n }\n </FieldCaption>\n </>\n );\n })()}\n {(() => {\n const orderPropertyMissing = Boolean(values.orderProperty) &&\n !textProperties.some(p => p.key === values.orderProperty);\n const showCreateButton = !values.orderProperty || orderPropertyMissing;\n\n const dialogPropertyKey = orderPropertyMissing && values.orderProperty\n ? values.orderProperty\n : \"__order\";\n const dialogPropertyName = orderPropertyMissing && values.orderProperty\n ? unslugify(values.orderProperty)\n : \"Order\";\n\n if (!showCreateButton) return null;\n\n return (\n <>\n <Button\n variant=\"text\"\n size=\"small\"\n className=\"ml-3.5 mt-2\"\n onClick={() => setOrderPropertyDialogOpen(true)}\n >\n + Create &quot;{dialogPropertyKey}&quot; property\n </Button>\n <PropertyFormDialog\n open={orderPropertyDialogOpen}\n onCancel={() => setOrderPropertyDialogOpen(false)}\n property={{\n type: \"string\",\n name: dialogPropertyName,\n admin: { disabled: true,\nhideFromCollection: true }\n }}\n propertyKey={dialogPropertyKey}\n existingProperty={false}\n autoOpenTypeSelect={false}\n autoUpdateId={false}\n inArray={false}\n allowDataInference={false}\n propertyConfigs={customizationController?.propertyConfigs ?? {}}\n\n existingPropertyKeys={Object.keys(values.properties ?? {})}\n onPropertyChanged={({ id, property }) => {\n const newProperties = {\n ...values.properties,\n [id!]: property\n };\n const newPropertiesOrder = [...(values.propertiesOrder ?? Object.keys(values.properties ?? {})), id];\n setFieldValue(\"properties\", newProperties);\n setFieldValue(\"propertiesOrder\", newPropertiesOrder);\n setFieldValue(\"orderProperty\", id);\n setOrderPropertyDialogOpen(false);\n }}\n />\n </>\n );\n })()}\n </div>\n\n {/* Default row size */}\n <div className={\"col-span-12\"}>\n <Select\n name=\"defaultSize\"\n fullWidth={true}\n label=\"Default row size\"\n position={\"item-aligned\"}\n onChange={handleChange}\n value={values.defaultSize ?? \"\"}\n renderValue={(value: string) => value.toUpperCase()}\n >\n {[\"xs\", \"s\", \"m\", \"l\", \"xl\"].map((value) => (\n <SelectItem\n key={`size-select-${value}`}\n value={value}>\n {value.toUpperCase()}\n </SelectItem>\n ))}\n </Select>\n </div>\n\n {/* Side dialog width */}\n <div className={\"col-span-12\"}>\n <TextField\n name={\"sideDialogWidth\"}\n type={\"number\"}\n aria-describedby={\"sideDialogWidth-helper\"}\n onChange={(e) => {\n const value = e.target.value;\n if (!value) {\n setFieldValue(\"sideDialogWidth\", null);\n } else if (!isNaN(Number(value))) {\n setFieldValue(\"sideDialogWidth\", Number(value));\n }\n }}\n endAdornment={<IconButton aria-label={t(\"clear\")}\n size={\"small\"}\n onClick={() => {\n setFieldValue(\"sideDialogWidth\", null);\n }}\n disabled={!values.sideDialogWidth}>\n <XIcon size={iconSize.small}/>\n </IconButton>}\n value={values.sideDialogWidth ?? \"\"}\n label={\"Side dialog width\"}/>\n <FieldCaption>\n Optionally define the width (in pixels) of entities side dialog. Default is 768px\n </FieldCaption>\n </div>\n\n {/* Inline editing */}\n <div className={\"col-span-12\"}>\n <BooleanSwitchWithLabel\n position={\"start\"}\n label={values.inlineEditing === undefined || values.inlineEditing ? \"Data can be edited directly in the table view\" : \"Data can be edited only in the form view\"}\n onValueChange={(v) => setFieldValue(\"inlineEditing\", v)}\n value={values.inlineEditing === undefined ? true : values.inlineEditing}\n />\n <FieldCaption>\n Allow editing data directly in the table view, without opening the form view.\n </FieldCaption>\n </div>\n\n {/* Include JSON view */}\n <div className={\"col-span-12\"}>\n <BooleanSwitchWithLabel\n position={\"start\"}\n label={values.includeJsonView === undefined || values.includeJsonView ? \"Include JSON view\" : \"Do not include JSON view\"}\n onValueChange={(v) => setFieldValue(\"includeJsonView\", v)}\n value={values.includeJsonView === undefined ? true : values.includeJsonView}\n />\n <FieldCaption>\n Allows removing the form view JSON tab if you think it is confusing for your users.\n </FieldCaption>\n </div>\n\n </div>\n </fieldset>\n\n <div style={{ height: \"52px\" }}/>\n\n </Container>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AA6BA,SAAgB,oBAAoB,EAChC,cACA,cAID;CACC,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,EACF,QACA,eACA,cACA,gBACA,UAA2B;CAE/B,MAAM,CAAC,yBAAyB,8BAA8B,SAAS,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AAoB,KAAA,KAAa,OAAO,kBAAkB,sBAAsB;SAC9F,gBAAgB,MAAM,cAAc,mBAAmB,CAAC;SACxD,OAAO,OAAO,oBAAoB,KAAA,IAAY,OAAO,OAAO;QAC/D,CAAA,GACD,oBAAC,cAAD,EAAA,UAAc,sFAEA,CAAA,CACb;;MAEJ;;IACC,CAAA;IAEV,oBAAC,OAAD,EAAK,OAAO,EAAE,QAAQ,OAAO,EAAG,CAAA;GAEzB;;CACV,CAAA;AAEb"}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { EnumValueConfig } from "@rebasepro/types";
2
+ import { EnumValueConfig } from "@rebasepro/cms-types";
3
3
  type EnumFormProps = {
4
4
  enumValues: EnumValueConfig[];
5
5
  onValuesChanged?: (enumValues: EnumValueConfig[]) => void;