@rebasepro/cms 0.30.0 → 0.31.0-canary.g59cd6fd
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.
- package/README.md +8 -8
- package/dist/collection_editor/ConfigControllerProvider.js +25 -22
- package/dist/collection_editor/ConfigControllerProvider.js.map +1 -1
- package/dist/collection_editor/firestore_callee.d.ts +10 -0
- package/dist/collection_editor/firestore_callee.js +15 -0
- package/dist/collection_editor/firestore_callee.js.map +1 -0
- package/dist/collection_editor/firestore_edit.d.ts +62 -0
- package/dist/collection_editor/firestore_edit.js +339 -0
- package/dist/collection_editor/firestore_edit.js.map +1 -0
- package/dist/collection_editor/index.d.ts +2 -3
- package/dist/collection_editor/liveSchemaClient.d.ts +44 -22
- package/dist/collection_editor/liveSchemaClient.js +9 -3
- package/dist/collection_editor/liveSchemaClient.js.map +1 -1
- package/dist/collection_editor/property_column.d.ts +86 -0
- package/dist/collection_editor/property_column.js +719 -0
- package/dist/collection_editor/property_column.js.map +1 -0
- package/dist/collection_editor/serializable_types.d.ts +2 -24
- package/dist/collection_editor/serializable_utils.d.ts +1 -1
- package/dist/collection_editor/serializable_utils.js +2 -1
- package/dist/collection_editor/serializable_utils.js.map +1 -1
- package/dist/collection_editor/split_edit.d.ts +106 -0
- package/dist/collection_editor/split_edit.js +564 -0
- package/dist/collection_editor/split_edit.js.map +1 -0
- package/dist/collection_editor/split_edit_error.d.ts +25 -0
- package/dist/collection_editor/split_edit_error.js +35 -0
- package/dist/collection_editor/split_edit_error.js.map +1 -0
- package/dist/collection_editor/types/collection_editor_controller.d.ts +1 -1
- package/dist/collection_editor/types/config_controller.d.ts +67 -1
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.d.ts +6 -5
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js +44 -12
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js +18 -3
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js +94 -55
- package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/CollectionRelationsTab.d.ts +2 -1
- package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/EnumForm.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js +3 -3
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.d.ts +2 -3
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.js +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyTree.d.ts +7 -4
- package/dist/collection_editor/ui/collection_editor/PropertyTree.js +15 -5
- package/dist/collection_editor/ui/collection_editor/PropertyTree.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.d.ts +20 -0
- package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js +74 -0
- package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/conditions/ConditionsEditor.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/conditions/EnumConditionsEditor.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/conditions/property_paths.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/rlsRuleForm.d.ts +34 -0
- package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js +50 -0
- package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.d.ts +1 -2
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js.map +1 -1
- package/dist/collection_editor/useDetachRulesConfirmation.d.ts +16 -0
- package/dist/collection_editor/useDetachRulesConfirmation.js +48 -0
- package/dist/collection_editor/useDetachRulesConfirmation.js.map +1 -0
- package/dist/collection_editor/useLiveSchemaEditing.d.ts +2 -2
- package/dist/collection_editor/useLiveSchemaEditing.js +1 -1
- package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -1
- package/dist/collection_editor/useLocalCollectionsConfigController.d.ts +54 -10
- package/dist/collection_editor/useLocalCollectionsConfigController.js +394 -122
- package/dist/collection_editor/useLocalCollectionsConfigController.js.map +1 -1
- package/dist/collection_editor/validateCollectionJson.js.map +1 -1
- package/dist/components/CollectionPanel.d.ts +10 -9
- package/dist/components/CollectionPanel.js +5 -2
- package/dist/components/CollectionPanel.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +1 -2
- package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +3 -5
- package/dist/components/CollectionTableBinding/PropertyTableCell.d.ts +2 -2
- package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
- package/dist/components/CollectionTableBinding/column_utils.d.ts +1 -1
- package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +1 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationField.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js +1 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.d.ts +2 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableStorageUpload.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.d.ts +1 -1
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js +1 -1
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/common.d.ts +1 -2
- package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +2 -2
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
- package/dist/components/CollectionTableBinding/table_bindings.d.ts +2 -2
- package/dist/components/CollectionTableBinding/table_bindings.js.map +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -5
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +1 -1
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.js +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +2 -4
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +6 -6
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewContent.js +1 -2
- package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntitiesCount.js +3 -3
- package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -1
- package/dist/components/CollectionViewBinding/FilterPresetsButton.d.ts +1 -2
- package/dist/components/CollectionViewBinding/FilterPresetsButton.js +1 -1
- package/dist/components/CollectionViewBinding/FilterPresetsButton.js.map +1 -1
- package/dist/components/CollectionViewBinding/FiltersButton.d.ts +1 -2
- package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -1
- package/dist/components/CollectionViewBinding/FiltersDialog.d.ts +1 -1
- package/dist/components/CollectionViewBinding/FiltersDialog.js.map +1 -1
- package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +1 -2
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/RowActions.d.ts +1 -2
- package/dist/components/CollectionViewBinding/RowActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/SortButton.d.ts +1 -1
- package/dist/components/CollectionViewBinding/SortButton.js.map +1 -1
- package/dist/components/CollectionViewBinding/SplitListView.d.ts +1 -2
- package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.d.ts +1 -2
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js +1 -1
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js.map +1 -1
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.d.ts +1 -2
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js.map +1 -1
- package/dist/components/CollectionViewBinding/useBoardDataController.d.ts +2 -1
- package/dist/components/CollectionViewBinding/useBoardDataController.js +3 -3
- package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
- package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +2 -4
- package/dist/components/CollectionViewBinding/useCollectionViewState.js +14 -19
- package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -1
- package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +1 -3
- package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/useSelectionController.d.ts +1 -2
- package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
- package/dist/components/CollectionsProvider.d.ts +23 -8
- package/dist/components/CollectionsProvider.js +23 -7
- package/dist/components/CollectionsProvider.js.map +1 -1
- package/dist/components/DefaultDrawer.js +1 -1
- package/dist/components/DeleteEntityDialog.d.ts +1 -1
- package/dist/components/DeleteEntityDialog.js +1 -1
- package/dist/components/DeleteEntityDialog.js.map +1 -1
- package/dist/components/DetailViewBinding.js +3 -3
- package/dist/components/DetailViewBinding.js.map +1 -1
- package/dist/components/EditFormActions.js.map +1 -1
- package/dist/components/EditViewBinding.d.ts +2 -1
- package/dist/components/EditViewBinding.js +6 -6
- package/dist/components/EditViewBinding.js.map +1 -1
- package/dist/components/EntityDisplayHeader.d.ts +1 -2
- package/dist/components/EntityDisplayHeader.js.map +1 -1
- package/dist/components/EntityInspector.d.ts +1 -2
- package/dist/components/EntityInspector.js.map +1 -1
- package/dist/components/EntityPreviewBinding.d.ts +1 -1
- package/dist/components/EntityPreviewBinding.js +1 -1
- package/dist/components/EntityPreviewBinding.js.map +1 -1
- package/dist/components/EntityViewBinding.d.ts +1 -1
- package/dist/components/EntityViewBinding.js.map +1 -1
- package/dist/components/EntityViewBody.d.ts +1 -1
- package/dist/components/EntityViewBody.js +3 -4
- package/dist/components/EntityViewBody.js.map +1 -1
- package/dist/components/FieldValue.js +2 -2
- package/dist/components/FieldValue.js.map +1 -1
- package/dist/components/HomePage/ContentHomePage.js +12 -3
- package/dist/components/HomePage/ContentHomePage.js.map +1 -1
- package/dist/components/InlineEntityPreview.d.ts +1 -1
- package/dist/components/InlineEntityPreview.js.map +1 -1
- package/dist/components/PropertyCollectionView.d.ts +2 -2
- package/dist/components/PropertyCollectionView.js.map +1 -1
- package/dist/components/PropertyConfigBadge.js.map +1 -1
- package/dist/components/RebaseCMS.d.ts +22 -3
- package/dist/components/RebaseCMS.js +32 -14
- package/dist/components/RebaseCMS.js.map +1 -1
- package/dist/components/RebaseNavigation.js +106 -31
- package/dist/components/RebaseNavigation.js.map +1 -1
- package/dist/components/RecordDetail.js +4 -1
- package/dist/components/RecordDetail.js.map +1 -1
- package/dist/components/RecordForm.d.ts +5 -5
- package/dist/components/RecordForm.js +5 -2
- package/dist/components/RecordForm.js.map +1 -1
- package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +2 -2
- package/dist/components/ReferenceTable/SelectionTableBinding.js +1 -1
- package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
- package/dist/components/ReferenceWidget.d.ts +2 -1
- package/dist/components/ReferenceWidget.js +2 -2
- package/dist/components/ReferenceWidget.js.map +1 -1
- package/dist/components/RelationSelector.d.ts +2 -1
- package/dist/components/RelationSelector.js +2 -3
- package/dist/components/RelationSelector.js.map +1 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +2 -2
- package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
- package/dist/components/SelectableTable/filters/FilterFieldBinding.d.ts +2 -1
- package/dist/components/SelectableTable/filters/FilterFieldBinding.js +3 -3
- package/dist/components/SelectableTable/filters/FilterFieldBinding.js.map +1 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js +2 -2
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -1
- package/dist/components/SelectableTable/filters/RelationFilterField.d.ts +1 -1
- package/dist/components/SelectableTable/filters/RelationFilterField.js +1 -1
- package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -1
- package/dist/components/SelectableTable/filters/StringNumberFilterField.d.ts +1 -1
- package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -1
- package/dist/components/SelectableTable/filters/null_filter.d.ts +1 -3
- package/dist/components/SelectableTable/filters/null_filter.js.map +1 -1
- package/dist/components/SidePanelBinding.js +1 -1
- package/dist/components/SidePanelBinding.js.map +1 -1
- package/dist/components/field_configs.d.ts +1 -2
- package/dist/components/field_configs.js.map +1 -1
- package/dist/components/field_ids.d.ts +1 -1
- package/dist/components/field_ids.js +1 -1
- package/dist/components/field_ids.js.map +1 -1
- package/dist/components/history/EntityHistoryEntry.js.map +1 -1
- package/dist/components/history/EntityHistoryView.d.ts +1 -2
- package/dist/components/history/EntityHistoryView.js +1 -1
- package/dist/components/history/EntityHistoryView.js.map +1 -1
- package/dist/data_export/export/BasicExportAction.d.ts +1 -1
- package/dist/data_export/export/BasicExportAction.js.map +1 -1
- package/dist/data_export/export/ExportCollectionAction.js +2 -2
- package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
- package/dist/data_export/export/additional_fields.d.ts +1 -1
- package/dist/data_export/export/additional_fields.js.map +1 -1
- package/dist/data_export/export/export.d.ts +1 -1
- package/dist/data_export/export/export.js +1 -1
- package/dist/data_export/export/export.js.map +1 -1
- package/dist/data_export/export/fetch_export_data.d.ts +3 -2
- package/dist/data_export/export/fetch_export_data.js.map +1 -1
- package/dist/data_import/components/DataNewPropertiesMapping.d.ts +1 -1
- package/dist/data_import/components/DataNewPropertiesMapping.js.map +1 -1
- package/dist/data_import/components/ImportNewPropertyFieldPreview.d.ts +1 -1
- package/dist/data_import/components/ImportNewPropertyFieldPreview.js.map +1 -1
- package/dist/data_import/hooks/useImportConfig.js.map +1 -1
- package/dist/data_import/import/ImportCollectionAction.d.ts +2 -2
- package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
- package/dist/data_import/types/column_mapping.d.ts +1 -1
- package/dist/data_import/utils/data.d.ts +1 -2
- package/dist/data_import/utils/data.js +1 -2
- package/dist/data_import/utils/data.js.map +1 -1
- package/dist/data_import/utils/get_import_inference_type.d.ts +1 -1
- package/dist/data_import/utils/get_import_inference_type.js.map +1 -1
- package/dist/data_import/utils/id_column.d.ts +1 -1
- package/dist/data_import/utils/id_column.js.map +1 -1
- package/dist/data_import/utils/import_columns.d.ts +1 -1
- package/dist/data_import/utils/import_columns.js.map +1 -1
- package/dist/data_import/utils/save_entities.d.ts +3 -3
- package/dist/data_import/utils/save_entities.js +1 -1
- package/dist/data_import/utils/save_entities.js.map +1 -1
- package/dist/form/EntityForm.js +2 -1
- package/dist/form/EntityForm.js.map +1 -1
- package/dist/form/EntityFormActions.js.map +1 -1
- package/dist/form/EntityFormBinding.js +2 -2
- package/dist/form/EntityFormBinding.js.map +1 -1
- package/dist/form/FormFieldsContext.d.ts +1 -4
- package/dist/form/FormFieldsContext.js +1 -1
- package/dist/form/FormFieldsContext.js.map +1 -1
- package/dist/form/PropertyFieldBinding.js +6 -8
- package/dist/form/PropertyFieldBinding.js.map +1 -1
- package/dist/form/components/FieldBlock.d.ts +1 -2
- package/dist/form/components/FieldBlock.js.map +1 -1
- package/dist/form/components/FieldHelperText.d.ts +1 -1
- package/dist/form/components/FieldHelperText.js.map +1 -1
- package/dist/form/components/FormRail.d.ts +1 -1
- package/dist/form/components/FormRail.js.map +1 -1
- package/dist/form/components/LocalChangesMenu.d.ts +1 -1
- package/dist/form/components/LocalChangesMenu.js.map +1 -1
- package/dist/form/components/StorageItemPreview.d.ts +1 -1
- package/dist/form/components/StorageItemPreview.js.map +1 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js +1 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/BinaryFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.js +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/DateTimeFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/GeopointFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.js +1 -2
- package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MapFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MultiSelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MultiSelectFieldBinding.js +1 -1
- package/dist/form/field_bindings/MultiSelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MultipleRelationFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.js +2 -2
- package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/RelationFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/RelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.js +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.js +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +2 -2
- package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/SwitchFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/UserSelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/UserSelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/VectorFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/VectorFieldBinding.js.map +1 -1
- package/dist/form/form_utils.d.ts +3 -3
- package/dist/form/form_utils.js +1 -2
- package/dist/form/form_utils.js.map +1 -1
- package/dist/form/label_placement.d.ts +1 -2
- package/dist/form/label_placement.js.map +1 -1
- package/dist/form/resolve_cell_property.d.ts +1 -2
- package/dist/form/resolve_cell_property.js +1 -1
- package/dist/form/resolve_cell_property.js.map +1 -1
- package/dist/form/resolve_form_properties.d.ts +2 -2
- package/dist/form/resolve_form_properties.js +1 -1
- package/dist/form/resolve_form_properties.js.map +1 -1
- package/dist/form/useClearRestoreValue.d.ts +1 -1
- package/dist/form/useClearRestoreValue.js.map +1 -1
- package/dist/form/validation.d.ts +2 -2
- package/dist/form/validation.js +1 -1
- package/dist/form/validation.js.map +1 -1
- package/dist/hooks/navigation/compose_collections.d.ts +59 -0
- package/dist/hooks/navigation/compose_collections.js +48 -0
- package/dist/hooks/navigation/compose_collections.js.map +1 -0
- package/dist/hooks/navigation/compose_collections_input.d.ts +8 -0
- package/dist/hooks/navigation/compose_collections_input.js +17 -0
- package/dist/hooks/navigation/compose_collections_input.js.map +1 -0
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +1 -1
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.js.map +1 -1
- package/dist/hooks/navigation/registered_collection.d.ts +15 -0
- package/dist/hooks/navigation/registered_collection.js +20 -0
- package/dist/hooks/navigation/registered_collection.js.map +1 -0
- package/dist/hooks/navigation/ui_preferences.d.ts +47 -0
- package/dist/hooks/navigation/ui_preferences.js +179 -0
- package/dist/hooks/navigation/ui_preferences.js.map +1 -0
- package/dist/hooks/navigation/useAsyncResolver.d.ts +8 -1
- package/dist/hooks/navigation/useAsyncResolver.js +9 -3
- package/dist/hooks/navigation/useAsyncResolver.js.map +1 -1
- package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +1 -3
- package/dist/hooks/navigation/useBuildCollectionRegistryController.js +3 -3
- package/dist/hooks/navigation/useBuildCollectionRegistryController.js.map +1 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +9 -5
- package/dist/hooks/navigation/useBuildNavigationStateController.js +2 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
- package/dist/hooks/navigation/useBuildUrlController.d.ts +1 -1
- package/dist/hooks/navigation/useBuildUrlController.js.map +1 -1
- package/dist/hooks/navigation/useNavigationResolution.js +1 -2
- package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
- package/dist/hooks/navigation/usePanelTables.d.ts +11 -0
- package/dist/hooks/navigation/usePanelTables.js +33 -0
- package/dist/hooks/navigation/usePanelTables.js.map +1 -0
- package/dist/hooks/navigation/useResolvedCollections.d.ts +8 -3
- package/dist/hooks/navigation/useResolvedCollections.js +3 -2
- package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
- package/dist/hooks/navigation/useResolvedViews.d.ts +1 -2
- package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
- package/dist/hooks/navigation/useTopLevelNavigation.d.ts +1 -2
- package/dist/hooks/navigation/useTopLevelNavigation.js.map +1 -1
- package/dist/hooks/navigation/user_preferences_overlay.d.ts +21 -0
- package/dist/hooks/navigation/user_preferences_overlay.js +101 -0
- package/dist/hooks/navigation/user_preferences_overlay.js.map +1 -0
- package/dist/hooks/navigation/utils.js +1 -1
- package/dist/hooks/navigation/utils.js.map +1 -1
- package/dist/hooks/useAdminContext.d.ts +1 -2
- package/dist/hooks/useAdminContext.js.map +1 -1
- package/dist/hooks/useBuildSidePanel.d.ts +1 -2
- package/dist/hooks/useBuildSidePanel.js +2 -1
- package/dist/hooks/useBuildSidePanel.js.map +1 -1
- package/dist/hooks/useChildViewSource.d.ts +1 -1
- package/dist/hooks/useChildViewSource.js +1 -1
- package/dist/hooks/useChildViewSource.js.map +1 -1
- package/dist/hooks/useEntityDisplay.d.ts +1 -2
- package/dist/hooks/useEntityDisplay.js +1 -1
- package/dist/hooks/useEntityDisplay.js.map +1 -1
- package/dist/hooks/useEntityDisplayTitle.d.ts +2 -2
- package/dist/hooks/useEntityDisplayTitle.js.map +1 -1
- package/dist/hooks/useHistory.js +1 -1
- package/dist/hooks/useHistory.js.map +1 -1
- package/dist/hooks/useRecordActions.d.ts +1 -2
- package/dist/hooks/useRecordActions.js.map +1 -1
- package/dist/hooks/useReferencePaths.d.ts +21 -7
- package/dist/hooks/useReferencePaths.js +23 -6
- package/dist/hooks/useReferencePaths.js.map +1 -1
- package/dist/hooks/useResolvedNavigationFrom.d.ts +3 -3
- package/dist/hooks/useResolvedNavigationFrom.js +1 -1
- package/dist/hooks/useResolvedNavigationFrom.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +8 -2
- package/dist/mcp_view/app_modules.d.ts +2 -2
- package/dist/mcp_view/app_modules.js +4 -4
- package/dist/mcp_view/app_modules.js.map +1 -1
- package/dist/mcp_view/index.d.ts +16 -19
- package/dist/mcp_view/index.js +43 -62
- package/dist/mcp_view/index.js.map +1 -1
- package/dist/mcp_view/payload.d.ts +54 -18
- package/dist/mcp_view/payload.js +49 -24
- package/dist/mcp_view/payload.js.map +1 -1
- package/dist/mcp_view/screen.js +11 -11
- package/dist/mcp_view/screen.js.map +1 -1
- package/dist/mcp_view/tool_driver.d.ts +5 -34
- package/dist/mcp_view/tool_driver.js +17 -16
- package/dist/mcp_view/tool_driver.js.map +1 -1
- package/dist/mcp_view/write_review.d.ts +1 -2
- package/dist/mcp_view/write_review.js +1 -1
- package/dist/mcp_view/write_review.js.map +1 -1
- package/dist/preview/PropertyPreview.d.ts +1 -1
- package/dist/preview/PropertyPreview.js +4 -3
- package/dist/preview/PropertyPreview.js.map +1 -1
- package/dist/preview/components/ArrayEnumPreview.d.ts +1 -1
- package/dist/preview/components/ArrayEnumPreview.js.map +1 -1
- package/dist/preview/components/BooleanPreview.d.ts +1 -1
- package/dist/preview/components/BooleanPreview.js.map +1 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/EnumValuesChip.js +1 -1
- package/dist/preview/components/EnumValuesChip.js.map +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.js.map +1 -1
- package/dist/preview/components/RelationPreview.d.ts +1 -1
- package/dist/preview/components/RelationPreview.js.map +1 -1
- package/dist/preview/components/StorageThumbnail.js +2 -1
- package/dist/preview/components/StorageThumbnail.js.map +1 -1
- package/dist/preview/components/UserPreview.d.ts +1 -1
- package/dist/preview/components/UserPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfMapsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfMapsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfReferencesPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfReferencesPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfRelationsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfRelationsPreview.js +2 -1
- package/dist/preview/property_previews/ArrayOfRelationsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfStringsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfStringsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOneOfPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOneOfPreview.js +1 -1
- package/dist/preview/property_previews/ArrayOneOfPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.js +1 -1
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayPropertyPreview.js +1 -1
- package/dist/preview/property_previews/ArrayPropertyPreview.js.map +1 -1
- package/dist/preview/property_previews/MapPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/MapPropertyPreview.js.map +1 -1
- package/dist/preview/property_previews/NumberPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/NumberPropertyPreview.js +1 -1
- package/dist/preview/property_previews/NumberPropertyPreview.js.map +1 -1
- package/dist/preview/property_previews/SkeletonPropertyComponent.d.ts +1 -1
- package/dist/preview/property_previews/SkeletonPropertyComponent.js.map +1 -1
- package/dist/preview/property_previews/StringPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/StringPropertyPreview.js.map +1 -1
- package/dist/preview/util.d.ts +1 -1
- package/dist/preview/util.js.map +1 -1
- package/dist/routes/RebaseRoute.js +2 -2
- package/dist/routes/RebaseRoute.js.map +1 -1
- package/dist/saved_apps/SavedAppsView.d.ts +1 -1
- package/dist/saved_apps/SavedAppsView.js +1 -1
- package/dist/saved_apps/SavedAppsView.js.map +1 -1
- package/dist/selection/SelectionMenu.d.ts +1 -1
- package/dist/selection/SelectionMenu.js.map +1 -1
- package/dist/selection/resolve_selection.d.ts +3 -3
- package/dist/selection/resolve_selection.js +3 -2
- package/dist/selection/resolve_selection.js.map +1 -1
- package/dist/tables/apply_customization.d.ts +65 -0
- package/dist/tables/apply_customization.js +644 -0
- package/dist/tables/apply_customization.js.map +1 -0
- package/dist/tables/column_property.d.ts +64 -0
- package/dist/tables/column_property.js +549 -0
- package/dist/tables/column_property.js.map +1 -0
- package/dist/tables/customize_table.d.ts +39 -0
- package/dist/tables/customize_table.js +247 -0
- package/dist/tables/customize_table.js.map +1 -0
- package/dist/tables/index.d.ts +12 -0
- package/dist/tables/labels.d.ts +18 -0
- package/dist/tables/labels.js +18 -0
- package/dist/tables/labels.js.map +1 -0
- package/dist/tables/project_table.d.ts +79 -0
- package/dist/tables/project_table.js +148 -0
- package/dist/tables/project_table.js.map +1 -0
- package/dist/tables/relations.d.ts +47 -0
- package/dist/tables/relations.js +112 -0
- package/dist/tables/relations.js.map +1 -0
- package/dist/tables/rls.d.ts +39 -0
- package/dist/tables/rls.js +111 -0
- package/dist/tables/rls.js.map +1 -0
- package/dist/tables/update_record.d.ts +32 -0
- package/dist/tables/update_record.js +40 -0
- package/dist/tables/update_record.js.map +1 -0
- package/dist/types/components/EntityFormActionsProps.d.ts +1 -1
- package/dist/types/components/PropertyPreviewProps.d.ts +2 -2
- package/dist/types/fields.d.ts +2 -2
- package/dist/util/dataControllerAdapter.js.map +1 -1
- package/dist/util/entity_pages.d.ts +2 -1
- package/dist/util/entity_pages.js.map +1 -1
- package/dist/util/find_entities_by_ids.d.ts +2 -2
- package/dist/util/find_entities_by_ids.js +1 -1
- package/dist/util/find_entities_by_ids.js.map +1 -1
- package/dist/util/format_collection_date.d.ts +1 -1
- package/dist/util/format_collection_date.js.map +1 -1
- package/dist/util/identity.d.ts +8 -0
- package/dist/util/identity.js +16 -0
- package/dist/util/identity.js.map +1 -0
- package/dist/util/navigation_utils.js +1 -1
- package/dist/util/navigation_utils.js.map +1 -1
- package/dist/util/previews.js +1 -1
- package/dist/util/previews.js.map +1 -1
- package/dist/util/propertyConfigMapper.d.ts +1 -1
- package/dist/util/propertyConfigMapper.js.map +1 -1
- package/dist/util/property_utils.d.ts +1 -3
- package/dist/util/property_utils.js +1 -1
- package/dist/util/property_utils.js.map +1 -1
- package/dist/util/relations.d.ts +18 -0
- package/dist/util/relations.js +32 -0
- package/dist/util/relations.js.map +1 -0
- package/package.json +12 -10
- package/recipes/README.md +4 -4
- package/recipes/my-preferences.tsx +34 -26
- package/recipes/site-settings.tsx +34 -27
- package/dist/collection_editor/collection_wire.d.ts +0 -13
- package/dist/collection_editor/collection_wire.js +0 -49
- package/dist/collection_editor/collection_wire.js.map +0 -1
- package/dist/collection_editor/useJsonCollectionsConfigController.d.ts +0 -37
- package/dist/collection_editor/useJsonCollectionsConfigController.js +0 -191
- package/dist/collection_editor/useJsonCollectionsConfigController.js.map +0 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { policyToPostgres } from "@rebasepro/cms-types";
|
|
2
|
+
import { isPolicyShorthand, isRedactedSecurityRule } from "@rebasepro/types";
|
|
3
|
+
import { policyConditionToExpression } from "@rebasepro/common";
|
|
4
|
+
//#region src/collection_editor/ui/collection_editor/rlsRuleForm.ts
|
|
5
|
+
/** The {@link RlsRuleForm} of a declared rule. */
|
|
6
|
+
function rlsRuleForm(rule) {
|
|
7
|
+
if (isRedactedSecurityRule(rule)) return "redacted";
|
|
8
|
+
if (rule.using != null || rule.withCheck != null) return "raw";
|
|
9
|
+
if (rule.ownerField != null) return "owner";
|
|
10
|
+
if (rule.access !== void 0) {
|
|
11
|
+
if (rule.condition != null || rule.check != null) return "conditional_access";
|
|
12
|
+
if (rule.access === "authenticated") return "authenticated";
|
|
13
|
+
return rule.access === "registered" ? "registered" : "public";
|
|
14
|
+
}
|
|
15
|
+
if (isPolicyShorthand(rule.condition) || isPolicyShorthand(rule.check)) return "shorthand";
|
|
16
|
+
if (rule.condition != null || rule.check != null) return "structured";
|
|
17
|
+
return "roles_only";
|
|
18
|
+
}
|
|
19
|
+
/** Whether the tab's form can edit a rule of this form without losing what it says. */
|
|
20
|
+
function isEditableInForm(form) {
|
|
21
|
+
switch (form) {
|
|
22
|
+
case "raw":
|
|
23
|
+
case "owner":
|
|
24
|
+
case "public":
|
|
25
|
+
case "structured":
|
|
26
|
+
case "roles_only": return true;
|
|
27
|
+
case "shorthand":
|
|
28
|
+
case "conditional_access":
|
|
29
|
+
case "authenticated":
|
|
30
|
+
case "registered":
|
|
31
|
+
case "redacted": return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A condition / check as the SQL it compiles to — a shorthand
|
|
36
|
+
* `{ status: "published" }` reads `status = 'published'`, with each key
|
|
37
|
+
* resolved to its column. Falls back to the condition as JSON when it does
|
|
38
|
+
* not compile (an invalid object), so a listing never throws.
|
|
39
|
+
*/
|
|
40
|
+
function describeCondition(condition, collection) {
|
|
41
|
+
try {
|
|
42
|
+
return policyToPostgres(policyConditionToExpression(condition), collection);
|
|
43
|
+
} catch {
|
|
44
|
+
return JSON.stringify(condition);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { describeCondition, isEditableInForm, rlsRuleForm };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=rlsRuleForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rlsRuleForm.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/rlsRuleForm.ts"],"sourcesContent":["import { isPolicyShorthand, isRedactedSecurityRule } from \"@rebasepro/types\";\nimport type {\n AuthenticatedSecurityRule,\n CheckedAccessSecurityRule,\n ConditionalAccessSecurityRule,\n OwnerSecurityRule,\n PolicyCondition,\n PublicSecurityRule,\n RawSQLCheckOnlySecurityRule,\n RawSQLSecurityRule,\n RedactedSecurityRule,\n RegisteredSecurityRule,\n RolesOnlySecurityRule,\n SecurityRule,\n StructuredSecurityRule\n} from \"@rebasepro/types\";\nimport type {\n CollectionConfig\n} from \"@rebasepro/cms-types\";\nimport { policyConditionToExpression } from \"@rebasepro/common\";\nimport { policyToPostgres } from \"@rebasepro/cms-types\";\n\n/**\n * Which form a declared rule is written in, as the RLS tab sees it.\n *\n * The tab's form edits a rule as a policy — name, command, mode, roles and\n * raw USING / WITH CHECK — and writes back only the fields it changed. For\n * the forms it has always handled (`raw`, `owner`, `public`, a structured\n * `PolicyExpression` condition, `roles_only`) that is enough. The forms below\n * it has no field for, and opened in it they would show empty clauses that a\n * save could only replace:\n *\n * - `shorthand`: a `PolicyShorthand` condition / check (`{ status: \"published\" }`);\n * - `conditional_access`: `access` together with a condition / check;\n * - `authenticated`: bare `access: \"authenticated\"`;\n * - `registered`: bare `access: \"registered\"`;\n * - `redacted`: the server withheld the rule's clauses from this caller.\n *\n * Those are shown read-only (see {@link isEditableInForm}): listed with what\n * they mean, and saved exactly as written — rewriting one into another shape\n * would rename its policy.\n */\nexport type RlsRuleForm =\n | \"raw\" | \"owner\" | \"public\" | \"structured\" | \"roles_only\"\n | \"shorthand\" | \"conditional_access\" | \"authenticated\" | \"registered\" | \"redacted\";\n\n/**\n * Every `SecurityRule` member {@link rlsRuleForm} classifies. A member added\n * to the union and not listed here fails to compile at\n * {@link RULE_FORMS_COVER_THE_UNION} — the one place to decide how the tab\n * treats it.\n */\ntype ClassifiedRule =\n | OwnerSecurityRule | PublicSecurityRule | AuthenticatedSecurityRule | RegisteredSecurityRule\n | ConditionalAccessSecurityRule | CheckedAccessSecurityRule | StructuredSecurityRule\n | RawSQLSecurityRule | RawSQLCheckOnlySecurityRule | RolesOnlySecurityRule | RedactedSecurityRule;\nconst RULE_FORMS_COVER_THE_UNION: [Exclude<SecurityRule, ClassifiedRule>] extends [never] ? true : false = true;\nvoid RULE_FORMS_COVER_THE_UNION;\n\n/** The {@link RlsRuleForm} of a declared rule. */\nexport function rlsRuleForm(rule: SecurityRule): RlsRuleForm {\n if (isRedactedSecurityRule(rule)) return \"redacted\";\n if (rule.using != null || rule.withCheck != null) return \"raw\";\n if (rule.ownerField != null) return \"owner\";\n if (rule.access !== undefined) {\n if (rule.condition != null || rule.check != null) return \"conditional_access\";\n if (rule.access === \"authenticated\") return \"authenticated\";\n return rule.access === \"registered\" ? \"registered\" : \"public\";\n }\n if (isPolicyShorthand(rule.condition) || isPolicyShorthand(rule.check)) return \"shorthand\";\n if (rule.condition != null || rule.check != null) return \"structured\";\n return \"roles_only\";\n}\n\n/** Whether the tab's form can edit a rule of this form without losing what it says. */\nexport function isEditableInForm(form: RlsRuleForm): boolean {\n switch (form) {\n case \"raw\":\n case \"owner\":\n case \"public\":\n case \"structured\":\n case \"roles_only\":\n return true;\n case \"shorthand\":\n case \"conditional_access\":\n case \"authenticated\":\n case \"registered\":\n case \"redacted\":\n return false;\n }\n}\n\n/**\n * A condition / check as the SQL it compiles to — a shorthand\n * `{ status: \"published\" }` reads `status = 'published'`, with each key\n * resolved to its column. Falls back to the condition as JSON when it does\n * not compile (an invalid object), so a listing never throws.\n */\nexport function describeCondition(condition: PolicyCondition, collection?: CollectionConfig): string {\n try {\n return policyToPostgres(policyConditionToExpression(condition), collection);\n } catch {\n return JSON.stringify(condition);\n }\n}\n"],"mappings":";;;;;AA4DA,SAAgB,YAAY,MAAiC;CACzD,IAAI,uBAAuB,IAAI,GAAG,OAAO;CACzC,IAAI,KAAK,SAAS,QAAQ,KAAK,aAAa,MAAM,OAAO;CACzD,IAAI,KAAK,cAAc,MAAM,OAAO;CACpC,IAAI,KAAK,WAAW,KAAA,GAAW;EAC3B,IAAI,KAAK,aAAa,QAAQ,KAAK,SAAS,MAAM,OAAO;EACzD,IAAI,KAAK,WAAW,iBAAiB,OAAO;EAC5C,OAAO,KAAK,WAAW,eAAe,eAAe;CACzD;CACA,IAAI,kBAAkB,KAAK,SAAS,KAAK,kBAAkB,KAAK,KAAK,GAAG,OAAO;CAC/E,IAAI,KAAK,aAAa,QAAQ,KAAK,SAAS,MAAM,OAAO;CACzD,OAAO;AACX;;AAGA,SAAgB,iBAAiB,MAA4B;CACzD,QAAQ,MAAR;EACI,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,cACD,OAAO;EACX,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,YACD,OAAO;CACf;AACJ;;;;;;;AAQA,SAAgB,kBAAkB,WAA4B,YAAuC;CACjG,IAAI;EACA,OAAO,iBAAiB,4BAA4B,SAAS,GAAG,UAAU;CAC9E,QAAQ;EACJ,OAAO,KAAK,UAAU,SAAS;CACnC;AACJ"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { Property } from "@rebasepro/types";
|
|
2
|
-
import { PropertyConfig } from "@rebasepro/cms-types";
|
|
1
|
+
import { PropertyConfig, Property } from "@rebasepro/cms-types";
|
|
3
2
|
export declare function updatePropertyFromWidget(propertyData: any, selectedWidgetId: string | undefined, propertyConfigs: Record<string, PropertyConfig>): Property;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update_property_for_widget.js","names":[],"sources":["../../../../../src/collection_editor/ui/collection_editor/utils/update_property_for_widget.ts"],"sourcesContent":["import { ArrayProperty, BooleanProperty, DateProperty, MapProperty, NumberProperty, Property, StringProperty } from \"@rebasepro/types\";\nimport { PropertyConfig } from \"@rebasepro/cms-types\";\nimport { mergeDeep } from \"@rebasepro/utils\";\n\n\nexport function updatePropertyFromWidget(propertyData: any,\n selectedWidgetId: string | undefined,\n propertyConfigs: Record<string, PropertyConfig>): Property {\n\n let updatedProperty;\n if (selectedWidgetId === \"text_field\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"string\",\n propertyConfig: \"text_field\",\n storage: undefined,\n admin: { multiline: undefined, markdown: undefined, urlPreview: undefined },\n email: undefined,\n enum: undefined,\n userSelect: undefined\n } as StringProperty\n );\n } else if (selectedWidgetId === \"user_select\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"string\",\n propertyConfig: \"user_select\",\n storage: undefined,\n admin: { multiline: undefined, markdown: undefined, urlPreview: undefined },\n email: undefined,\n enum: undefined,\n userSelect: true\n } as StringProperty\n );\n } else if (selectedWidgetId === \"multiline\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"string\",\n propertyConfig: \"multiline\",\n admin: { multiline: true, markdown: undefined, urlPreview: undefined },\n storage: undefined,\n email: undefined,\n enum: undefined,\n userSelect: undefined\n } as StringProperty\n );\n } else if (selectedWidgetId === \"markdown\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"string\",\n propertyConfig: \"markdown\",\n storage: undefined,\n admin: { multiline: undefined, markdown: true, urlPreview: undefined },\n email: undefined,\n userSelect: undefined\n } as StringProperty\n );\n } else if (selectedWidgetId === \"url\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"string\",\n propertyConfig: \"url\",\n storage: undefined,\n url: true,\n admin: { multiline: undefined, markdown: undefined },\n email: undefined,\n enum: undefined,\n userSelect: undefined\n } as StringProperty\n );\n } else if (selectedWidgetId === \"email\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"string\",\n propertyConfig: \"email\",\n storage: undefined,\n admin: { multiline: undefined, markdown: undefined, urlPreview: undefined },\n email: true,\n enum: undefined,\n userSelect: undefined\n } as StringProperty\n );\n } else if (selectedWidgetId === \"select\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"string\",\n propertyConfig: \"select\",\n storage: undefined,\n admin: { multiline: undefined, markdown: undefined, urlPreview: undefined },\n email: undefined,\n enum: propertyData.enum ?? [],\n userSelect: undefined\n } as StringProperty\n );\n } else if (selectedWidgetId === \"multi_select\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"array\",\n propertyConfig: \"multi_select\",\n of: {\n type: \"string\",\n enum: propertyData.of?.enum ?? []\n }\n } as ArrayProperty\n );\n } else if (selectedWidgetId === \"number_input\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"number\",\n propertyConfig: \"number_input\",\n enum: undefined\n } as NumberProperty\n );\n } else if (selectedWidgetId === \"number_select\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"number\",\n propertyConfig: \"number_select\",\n enum: propertyData.enum ?? []\n } as NumberProperty\n );\n } else if (selectedWidgetId === \"multi_number_select\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"array\",\n propertyConfig: \"multi_number_select\",\n of: {\n type: \"number\",\n enum: propertyData.of?.enum ?? []\n }\n } as ArrayProperty\n );\n } else if (selectedWidgetId === \"file_upload\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"string\",\n propertyConfig: \"file_upload\",\n storage: {\n storagePath: \"/\"\n }\n } as StringProperty\n );\n } else if (selectedWidgetId === \"multi_file_upload\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"array\",\n propertyConfig: \"multi_file_upload\",\n of: {\n type: \"string\",\n storage: propertyData.of?.storage ?? {\n storagePath: \"/\"\n }\n }\n } as ArrayProperty\n );\n } else if (selectedWidgetId === \"group\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"map\",\n propertyConfig: \"group\",\n keyValue: false,\n properties: propertyData.properties ?? {}\n } as MapProperty\n );\n } else if (selectedWidgetId === \"key_value\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"map\",\n propertyConfig: \"key_value\",\n keyValue: true,\n properties: undefined\n } as MapProperty\n );\n } else if (selectedWidgetId === \"reference\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"reference\",\n propertyConfig: \"reference\"\n } as Property\n );\n } else if (selectedWidgetId === \"multi_references\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"array\",\n propertyConfig: \"multi_references\",\n of: {\n type: \"reference\"\n }\n } as ArrayProperty\n );\n } else if (selectedWidgetId === \"switch\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"boolean\",\n propertyConfig: \"switch\"\n } as BooleanProperty\n );\n } else if (selectedWidgetId === \"date_time\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"date\",\n propertyConfig: \"date_time\",\n mode: \"date_time\"\n } as DateProperty\n );\n } else if (selectedWidgetId === \"relation\") {\n // `relationName` lives inside `relation`; at the top level, where this\n // used to write it, the boot validator refuses it. The `kind` is seeded\n // because the form's select *displays* \"Belongs to\" for a relation that\n // has none, and a relation with no kind does not boot either.\n const { relationName: _misplaced, ...rest } = propertyData ?? {};\n updatedProperty = mergeDeep(\n rest,\n {\n type: \"relation\",\n propertyConfig: \"relation\",\n relation: { kind: propertyData?.relation?.kind ?? \"belongsTo\" }\n } as Property\n );\n } else if (selectedWidgetId === \"repeat\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"array\",\n propertyConfig: \"repeat\"\n } as ArrayProperty\n );\n } else if (selectedWidgetId === \"block\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"array\",\n propertyConfig: \"block\",\n oneOf: {\n properties: {}\n }\n } as ArrayProperty\n );\n } else if (selectedWidgetId && propertyConfigs[selectedWidgetId]) {\n // Every widget without a branch of its own — vector, geopoint, binary,\n // and any registered custom one — takes its shape from the config.\n //\n // The identity fields are carried across explicitly. This used to\n // return the config's property alone, which dropped the name, the\n // description and the column mapping: switching an existing property to\n // one of these widgets silently blanked its label. The branches above\n // all merge onto `propertyData`; this one did not.\n //\n // Only those three are kept, not a full merge: the point of changing\n // widget is to change type, and a `defaultValue` or `enum` left over\n // from the previous type is not valid for the new one.\n updatedProperty = {\n ...propertyConfigs[selectedWidgetId].property,\n propertyConfig: selectedWidgetId,\n ...(propertyData?.name !== undefined ? { name: propertyData.name } : {}),\n ...(propertyData?.description !== undefined ? { description: propertyData.description } : {}),\n ...(propertyData?.columnName !== undefined ? { columnName: propertyData.columnName } : {})\n };\n }\n\n return updatedProperty;\n}\n"],"mappings":";;AAKA,SAAgB,yBAAyB,cACrC,kBACA,iBAA2D;CAE3D,IAAI;CACJ,IAAI,qBAAqB,cACrB,kBAAkB,UACd,cACA;EACI,MAAM;EACN,gBAAgB;EAChB,SAAS,KAAA;EACT,OAAO;GAAE,WAAW,KAAA;GAAW,UAAU,KAAA;GAAW,YAAY,KAAA;EAAU;EAC1E,OAAO,KAAA;EACP,MAAM,KAAA;EACN,YAAY,KAAA;CAChB,CACJ;MACG,IAAI,qBAAqB,eAC5B,kBAAkB,UACd,cACA;EACI,MAAM;EACN,gBAAgB;EAChB,SAAS,KAAA;EACT,OAAO;GAAE,WAAW,KAAA;GAAW,UAAU,KAAA;GAAW,YAAY,KAAA;EAAU;EAC1E,OAAO,KAAA;EACP,MAAM,KAAA;EACN,YAAY;CAChB,CACJ;MACG,IAAI,qBAAqB,aAC5B,kBAAkB,UACd,cACA;EACI,MAAM;EACN,gBAAgB;EAChB,OAAO;GAAE,WAAW;GAAM,UAAU,KAAA;GAAW,YAAY,KAAA;EAAU;EACrE,SAAS,KAAA;EACT,OAAO,KAAA;EACP,MAAM,KAAA;EACN,YAAY,KAAA;CAChB,CACJ;MACG,IAAI,qBAAqB,YAC5B,kBAAkB,UACd,cACA;EACI,MAAM;EACN,gBAAgB;EAChB,SAAS,KAAA;EACT,OAAO;GAAE,WAAW,KAAA;GAAW,UAAU;GAAM,YAAY,KAAA;EAAU;EACrE,OAAO,KAAA;EACP,YAAY,KAAA;CAChB,CACJ;MACG,IAAI,qBAAqB,OAC5B,kBAAkB,UACd,cACA;EACI,MAAM;EACN,gBAAgB;EAChB,SAAS,KAAA;EACT,KAAK;EACL,OAAO;GAAE,WAAW,KA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AAI,CAAC;EACtE,GAAI,cAAc,gBAAgB,KAAA,IAAY,EAAE,aAAa,aAAa,YAAY,IAAI,CAAC;EAC3F,GAAI,cAAc,eAAe,KAAA,IAAY,EAAE,YAAY,aAAa,WAAW,IAAI,CAAC;CAC5F;CAGJ,OAAO;AACX"}
|
|
1
|
+
{"version":3,"file":"update_property_for_widget.js","names":[],"sources":["../../../../../src/collection_editor/ui/collection_editor/utils/update_property_for_widget.ts"],"sourcesContent":["import { PropertyConfig, ArrayProperty, BooleanProperty, DateProperty, MapProperty, NumberProperty, Property, StringProperty } from \"@rebasepro/cms-types\";\nimport { mergeDeep } from \"@rebasepro/utils\";\n\n\nexport function updatePropertyFromWidget(propertyData: any,\n selectedWidgetId: string | undefined,\n propertyConfigs: Record<string, PropertyConfig>): Property {\n\n let updatedProperty;\n if (selectedWidgetId === \"text_field\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"string\",\n propertyConfig: \"text_field\",\n storage: undefined,\n admin: { multiline: undefined, markdown: undefined, urlPreview: undefined },\n email: undefined,\n enum: undefined,\n userSelect: undefined\n } as StringProperty\n );\n } else if (selectedWidgetId === \"user_select\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"string\",\n propertyConfig: \"user_select\",\n storage: undefined,\n admin: { multiline: undefined, markdown: undefined, urlPreview: undefined },\n email: undefined,\n enum: undefined,\n userSelect: true\n } as StringProperty\n );\n } else if (selectedWidgetId === \"multiline\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"string\",\n propertyConfig: \"multiline\",\n admin: { multiline: true, markdown: undefined, urlPreview: undefined },\n storage: undefined,\n email: undefined,\n enum: undefined,\n userSelect: undefined\n } as StringProperty\n );\n } else if (selectedWidgetId === \"markdown\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"string\",\n propertyConfig: \"markdown\",\n storage: undefined,\n admin: { multiline: undefined, markdown: true, urlPreview: undefined },\n email: undefined,\n userSelect: undefined\n } as StringProperty\n );\n } else if (selectedWidgetId === \"url\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"string\",\n propertyConfig: \"url\",\n storage: undefined,\n url: true,\n admin: { multiline: undefined, markdown: undefined },\n email: undefined,\n enum: undefined,\n userSelect: undefined\n } as StringProperty\n );\n } else if (selectedWidgetId === \"email\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"string\",\n propertyConfig: \"email\",\n storage: undefined,\n admin: { multiline: undefined, markdown: undefined, urlPreview: undefined },\n email: true,\n enum: undefined,\n userSelect: undefined\n } as StringProperty\n );\n } else if (selectedWidgetId === \"select\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"string\",\n propertyConfig: \"select\",\n storage: undefined,\n admin: { multiline: undefined, markdown: undefined, urlPreview: undefined },\n email: undefined,\n enum: propertyData.enum ?? [],\n userSelect: undefined\n } as StringProperty\n );\n } else if (selectedWidgetId === \"multi_select\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"array\",\n propertyConfig: \"multi_select\",\n of: {\n type: \"string\",\n enum: propertyData.of?.enum ?? []\n }\n } as ArrayProperty\n );\n } else if (selectedWidgetId === \"number_input\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"number\",\n propertyConfig: \"number_input\",\n enum: undefined\n } as NumberProperty\n );\n } else if (selectedWidgetId === \"number_select\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"number\",\n propertyConfig: \"number_select\",\n enum: propertyData.enum ?? []\n } as NumberProperty\n );\n } else if (selectedWidgetId === \"multi_number_select\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"array\",\n propertyConfig: \"multi_number_select\",\n of: {\n type: \"number\",\n enum: propertyData.of?.enum ?? []\n }\n } as ArrayProperty\n );\n } else if (selectedWidgetId === \"file_upload\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"string\",\n propertyConfig: \"file_upload\",\n storage: {\n storagePath: \"/\"\n }\n } as StringProperty\n );\n } else if (selectedWidgetId === \"multi_file_upload\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"array\",\n propertyConfig: \"multi_file_upload\",\n of: {\n type: \"string\",\n storage: propertyData.of?.storage ?? {\n storagePath: \"/\"\n }\n }\n } as ArrayProperty\n );\n } else if (selectedWidgetId === \"group\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"map\",\n propertyConfig: \"group\",\n keyValue: false,\n properties: propertyData.properties ?? {}\n } as MapProperty\n );\n } else if (selectedWidgetId === \"key_value\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"map\",\n propertyConfig: \"key_value\",\n keyValue: true,\n properties: undefined\n } as MapProperty\n );\n } else if (selectedWidgetId === \"reference\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"reference\",\n propertyConfig: \"reference\"\n } as Property\n );\n } else if (selectedWidgetId === \"multi_references\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"array\",\n propertyConfig: \"multi_references\",\n of: {\n type: \"reference\"\n }\n } as ArrayProperty\n );\n } else if (selectedWidgetId === \"switch\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"boolean\",\n propertyConfig: \"switch\"\n } as BooleanProperty\n );\n } else if (selectedWidgetId === \"date_time\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"date\",\n propertyConfig: \"date_time\",\n mode: \"date_time\"\n } as DateProperty\n );\n } else if (selectedWidgetId === \"relation\") {\n // `relationName` lives inside `relation`; at the top level, where this\n // used to write it, the boot validator refuses it. The `kind` is seeded\n // because the form's select *displays* \"Belongs to\" for a relation that\n // has none, and a relation with no kind does not boot either.\n const { relationName: _misplaced, ...rest } = propertyData ?? {};\n updatedProperty = mergeDeep(\n rest,\n {\n type: \"relation\",\n propertyConfig: \"relation\",\n relation: { kind: propertyData?.relation?.kind ?? \"belongsTo\" }\n } as Property\n );\n } else if (selectedWidgetId === \"repeat\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"array\",\n propertyConfig: \"repeat\"\n } as ArrayProperty\n );\n } else if (selectedWidgetId === \"block\") {\n updatedProperty = mergeDeep(\n propertyData,\n {\n type: \"array\",\n propertyConfig: \"block\",\n oneOf: {\n properties: {}\n }\n } as ArrayProperty\n );\n } else if (selectedWidgetId && propertyConfigs[selectedWidgetId]) {\n // Every widget without a branch of its own — vector, geopoint, binary,\n // and any registered custom one — takes its shape from the config.\n //\n // The identity fields are carried across explicitly. This used to\n // return the config's property alone, which dropped the name, the\n // description and the column mapping: switching an existing property to\n // one of these widgets silently blanked its label. The branches above\n // all merge onto `propertyData`; this one did not.\n //\n // Only those three are kept, not a full merge: the point of changing\n // widget is to change type, and a `defaultValue` or `enum` left over\n // from the previous type is not valid for the new one.\n updatedProperty = {\n ...propertyConfigs[selectedWidgetId].property,\n propertyConfig: selectedWidgetId,\n ...(propertyData?.name !== undefined ? { name: propertyData.name } : {}),\n ...(propertyData?.description !== undefined ? { description: propertyData.description } : {}),\n ...(propertyData?.columnName !== undefined ? { columnName: propertyData.columnName } : {})\n };\n }\n\n return updatedProperty;\n}\n"],"mappings":";;AAIA,SAAgB,yBAAyB,cACrC,kBACA,iBAA2D;CAE3D,IAAI;CACJ,IAAI,qBAAqB,cACrB,kBAAkB,UACd,cACA;EACI,MAAM;EACN,gBAAgB;EAChB,SAAS,KAAA;EACT,OAAO;GAAE,WAAW,KAAA;GAAW,UAAU,KAAA;GAAW,YAAY,KAAA;EAAU;EAC1E,OAAO,KAAA;EACP,MAAM,KAAA;EACN,YAAY,KAAA;CAChB,CACJ;MACG,IAAI,qBAAqB,eAC5B,kBAAkB,UACd,cACA;EACI,MAAM;EACN,gBAAgB;EAChB,SAAS,KAAA;EACT,OAAO;GAAE,WAAW,KAAA;GAAW,UAAU,KAAA;GAAW,YAAY,KAAA;EAAU;EAC1E,OAAO,KAAA;EACP,MAAM,KAAA;EACN,YAAY;CAChB,CACJ;MACG,IAAI,qBAAqB,aAC5B,kBAAkB,UACd,cACA;EACI,MAAM;EACN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gB,CAAC;EAC/D,kBAAkB,UACd,MACA;GACI,MAAM;GACN,gBAAgB;GAChB,UAAU,EAAE,MAAM,cAAc,UAAU,QAAQ,YAAY;EAClE,CACJ;CACJ,OAAO,IAAI,qBAAqB,UAC5B,kBAAkB,UACd,cACA;EACI,MAAM;EACN,gBAAgB;CACpB,CACJ;MACG,IAAI,qBAAqB,SAC5B,kBAAkB,UACd,cACA;EACI,MAAM;EACN,gBAAgB;EAChB,OAAO,EACH,YAAY,CAAC,EACjB;CACJ,CACJ;MACG,IAAI,oBAAoB,gBAAgB,mBAa3C,kBAAkB;EACd,GAAG,gBAAgB,iBAAiB,CAAC;EACrC,gBAAgB;EAChB,GAAI,cAAc,SAAS,KAAA,IAAY,EAAE,MAAM,aAAa,KAAK,IAAI,CAAC;EACtE,GAAI,cAAc,gBAAgB,KAAA,IAAY,EAAE,aAAa,aAAa,YAAY,IAAI,CAAC;EAC3F,GAAI,cAAc,eAAe,KAAA,IAAY,EAAE,YAAY,aAAa,WAAW,IAAI,CAAC;CAC5F;CAGJ,OAAO;AACX"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Asking before a table's inherited rules are replaced by rules of its own.
|
|
4
|
+
*
|
|
5
|
+
* A table whose `rls` is `"inherit"` follows `defaultRls`: a change there
|
|
6
|
+
* reaches it. Saving edited rules writes them into the table's own `rls`, and
|
|
7
|
+
* from then on `defaultRls` no longer applies to it. That is a decision, not a
|
|
8
|
+
* side effect of pressing Save, so the save waits for it — and keeping
|
|
9
|
+
* `"inherit"` (cancelling) writes nothing.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useDetachRulesConfirmation(): {
|
|
12
|
+
/** Resolves when the person agrees to detach `slug`; rejects with {@link SchemaChangeCancelled} when they keep `"inherit"`. */
|
|
13
|
+
confirm: (slug: string) => Promise<void>;
|
|
14
|
+
/** Render once beside the editor. */
|
|
15
|
+
dialog: React.ReactNode;
|
|
16
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SchemaChangeCancelled } from "./liveSchemaClient.js";
|
|
2
|
+
import { useCallback, useRef, useState } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { ConfirmationDialog, useTranslation } from "@rebasepro/app";
|
|
5
|
+
//#region src/collection_editor/useDetachRulesConfirmation.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Asking before a table's inherited rules are replaced by rules of its own.
|
|
8
|
+
*
|
|
9
|
+
* A table whose `rls` is `"inherit"` follows `defaultRls`: a change there
|
|
10
|
+
* reaches it. Saving edited rules writes them into the table's own `rls`, and
|
|
11
|
+
* from then on `defaultRls` no longer applies to it. That is a decision, not a
|
|
12
|
+
* side effect of pressing Save, so the save waits for it — and keeping
|
|
13
|
+
* `"inherit"` (cancelling) writes nothing.
|
|
14
|
+
*/
|
|
15
|
+
function useDetachRulesConfirmation() {
|
|
16
|
+
const { t } = useTranslation();
|
|
17
|
+
const [pending, setPending] = useState();
|
|
18
|
+
const settle = useRef(void 0);
|
|
19
|
+
const confirm = useCallback((slug) => new Promise((resolve, reject) => {
|
|
20
|
+
settle.current?.reject(new SchemaChangeCancelled());
|
|
21
|
+
settle.current = {
|
|
22
|
+
resolve,
|
|
23
|
+
reject
|
|
24
|
+
};
|
|
25
|
+
setPending(slug);
|
|
26
|
+
}), []);
|
|
27
|
+
const close = (accepted) => {
|
|
28
|
+
const current = settle.current;
|
|
29
|
+
settle.current = void 0;
|
|
30
|
+
setPending(void 0);
|
|
31
|
+
if (accepted) current?.resolve();
|
|
32
|
+
else current?.reject(new SchemaChangeCancelled());
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
confirm,
|
|
36
|
+
dialog: pending === void 0 ? null : /* @__PURE__ */ jsx(ConfirmationDialog, {
|
|
37
|
+
open: true,
|
|
38
|
+
title: t("schema_rules_detach_title"),
|
|
39
|
+
body: t("schema_rules_detach_body", { table: pending }),
|
|
40
|
+
onAccept: () => close(true),
|
|
41
|
+
onCancel: () => close(false)
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { useDetachRulesConfirmation };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=useDetachRulesConfirmation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDetachRulesConfirmation.js","names":[],"sources":["../../src/collection_editor/useDetachRulesConfirmation.tsx"],"sourcesContent":["import React, { useCallback, useRef, useState } from \"react\";\nimport { ConfirmationDialog, useTranslation } from \"@rebasepro/app\";\n\nimport { SchemaChangeCancelled } from \"./liveSchemaClient\";\n\n/**\n * Asking before a table's inherited rules are replaced by rules of its own.\n *\n * A table whose `rls` is `\"inherit\"` follows `defaultRls`: a change there\n * reaches it. Saving edited rules writes them into the table's own `rls`, and\n * from then on `defaultRls` no longer applies to it. That is a decision, not a\n * side effect of pressing Save, so the save waits for it — and keeping\n * `\"inherit\"` (cancelling) writes nothing.\n */\nexport function useDetachRulesConfirmation(): {\n /** Resolves when the person agrees to detach `slug`; rejects with {@link SchemaChangeCancelled} when they keep `\"inherit\"`. */\n confirm: (slug: string) => Promise<void>;\n /** Render once beside the editor. */\n dialog: React.ReactNode;\n} {\n const { t } = useTranslation();\n const [pending, setPending] = useState<string | undefined>();\n const settle = useRef<{ resolve: () => void; reject: (error: Error) => void } | undefined>(undefined);\n\n const confirm = useCallback((slug: string) => new Promise<void>((resolve, reject) => {\n settle.current?.reject(new SchemaChangeCancelled());\n settle.current = { resolve, reject };\n setPending(slug);\n }), []);\n\n const close = (accepted: boolean): void => {\n const current = settle.current;\n settle.current = undefined;\n setPending(undefined);\n if (accepted) current?.resolve();\n else current?.reject(new SchemaChangeCancelled());\n };\n\n const dialog = pending === undefined ? null : (\n <ConfirmationDialog\n open\n title={t(\"schema_rules_detach_title\")}\n body={t(\"schema_rules_detach_body\", { table: pending })}\n onAccept={() => close(true)}\n onCancel={() => close(false)}\n />\n );\n\n return { confirm, dialog };\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,SAAgB,6BAKd;CACE,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,CAAC,SAAS,cAAc,SAA6B;CAC3D,MAAM,SAAS,OAA4E,KAAA,CAAS;CAEpG,MAAM,UAAU,aAAa,SAAiB,IAAI,SAAe,SAAS,WAAW;EACjF,OAAO,SAAS,OAAO,IAAI,sBAAsB,CAAC;EAClD,OAAO,UAAU;GAAE;GAAS;EAAO;EACnC,WAAW,IAAI;CACnB,CAAC,GAAG,CAAC,CAAC;CAEN,MAAM,SAAS,aAA4B;EACvC,MAAM,UAAU,OAAO;EACvB,OAAO,UAAU,KAAA;EACjB,WAAW,KAAA,CAAS;EACpB,IAAI,UAAU,SAAS,QAAQ;OAC1B,SAAS,OAAO,IAAI,sBAAsB,CAAC;CACpD;CAYA,OAAO;EAAE;EAAS,QAVH,YAAY,KAAA,IAAY,OACnC,oBAAC,oBAAD;GACI,MAAA;GACA,OAAO,EAAE,2BAA2B;GACpC,MAAM,EAAE,4BAA4B,EAAE,OAAO,QAAQ,CAAC;GACtD,gBAAgB,MAAM,IAAI;GAC1B,gBAAgB,MAAM,KAAK;EAC9B,CAAA;CAGoB;AAC7B"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* said no" reaches the caller as an outcome rather than as silence.
|
|
16
16
|
*/
|
|
17
17
|
import React from "react";
|
|
18
|
-
import { type LiveSchemaClient, type LiveSchemaStatus, type
|
|
18
|
+
import { type LiveSchemaClient, type LiveSchemaStatus, type ProposedSchemaChange } from "./liveSchemaClient.js";
|
|
19
19
|
export { SchemaChangeCancelled, isSchemaChangeCancelled } from "./liveSchemaClient.js";
|
|
20
20
|
export interface UseLiveSchemaEditingOptions {
|
|
21
21
|
/** Base for the routes, e.g. `https://api.example.com/api/admin/schema`. */
|
|
@@ -64,7 +64,7 @@ export interface LiveSchemaEditing {
|
|
|
64
64
|
* closed the dialog, and with the underlying error if planning or applying
|
|
65
65
|
* failed in a way they did not choose.
|
|
66
66
|
*/
|
|
67
|
-
reviewChange: (change:
|
|
67
|
+
reviewChange: (change: ProposedSchemaChange) => Promise<void>;
|
|
68
68
|
/** Render this once, high enough that a dialog over the editor is not clipped. */
|
|
69
69
|
dialog: React.ReactNode;
|
|
70
70
|
}
|
|
@@ -191,7 +191,7 @@ function useLiveSchemaEditing(options) {
|
|
|
191
191
|
fallback: null,
|
|
192
192
|
children: /* @__PURE__ */ jsx(SchemaChangeDialog, {
|
|
193
193
|
open,
|
|
194
|
-
collectionId: pending?.change.
|
|
194
|
+
collectionId: pending?.change.table ?? "",
|
|
195
195
|
plan,
|
|
196
196
|
planError,
|
|
197
197
|
result,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveSchemaEditing.js","names":[],"sources":["../../src/collection_editor/useLiveSchemaEditing.tsx"],"sourcesContent":["/**\n * The plan-then-confirm flow, as a hook.\n *\n * Owns three things that belong together and nothing else: whether the backend\n * can edit its schema, the plan for the change somebody is making, and the\n * dialog they confirm it in. The config controller calls `reviewChange` and\n * awaits it; everything about *how* the confirmation happens stays here.\n *\n * ## Why `reviewChange` returns a promise that can reject\n *\n * Because the editor needs to know. A save that was cancelled must not leave\n * the form thinking it succeeded — the collection on screen would then differ\n * from the one on disk, and the next save would be computed from the wrong\n * `before`. Rejecting with {@link SchemaChangeCancelled} is how \"the person\n * said no\" reaches the caller as an outcome rather than as silence.\n */\nimport React, { Suspense, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { lazyChunk } from \"@rebasepro/ui\";\n\nimport {\n createLiveSchemaClient,\n LiveSchemaError,\n SchemaChangeCancelled,\n type LiveSchemaClient,\n type LiveSchemaPlan,\n type LiveSchemaResult,\n type LiveSchemaStatus,\n type ProposedCollectionChange\n} from \"./liveSchemaClient\";\n\n// Re-exported so the hook stays the one import a caller needs.\nexport { SchemaChangeCancelled, isSchemaChangeCancelled } from \"./liveSchemaClient\";\n\n/**\n * Loaded when a change is actually being reviewed, not before.\n *\n * This hook is reached from the collections config controller, which is\n * constructed on every admin boot — so a static import would put the dialog and\n * the `@rebasepro/ui` surface it draws on into the **eager** bundle: everything\n * a browser downloads before the login screen paints. It cost 14 kB there, for\n * a dialog most sessions never open. The bundle budget caught it.\n */\nconst SchemaChangeDialog = lazyChunk(() =>\n import(\"./ui/collection_editor/SchemaChangeDialog\")\n .then(m => ({ default: m.SchemaChangeDialog }))\n);\n\nexport interface UseLiveSchemaEditingOptions {\n /** Base for the routes, e.g. `https://api.example.com/api/admin/schema`. */\n baseUrl: string;\n getAuthToken?: () => Promise<string | null> | string | null;\n /**\n * Identity of the signed-in user.\n *\n * Only used to re-ask: whether this backend will accept a schema change\n * depends on who is asking, and the answer to an anonymous probe does not\n * survive a sign-in.\n */\n authKey?: string | null;\n /**\n * Whether to ask the backend at all. `false` when the caller cannot be told\n * anything (`/status` needs `schema:read`) or the editor is read-only: the\n * answer is then \"not available\" without a request that could only be\n * refused. Defaults to `true`.\n */\n enabled?: boolean;\n /** Swappable for the tests, which have no server. */\n client?: LiveSchemaClient;\n}\n\n/** The answer when nobody asked. */\nconst NOT_ASKED: LiveSchemaStatus = { enabled: false, canPlan: false, canApply: false };\n\ninterface PendingChange {\n change: ProposedCollectionChange;\n resolve: () => void;\n reject: (err: Error) => void;\n}\n\nexport interface LiveSchemaEditing {\n /** `undefined` until the backend has answered. For rendering. */\n status?: LiveSchemaStatus;\n /**\n * The same answer, for deciding.\n *\n * `status` is undefined for one round trip after mount, and a caller that\n * read it to choose a code path would take the \"not available\" branch for\n * that window — so a save issued quickly after a page load would silently\n * skip the confirmation and write source only, while the same save a second\n * later would not. Timing-dependent behaviour with no visible difference is\n * the worst shape this could have.\n *\n * Resolves once, cached; never rejects, because every way of failing to get\n * an answer means the same thing to whoever is deciding.\n */\n ready: () => Promise<LiveSchemaStatus>;\n /**\n * Plan the change, show it, and settle when the person has decided.\n *\n * Resolves once the change has been applied — or written source-only, if\n * they chose that. Rejects with {@link SchemaChangeCancelled} if they\n * closed the dialog, and with the underlying error if planning or applying\n * failed in a way they did not choose.\n */\n reviewChange: (change: ProposedCollectionChange) => Promise<void>;\n /** Render this once, high enough that a dialog over the editor is not clipped. */\n dialog: React.ReactNode;\n}\n\nexport function useLiveSchemaEditing(options: UseLiveSchemaEditingOptions): LiveSchemaEditing {\n const { baseUrl, authKey } = options;\n const asking = options.enabled !== false;\n\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n const client = useMemo(\n () => options.client ?? createLiveSchemaClient({\n baseUrl,\n getAuthToken: () => optionsRef.current.getAuthToken?.() ?? null\n }),\n // `client` is either supplied once by a test or built from the URL. The\n // token getter is read through the ref so a new closure on every render\n // does not rebuild the client underneath an in-flight request.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [baseUrl, options.client]\n );\n\n const [status, setStatus] = useState<LiveSchemaStatus | undefined>();\n const [pending, setPending] = useState<PendingChange | undefined>();\n const [plan, setPlan] = useState<LiveSchemaPlan | undefined>();\n const [planError, setPlanError] = useState<string | undefined>();\n const [result, setResult] = useState<LiveSchemaResult | undefined>();\n const [applying, setApplying] = useState(false);\n const [applyError, setApplyError] = useState<string | undefined>();\n\n // The in-flight probe, so `ready()` can await the same one the effect\n // started rather than issuing a second. Keyed by client+authKey the same way\n // the effect is: a sign-in changes the answer, so it has to be re-asked.\n // `undefined` passed explicitly: React 19's `useRef` takes no zero-argument\n // overload, and omitting it is an error rather than a default.\n const probe = useRef<{ key: unknown[]; promise: Promise<LiveSchemaStatus> } | undefined>(undefined);\n\n /** Which review a plan response belongs to. See `reviewChange`. */\n const reviewToken = useRef(0);\n\n const ready = useCallback((): Promise<LiveSchemaStatus> => {\n if (!asking) return Promise.resolve(NOT_ASKED);\n const key = [client, authKey];\n const current = probe.current;\n if (!current || current.key[0] !== key[0] || current.key[1] !== key[1]) {\n probe.current = { key, promise: client.status() };\n }\n return probe.current!.promise;\n }, [client, authKey, asking]);\n\n useEffect(() => {\n let cancelled = false;\n void ready().then(answer => {\n if (!cancelled) setStatus(answer);\n });\n return () => { cancelled = true; };\n }, [ready]);\n\n /**\n * Ask what the change would do, and ignore an answer that arrives late.\n *\n * Separate from `reviewChange` so it can be issued *again* without starting\n * a new review: a plan that failed on a dropped connection should cost a\n * click, not the whole wizard — the person has already filled in the form,\n * and making them do it twice for a transient failure is the kind of thing\n * that teaches people to distrust the preview.\n */\n const requestPlan = useCallback(async (change: ProposedCollectionChange) => {\n // Identifies the review a response belongs to. A plan that arrives after\n // its review was replaced must not be shown: the dialog would describe\n // the *previous* change while the reader believes it describes this one.\n const token = ++reviewToken.current;\n try {\n const answer = await client.plan(change);\n if (token === reviewToken.current) setPlan(answer);\n } catch (err: unknown) {\n if (token !== reviewToken.current) return;\n setPlanError(\n err instanceof LiveSchemaError || err instanceof Error\n ? err.message\n : String(err)\n );\n }\n }, [client]);\n\n const onRetry = useCallback(() => {\n if (!pending) return;\n setPlanError(undefined);\n setPlan(undefined);\n void requestPlan(pending.change);\n }, [pending, requestPlan]);\n\n const clear = useCallback(() => {\n setPending(undefined);\n setPlan(undefined);\n setPlanError(undefined);\n setResult(undefined);\n setApplyError(undefined);\n setApplying(false);\n }, []);\n\n const reviewChange = useCallback((change: ProposedCollectionChange) => {\n return new Promise<void>((resolve, reject) => {\n // A second review while one is open — a double-clicked save —\n // replaces the pending one, and the one it replaces has to be\n // settled. `setPending` used to overwrite `resolve`/`reject` with\n // nobody left holding them, so the first caller's promise never\n // settled at all and the editor's save simply never returned.\n setPending(previous => {\n previous?.reject(new SchemaChangeCancelled());\n return { change, resolve, reject };\n });\n\n // Identifies the review a response belongs to. A plan that arrives\n // after its review was replaced must not be shown: the dialog would\n // describe the *previous* change while the reader believes it\n // describes this one, and the SQL on screen would be for something\n // they are not confirming.\n setPlan(undefined);\n setPlanError(undefined);\n setResult(undefined);\n setApplyError(undefined);\n setApplying(false);\n\n void requestPlan(change);\n });\n // `client` is not listed: this no longer touches it directly, and\n // `requestPlan` already carries that dependency.\n }, [requestPlan]);\n\n const onConfirm = useCallback(() => {\n if (!pending) return;\n setApplying(true);\n setApplyError(undefined);\n void client.apply(pending.change).then(\n answer => {\n setResult(answer);\n setApplying(false);\n // Resolved here, not on close. The change has happened, and the\n // dialog is now a receipt somebody may read for as long as they\n // like — holding the caller open until they close it would\n // leave the editor mid-save for no reason.\n pending.resolve();\n setPending(undefined);\n },\n (err: unknown) => {\n setApplying(false);\n setApplyError(err instanceof Error ? err.message : String(err));\n }\n );\n }, [client, pending]);\n\n /**\n * \"Edit source only\": commit the collection, run nothing.\n *\n * Through the same door as an apply, so it is committed. It used to be a\n * write through the source-only editor that nobody committed, which every\n * later \"Commit and apply\" met as somebody else's work — 409, with the\n * dialog never saying why.\n */\n const onSourceOnly = useCallback(() => {\n if (!pending) return;\n setApplying(true);\n setApplyError(undefined);\n const settle = pending;\n void client.apply({ ...settle.change, sourceOnly: true }).then(\n answer => {\n setResult(answer);\n setApplying(false);\n settle.resolve();\n setPending(undefined);\n },\n (err: unknown) => {\n setApplying(false);\n setApplyError(err instanceof Error ? err.message : String(err));\n }\n );\n }, [client, pending]);\n\n // A deployment that provisions nothing applies no change from here, and\n // says to commit it as source only: for a change that could be applied,\n // that commit is the way through, and the dialog's main action.\n const provisioningOff = status?.applyRefusedCode === \"SCHEMA_EDITING_PROVISIONING_OFF\";\n const commitAsSourceOnly = Boolean(provisioningOff && plan?.applicable);\n\n // Offered only when every refused change says what it would leave behind.\n // One that does not may not be written to the source alone.\n const sourceOnlyOffered = commitAsSourceOnly || Boolean(plan && !plan.applicable &&\n plan.changes.filter(change => change.verdict !== \"safe\").every(change => change.sourceOnly));\n\n const onClose = useCallback(() => {\n // Escape and the backdrop reach this too, and the Cancel *button* is the\n // only one of the three that was disabled while applying. Closing\n // mid-apply rejected the caller as cancelled while the commit and the\n // DDL carried on — reporting that nothing happened while something did,\n // which is the exact failure this whole feature exists to end.\n if (applying) return;\n\n const settle = pending;\n clear();\n // A dialog showing a result has already resolved; closing it is not a\n // cancellation of anything.\n if (settle && !result) settle.reject(new SchemaChangeCancelled());\n }, [applying, pending, result, clear]);\n\n // Not even a Suspense boundary until there is something to review — the\n // chunk is fetched by the first `reviewChange`, and an admin session that\n // never edits a collection never pays for it.\n const open = Boolean(pending) || Boolean(result);\n const dialog = open\n ? (\n <Suspense fallback={null}>\n <SchemaChangeDialog\n open={open}\n collectionId={pending?.change.collectionId ?? \"\"}\n plan={plan}\n planError={planError}\n result={result}\n applying={applying}\n applyError={applyError}\n onConfirm={onConfirm}\n onRetry={planError ? onRetry : undefined}\n onSourceOnly={sourceOnlyOffered ? onSourceOnly : undefined}\n sourceOnlyIsTheCommit={commitAsSourceOnly}\n onClose={onClose}\n applyRefusedBecause={\n status && !status.canApply ? status.applyRefusedBecause : undefined\n }\n target={status && {\n repository: status.repository,\n branch: status.branch\n }}\n />\n </Suspense>\n )\n : null;\n\n return { status, ready, reviewChange, dialog };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAM,qBAAqB,gBACvB,OAAO,+CAA4C,CAC9C,MAAK,OAAM,EAAE,SAAS,EAAE,mBAAmB,EAAE,CACtD;;AA0BA,IAAM,YAA8B;CAAE,SAAS;CAAO,SAAS;CAAO,UAAU;AAAM;AAsCtF,SAAgB,qBAAqB,SAAyD;CAC1F,MAAM,EAAE,SAAS,YAAY;CAC7B,MAAM,SAAS,QAAQ,YAAY;CAEnC,MAAM,aAAa,OAAO,OAAO;CACjC,WAAW,UAAU;CAErB,MAAM,SAAS,cACL,QAAQ,UAAU,uBAAuB;EAC3C;EACA,oBAAoB,WAAW,QAAQ,eAAe,KAAK;CAC/D,CAAC,GAKD,CAAC,SAAS,QAAQ,MAAM,CAC5B;CAEA,MAAM,CAAC,QAAQ,aAAa,SAAuC;CACnE,MAAM,CAAC,SAAS,cAAc,SAAoC;CAClE,MAAM,CAAC,MAAM,WAAW,SAAqC;CAC7D,MAAM,CAAC,WAAW,gBAAgB,SAA6B;CAC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AAQ,IAAI,UAAU,OAAO,GAAG,CAAC;EAClE,CACJ;CACJ,GAAG,CAAC,QAAQ,OAAO,CAAC;CAKpB,MAAM,kBAAkB,QAAQ,qBAAqB;CACrD,MAAM,qBAAqB,QAAQ,mBAAmB,MAAM,UAAU;CAItE,MAAM,oBAAoB,sBAAsB,QAAQ,QAAQ,CAAC,KAAK,cAClE,KAAK,QAAQ,QAAO,WAAU,OAAO,YAAY,MAAM,CAAC,CAAC,OAAM,WAAU,OAAO,UAAU,CAAC;CAE/F,MAAM,UAAU,kBAAkB;EAM9B,IAAI,UAAU;EAEd,MAAM,SAAS;EACf,MAAM;EAGN,IAAI,UAAU,CAAC,QAAQ,OAAO,OAAO,IAAI,sBAAsB,CAAC;CACpE,GAAG;EAAC;EAAU;EAAS;EAAQ;CAAK,CAAC;CAKrC,MAAM,OAAO,QAAQ,OAAO,KAAK,QAAQ,MAAM;CA6B/C,OAAO;EAAE;EAAQ;EAAO;EAAc,QA5BvB,OAEP,oBAAC,UAAD;GAAU,UAAU;aAChB,oBAAC,oBAAD;IACU;IACN,cAAc,SAAS,OAAO,gBAAgB;IACxC;IACK;IACH;IACE;IACE;IACD;IACX,SAAS,YAAY,UAAU,KAAA;IAC/B,cAAc,oBAAoB,eAAe,KAAA;IACjD,uBAAuB;IACd;IACT,qBACI,UAAU,CAAC,OAAO,WAAW,OAAO,sBAAsB,KAAA;IAE9D,QAAQ,UAAU;KACd,YAAY,OAAO;KACnB,QAAQ,OAAO;IACnB;GACH,CAAA;EACK,CAAA,IAEZ;CAEuC;AACjD"}
|
|
1
|
+
{"version":3,"file":"useLiveSchemaEditing.js","names":[],"sources":["../../src/collection_editor/useLiveSchemaEditing.tsx"],"sourcesContent":["/**\n * The plan-then-confirm flow, as a hook.\n *\n * Owns three things that belong together and nothing else: whether the backend\n * can edit its schema, the plan for the change somebody is making, and the\n * dialog they confirm it in. The config controller calls `reviewChange` and\n * awaits it; everything about *how* the confirmation happens stays here.\n *\n * ## Why `reviewChange` returns a promise that can reject\n *\n * Because the editor needs to know. A save that was cancelled must not leave\n * the form thinking it succeeded — the collection on screen would then differ\n * from the one on disk, and the next save would be computed from the wrong\n * `before`. Rejecting with {@link SchemaChangeCancelled} is how \"the person\n * said no\" reaches the caller as an outcome rather than as silence.\n */\nimport React, { Suspense, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { lazyChunk } from \"@rebasepro/ui\";\n\nimport {\n createLiveSchemaClient,\n LiveSchemaError,\n SchemaChangeCancelled,\n type LiveSchemaClient,\n type LiveSchemaPlan,\n type LiveSchemaResult,\n type LiveSchemaStatus,\n type ProposedSchemaChange\n} from \"./liveSchemaClient\";\n\n// Re-exported so the hook stays the one import a caller needs.\nexport { SchemaChangeCancelled, isSchemaChangeCancelled } from \"./liveSchemaClient\";\n\n/**\n * Loaded when a change is actually being reviewed, not before.\n *\n * This hook is reached from the collections config controller, which is\n * constructed on every admin boot — so a static import would put the dialog and\n * the `@rebasepro/ui` surface it draws on into the **eager** bundle: everything\n * a browser downloads before the login screen paints. It cost 14 kB there, for\n * a dialog most sessions never open. The bundle budget caught it.\n */\nconst SchemaChangeDialog = lazyChunk(() =>\n import(\"./ui/collection_editor/SchemaChangeDialog\")\n .then(m => ({ default: m.SchemaChangeDialog }))\n);\n\nexport interface UseLiveSchemaEditingOptions {\n /** Base for the routes, e.g. `https://api.example.com/api/admin/schema`. */\n baseUrl: string;\n getAuthToken?: () => Promise<string | null> | string | null;\n /**\n * Identity of the signed-in user.\n *\n * Only used to re-ask: whether this backend will accept a schema change\n * depends on who is asking, and the answer to an anonymous probe does not\n * survive a sign-in.\n */\n authKey?: string | null;\n /**\n * Whether to ask the backend at all. `false` when the caller cannot be told\n * anything (`/status` needs `schema:read`) or the editor is read-only: the\n * answer is then \"not available\" without a request that could only be\n * refused. Defaults to `true`.\n */\n enabled?: boolean;\n /** Swappable for the tests, which have no server. */\n client?: LiveSchemaClient;\n}\n\n/** The answer when nobody asked. */\nconst NOT_ASKED: LiveSchemaStatus = { enabled: false, canPlan: false, canApply: false };\n\ninterface PendingChange {\n change: ProposedSchemaChange;\n resolve: () => void;\n reject: (err: Error) => void;\n}\n\nexport interface LiveSchemaEditing {\n /** `undefined` until the backend has answered. For rendering. */\n status?: LiveSchemaStatus;\n /**\n * The same answer, for deciding.\n *\n * `status` is undefined for one round trip after mount, and a caller that\n * read it to choose a code path would take the \"not available\" branch for\n * that window — so a save issued quickly after a page load would silently\n * skip the confirmation and write source only, while the same save a second\n * later would not. Timing-dependent behaviour with no visible difference is\n * the worst shape this could have.\n *\n * Resolves once, cached; never rejects, because every way of failing to get\n * an answer means the same thing to whoever is deciding.\n */\n ready: () => Promise<LiveSchemaStatus>;\n /**\n * Plan the change, show it, and settle when the person has decided.\n *\n * Resolves once the change has been applied — or written source-only, if\n * they chose that. Rejects with {@link SchemaChangeCancelled} if they\n * closed the dialog, and with the underlying error if planning or applying\n * failed in a way they did not choose.\n */\n reviewChange: (change: ProposedSchemaChange) => Promise<void>;\n /** Render this once, high enough that a dialog over the editor is not clipped. */\n dialog: React.ReactNode;\n}\n\nexport function useLiveSchemaEditing(options: UseLiveSchemaEditingOptions): LiveSchemaEditing {\n const { baseUrl, authKey } = options;\n const asking = options.enabled !== false;\n\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n const client = useMemo(\n () => options.client ?? createLiveSchemaClient({\n baseUrl,\n getAuthToken: () => optionsRef.current.getAuthToken?.() ?? null\n }),\n // `client` is either supplied once by a test or built from the URL. The\n // token getter is read through the ref so a new closure on every render\n // does not rebuild the client underneath an in-flight request.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [baseUrl, options.client]\n );\n\n const [status, setStatus] = useState<LiveSchemaStatus | undefined>();\n const [pending, setPending] = useState<PendingChange | undefined>();\n const [plan, setPlan] = useState<LiveSchemaPlan | undefined>();\n const [planError, setPlanError] = useState<string | undefined>();\n const [result, setResult] = useState<LiveSchemaResult | undefined>();\n const [applying, setApplying] = useState(false);\n const [applyError, setApplyError] = useState<string | undefined>();\n\n // The in-flight probe, so `ready()` can await the same one the effect\n // started rather than issuing a second. Keyed by client+authKey the same way\n // the effect is: a sign-in changes the answer, so it has to be re-asked.\n // `undefined` passed explicitly: React 19's `useRef` takes no zero-argument\n // overload, and omitting it is an error rather than a default.\n const probe = useRef<{ key: unknown[]; promise: Promise<LiveSchemaStatus> } | undefined>(undefined);\n\n /** Which review a plan response belongs to. See `reviewChange`. */\n const reviewToken = useRef(0);\n\n const ready = useCallback((): Promise<LiveSchemaStatus> => {\n if (!asking) return Promise.resolve(NOT_ASKED);\n const key = [client, authKey];\n const current = probe.current;\n if (!current || current.key[0] !== key[0] || current.key[1] !== key[1]) {\n probe.current = { key, promise: client.status() };\n }\n return probe.current!.promise;\n }, [client, authKey, asking]);\n\n useEffect(() => {\n let cancelled = false;\n void ready().then(answer => {\n if (!cancelled) setStatus(answer);\n });\n return () => { cancelled = true; };\n }, [ready]);\n\n /**\n * Ask what the change would do, and ignore an answer that arrives late.\n *\n * Separate from `reviewChange` so it can be issued *again* without starting\n * a new review: a plan that failed on a dropped connection should cost a\n * click, not the whole wizard — the person has already filled in the form,\n * and making them do it twice for a transient failure is the kind of thing\n * that teaches people to distrust the preview.\n */\n const requestPlan = useCallback(async (change: ProposedSchemaChange) => {\n // Identifies the review a response belongs to. A plan that arrives after\n // its review was replaced must not be shown: the dialog would describe\n // the *previous* change while the reader believes it describes this one.\n const token = ++reviewToken.current;\n try {\n const answer = await client.plan(change);\n if (token === reviewToken.current) setPlan(answer);\n } catch (err: unknown) {\n if (token !== reviewToken.current) return;\n setPlanError(\n err instanceof LiveSchemaError || err instanceof Error\n ? err.message\n : String(err)\n );\n }\n }, [client]);\n\n const onRetry = useCallback(() => {\n if (!pending) return;\n setPlanError(undefined);\n setPlan(undefined);\n void requestPlan(pending.change);\n }, [pending, requestPlan]);\n\n const clear = useCallback(() => {\n setPending(undefined);\n setPlan(undefined);\n setPlanError(undefined);\n setResult(undefined);\n setApplyError(undefined);\n setApplying(false);\n }, []);\n\n const reviewChange = useCallback((change: ProposedSchemaChange) => {\n return new Promise<void>((resolve, reject) => {\n // A second review while one is open — a double-clicked save —\n // replaces the pending one, and the one it replaces has to be\n // settled. `setPending` used to overwrite `resolve`/`reject` with\n // nobody left holding them, so the first caller's promise never\n // settled at all and the editor's save simply never returned.\n setPending(previous => {\n previous?.reject(new SchemaChangeCancelled());\n return { change, resolve, reject };\n });\n\n // Identifies the review a response belongs to. A plan that arrives\n // after its review was replaced must not be shown: the dialog would\n // describe the *previous* change while the reader believes it\n // describes this one, and the SQL on screen would be for something\n // they are not confirming.\n setPlan(undefined);\n setPlanError(undefined);\n setResult(undefined);\n setApplyError(undefined);\n setApplying(false);\n\n void requestPlan(change);\n });\n // `client` is not listed: this no longer touches it directly, and\n // `requestPlan` already carries that dependency.\n }, [requestPlan]);\n\n const onConfirm = useCallback(() => {\n if (!pending) return;\n setApplying(true);\n setApplyError(undefined);\n void client.apply(pending.change).then(\n answer => {\n setResult(answer);\n setApplying(false);\n // Resolved here, not on close. The change has happened, and the\n // dialog is now a receipt somebody may read for as long as they\n // like — holding the caller open until they close it would\n // leave the editor mid-save for no reason.\n pending.resolve();\n setPending(undefined);\n },\n (err: unknown) => {\n setApplying(false);\n setApplyError(err instanceof Error ? err.message : String(err));\n }\n );\n }, [client, pending]);\n\n /**\n * \"Edit source only\": commit the collection, run nothing.\n *\n * Through the same door as an apply, so it is committed. It used to be a\n * write through the source-only editor that nobody committed, which every\n * later \"Commit and apply\" met as somebody else's work — 409, with the\n * dialog never saying why.\n */\n const onSourceOnly = useCallback(() => {\n if (!pending) return;\n setApplying(true);\n setApplyError(undefined);\n const settle = pending;\n void client.apply({ ...settle.change, sourceOnly: true }).then(\n answer => {\n setResult(answer);\n setApplying(false);\n settle.resolve();\n setPending(undefined);\n },\n (err: unknown) => {\n setApplying(false);\n setApplyError(err instanceof Error ? err.message : String(err));\n }\n );\n }, [client, pending]);\n\n // A deployment that provisions nothing applies no change from here, and\n // says to commit it as source only: for a change that could be applied,\n // that commit is the way through, and the dialog's main action.\n const provisioningOff = status?.applyRefusedCode === \"SCHEMA_EDITING_PROVISIONING_OFF\";\n const commitAsSourceOnly = Boolean(provisioningOff && plan?.applicable);\n\n // Offered only when every refused change says what it would leave behind.\n // One that does not may not be written to the source alone.\n const sourceOnlyOffered = commitAsSourceOnly || Boolean(plan && !plan.applicable &&\n plan.changes.filter(change => change.verdict !== \"safe\").every(change => change.sourceOnly));\n\n const onClose = useCallback(() => {\n // Escape and the backdrop reach this too, and the Cancel *button* is the\n // only one of the three that was disabled while applying. Closing\n // mid-apply rejected the caller as cancelled while the commit and the\n // DDL carried on — reporting that nothing happened while something did,\n // which is the exact failure this whole feature exists to end.\n if (applying) return;\n\n const settle = pending;\n clear();\n // A dialog showing a result has already resolved; closing it is not a\n // cancellation of anything.\n if (settle && !result) settle.reject(new SchemaChangeCancelled());\n }, [applying, pending, result, clear]);\n\n // Not even a Suspense boundary until there is something to review — the\n // chunk is fetched by the first `reviewChange`, and an admin session that\n // never edits a collection never pays for it.\n const open = Boolean(pending) || Boolean(result);\n const dialog = open\n ? (\n <Suspense fallback={null}>\n <SchemaChangeDialog\n open={open}\n collectionId={pending?.change.table ?? \"\"}\n plan={plan}\n planError={planError}\n result={result}\n applying={applying}\n applyError={applyError}\n onConfirm={onConfirm}\n onRetry={planError ? onRetry : undefined}\n onSourceOnly={sourceOnlyOffered ? onSourceOnly : undefined}\n sourceOnlyIsTheCommit={commitAsSourceOnly}\n onClose={onClose}\n applyRefusedBecause={\n status && !status.canApply ? status.applyRefusedBecause : undefined\n }\n target={status && {\n repository: status.repository,\n branch: status.branch\n }}\n />\n </Suspense>\n )\n : null;\n\n return { status, ready, reviewChange, dialog };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAM,qBAAqB,gBACvB,OAAO,+CAA4C,CAC9C,MAAK,OAAM,EAAE,SAAS,EAAE,mBAAmB,EAAE,CACtD;;AA0BA,IA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AAY,UAAU,KAAA;IAC/B,cAAc,oBAAoB,eAAe,KAAA;IACjD,uBAAuB;IACd;IACT,qBACI,UAAU,CAAC,OAAO,WAAW,OAAO,sBAAsB,KAAA;IAE9D,QAAQ,UAAU;KACd,YAAY,OAAO;KACnB,QAAQ,OAAO;IACnB;GACH,CAAA;EACK,CAAA,IAEZ;CAEuC;AACjD"}
|
|
@@ -1,21 +1,65 @@
|
|
|
1
1
|
import { CollectionsConfigController } from "./types/config_controller.js";
|
|
2
|
+
import type { TableDescriptor, UiTablePreferences } from "@rebasepro/types";
|
|
2
3
|
import type { AdminCollection } from "@rebasepro/cms-types";
|
|
3
|
-
|
|
4
|
+
import { type SchemaEditProblem } from "./liveSchemaClient.js";
|
|
5
|
+
/**
|
|
6
|
+
* Where the collection editor's presentation edits go: the UI preferences
|
|
7
|
+
* store (`usePresentationPersistence`). Absent, an edit that changes how a
|
|
8
|
+
* table is presented is refused, never silently dropped.
|
|
9
|
+
*/
|
|
10
|
+
export interface PresentationWriter {
|
|
11
|
+
/** Merge `delta` into the workspace's preferences for `slug`. */
|
|
12
|
+
save: (slug: string, delta: UiTablePreferences) => Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/** The client the controller is built over: a base URL, or the Rebase client. */
|
|
15
|
+
export interface SchemaEditorTransport {
|
|
16
|
+
baseUrl?: string;
|
|
17
|
+
apiPath?: string;
|
|
18
|
+
resolveToken?: () => Promise<string | null | undefined>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* An error a save ends with that the editor shows as more than a line:
|
|
22
|
+
* `SCHEMA_EDIT_DOES_NOT_COMPILE` with its problems, a refusal, a file changed
|
|
23
|
+
* on disk since the preview. Carries the server's code and problems.
|
|
24
|
+
*/
|
|
25
|
+
export declare class SchemaEditRefused extends Error {
|
|
26
|
+
readonly code: string | undefined;
|
|
27
|
+
readonly problems: readonly SchemaEditProblem[];
|
|
28
|
+
constructor(message: string, code: string | undefined, problems?: readonly SchemaEditProblem[]);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The collections config controller the panel builds when the collection
|
|
32
|
+
* editor is on.
|
|
33
|
+
*
|
|
34
|
+
* A save is split ({@link splitEdit}) into the schema edit — `TablePatch`
|
|
35
|
+
* operations for the server's schema editor, through the plan-and-confirm
|
|
36
|
+
* dialog when live schema editing is on, straight to the source-only editor
|
|
37
|
+
* when it is not — and the presentation delta, written to the UI preferences
|
|
38
|
+
* store. A Firestore collection is defined in the frontend: on a development
|
|
39
|
+
* server its save is an edit of its `defineFirestoreCollection` call
|
|
40
|
+
* (`firestoreCollectionPatches`), written by the server's frontend source
|
|
41
|
+
* editor; anywhere else it is read-only here.
|
|
42
|
+
*/
|
|
43
|
+
export declare function useLocalCollectionsConfigController(clientOrUrl: string | SchemaEditorTransport | null | undefined, baseCollections?: AdminCollection[], options?: {
|
|
4
44
|
readOnly?: boolean;
|
|
5
45
|
getAuthToken?: () => Promise<string | null>;
|
|
6
46
|
/**
|
|
7
|
-
* Identity of the signed-in user, if any.
|
|
8
|
-
*
|
|
9
|
-
* Only used to re-ask the backend when it changes: whether the editor
|
|
10
|
-
* will accept a write depends on who is asking, and the answer to an
|
|
11
|
-
* anonymous probe does not survive a sign-in.
|
|
47
|
+
* Identity of the signed-in user, if any. Only used to re-ask the
|
|
48
|
+
* backend when it changes.
|
|
12
49
|
*/
|
|
13
50
|
authKey?: string | null;
|
|
14
51
|
/**
|
|
15
|
-
* Whether the signed-in user holds `schema:read`, which both
|
|
16
|
-
*
|
|
17
|
-
* read-only
|
|
18
|
-
* Absent means ask.
|
|
52
|
+
* Whether the signed-in user holds `schema:read`, which both status
|
|
53
|
+
* routes require. `false` asks neither and leaves the editor
|
|
54
|
+
* read-only. Absent means ask.
|
|
19
55
|
*/
|
|
20
56
|
mayReadSchema?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* The tables the server serves, as descriptors: what a save keeps from
|
|
59
|
+
* a column the view model cannot fully describe, and which collections
|
|
60
|
+
* are tables at all (the others are external, and read-only here).
|
|
61
|
+
*/
|
|
62
|
+
tables?: readonly TableDescriptor[];
|
|
63
|
+
/** Where presentation edits are written. */
|
|
64
|
+
presentation?: PresentationWriter;
|
|
21
65
|
}): CollectionsConfigController;
|