@rebasepro/cms 0.30.1 → 0.31.0-canary.g902a0ce
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -2,71 +2,107 @@
|
|
|
2
2
|
* The screen a show_* tool asked for, read from its result
|
|
3
3
|
* (`McpViewPayload` in the server's `mcp/mcp-view.ts`).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* (
|
|
5
|
+
* The payload carries the descriptors of the tables the screen draws, as the
|
|
6
|
+
* server serves this caller (columns they may not read and raw policy SQL
|
|
7
|
+
* already left out), and what the connection was granted on each. The view
|
|
8
|
+
* renders them as the admin panel renders the tables `GET /api/schema/tables`
|
|
9
|
+
* serves: projected, with the project's `customizeTable` customizations where
|
|
10
|
+
* the view was built from the project's frontend, then the UI preferences the
|
|
11
|
+
* payload carries (the workspace's and the caller's), folded as the panel
|
|
12
|
+
* folds them.
|
|
7
13
|
*/
|
|
8
|
-
import { type FilterValues } from "@rebasepro/types";
|
|
14
|
+
import { type FilterValues, type TableDescriptor, type UiPreferences } from "@rebasepro/types";
|
|
9
15
|
import type { AdminCollection } from "@rebasepro/cms-types";
|
|
10
16
|
import { type ToolResult } from "./bridge.js";
|
|
11
17
|
import { type SeedPage, type ViewActions } from "./tool_driver.js";
|
|
12
18
|
export type ViewMode = "table" | "list" | "cards" | "kanban";
|
|
13
|
-
|
|
19
|
+
/** Rows of one table, in the admin panel's collection view (show_table). */
|
|
20
|
+
export interface TableBlock {
|
|
14
21
|
key: string;
|
|
15
|
-
type: "
|
|
16
|
-
|
|
22
|
+
type: "table";
|
|
23
|
+
/** The table's slug, as the tools take it. */
|
|
24
|
+
table: string;
|
|
17
25
|
view?: ViewMode;
|
|
18
26
|
where?: Record<string, unknown>;
|
|
19
27
|
orderBy?: unknown;
|
|
20
28
|
searchString?: string;
|
|
21
29
|
limit?: number;
|
|
22
30
|
}
|
|
31
|
+
/** One row's form, or a new row's (show_record). */
|
|
23
32
|
export interface RecordBlock {
|
|
24
33
|
key: string;
|
|
25
34
|
type: "record";
|
|
26
|
-
|
|
35
|
+
table: string;
|
|
27
36
|
id?: string;
|
|
28
37
|
values?: Record<string, unknown>;
|
|
29
38
|
}
|
|
30
|
-
/** An app the model wrote: compiled CommonJS, and the
|
|
39
|
+
/** An app the model wrote: compiled CommonJS, and the tables it reads. */
|
|
31
40
|
export interface AppBlock {
|
|
32
41
|
key: string;
|
|
33
42
|
type: "app";
|
|
34
43
|
code: string;
|
|
35
|
-
|
|
44
|
+
tables: string[];
|
|
45
|
+
}
|
|
46
|
+
export type Block = TableBlock | RecordBlock | AppBlock;
|
|
47
|
+
/** What the connection's scopes allow on one table. */
|
|
48
|
+
export interface TableGrant {
|
|
49
|
+
read: boolean;
|
|
50
|
+
write: boolean;
|
|
51
|
+
delete: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* How the screen's tables are presented: the UI preference layers the server
|
|
55
|
+
* holds, folded by `<RebaseCMS>` as on the project's page — `file` as its
|
|
56
|
+
* `uiConfig`, then `workspace`, then `user`.
|
|
57
|
+
*/
|
|
58
|
+
export interface ScreenPreferences {
|
|
59
|
+
/** `ui-config.json`, as the server knows it. */
|
|
60
|
+
file: UiPreferences;
|
|
61
|
+
/** The workspace's, stored by the server. */
|
|
62
|
+
workspace: UiPreferences;
|
|
63
|
+
/** The person's own. */
|
|
64
|
+
user: UiPreferences;
|
|
36
65
|
}
|
|
37
|
-
export type Block = CollectionBlock | RecordBlock | AppBlock;
|
|
38
66
|
export interface Screen {
|
|
39
67
|
title?: string;
|
|
40
68
|
blocks: Block[];
|
|
41
|
-
|
|
69
|
+
/** The descriptors the screen draws, as the server serves this caller. */
|
|
70
|
+
tables: TableDescriptor[];
|
|
71
|
+
/** What the connection was granted on each table in {@link tables}, by slug. */
|
|
72
|
+
grants: Record<string, TableGrant>;
|
|
73
|
+
/** How the tables are presented: the server's UI preference layers. */
|
|
74
|
+
preferences: ScreenPreferences;
|
|
42
75
|
viewer: {
|
|
43
76
|
uid: string;
|
|
44
77
|
roles: string[];
|
|
45
78
|
};
|
|
46
79
|
actions: ViewActions;
|
|
47
|
-
/** The page
|
|
80
|
+
/** The page show_table read for the model: what the table block reads first. */
|
|
48
81
|
firstPage?: SeedPage;
|
|
49
|
-
/** The pages show_app read ahead of the app's first render, one per
|
|
82
|
+
/** The pages show_app read ahead of the app's first render, one per table it names. */
|
|
50
83
|
seeds?: SeedPage[];
|
|
51
84
|
}
|
|
52
85
|
export type Parsed = {
|
|
53
86
|
kind: "screen";
|
|
54
87
|
screen: Screen;
|
|
55
|
-
}
|
|
56
|
-
/** A result from before the admin panel's views: the table's own columns. */
|
|
57
|
-
| {
|
|
58
|
-
kind: "table";
|
|
59
88
|
} | {
|
|
60
89
|
kind: "error";
|
|
61
90
|
message: string;
|
|
62
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* The payload version this view draws: `MCP_VIEW_PAYLOAD_VERSION` in the
|
|
94
|
+
* server's `mcp/mcp-view.ts`, bumped together. A host fetches the view for
|
|
95
|
+
* the listing it holds (its address carries the document's hash), so a
|
|
96
|
+
* mismatch is a host holding a stale document.
|
|
97
|
+
*/
|
|
98
|
+
export declare const PAYLOAD_VERSION = 3;
|
|
63
99
|
export declare function parseResult(result: ToolResult): Parsed;
|
|
64
100
|
/**
|
|
65
101
|
* The tools a result says to read and write with, over the defaults. The
|
|
66
102
|
* hosted connector's table named `edit` for what is `update` here.
|
|
67
103
|
*/
|
|
68
104
|
export declare function actionsOf(raw: unknown): ViewActions;
|
|
69
|
-
/** The collection a
|
|
105
|
+
/** The collection a table's slug names: the table's view in the admin panel has the same slug. */
|
|
70
106
|
export declare function findCollection(collections: readonly AdminCollection[], name: string): AdminCollection | undefined;
|
|
71
107
|
/**
|
|
72
108
|
* A block's `where` as the admin panel's filter: each field's condition, or
|
package/dist/mcp_view/payload.js
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { isRecord } from "./bridge.js";
|
|
2
2
|
import { DEFAULT_ACTIONS, textOf } from "./tool_driver.js";
|
|
3
|
-
import { ALL_WHERE_FILTER_OPS,
|
|
4
|
-
//#region src/mcp_view/payload.ts
|
|
5
|
-
/**
|
|
6
|
-
* The screen a show_* tool asked for, read from its result
|
|
7
|
-
* (`McpViewPayload` in the server's `mcp/mcp-view.ts`).
|
|
8
|
-
*
|
|
9
|
-
* A result with no payload is one from a server that only knew the table
|
|
10
|
-
* (show_collection before 0.29): the view draws that table.
|
|
11
|
-
*/
|
|
12
|
-
var PAYLOAD_VERSION = 1;
|
|
3
|
+
import { ALL_WHERE_FILTER_OPS, isUiTablePreferences } from "@rebasepro/types";
|
|
13
4
|
function parseResult(result) {
|
|
14
5
|
if (result.isError) return {
|
|
15
6
|
kind: "error",
|
|
@@ -21,15 +12,15 @@ function parseResult(result) {
|
|
|
21
12
|
message: "This view needs the tool's structured result, and the host did not pass it."
|
|
22
13
|
};
|
|
23
14
|
const view = content.view;
|
|
24
|
-
if (!isRecord(view)) return
|
|
15
|
+
if (!isRecord(view)) return {
|
|
25
16
|
kind: "error",
|
|
26
17
|
message: "The result carries nothing this view can draw."
|
|
27
18
|
};
|
|
28
|
-
if (view.version !==
|
|
19
|
+
if (view.version !== 3) return {
|
|
29
20
|
kind: "error",
|
|
30
|
-
message: "This view is older than the server that answered; it cannot draw this screen."
|
|
21
|
+
message: typeof view.version === "number" && view.version > 3 ? "This view is older than the server that answered; it cannot draw this screen." : "This view is newer than the server that answered; it cannot draw this screen."
|
|
31
22
|
};
|
|
32
|
-
const
|
|
23
|
+
const tables = Array.isArray(view.tables) ? view.tables.filter(isTableDescriptor) : [];
|
|
33
24
|
const blocks = Array.isArray(view.blocks) ? view.blocks.filter(isBlock) : [];
|
|
34
25
|
if (blocks.length === 0) return {
|
|
35
26
|
kind: "error",
|
|
@@ -48,7 +39,9 @@ function parseResult(result) {
|
|
|
48
39
|
screen: {
|
|
49
40
|
...typeof view.title === "string" && { title: view.title },
|
|
50
41
|
blocks,
|
|
51
|
-
|
|
42
|
+
tables,
|
|
43
|
+
grants: grantsOf(view.grants, tables),
|
|
44
|
+
preferences: preferencesOf(view.preferences),
|
|
52
45
|
viewer: {
|
|
53
46
|
uid: typeof viewer.uid === "string" ? viewer.uid : "",
|
|
54
47
|
roles: Array.isArray(viewer.roles) ? viewer.roles.filter((role) => typeof role === "string") : []
|
|
@@ -59,17 +52,49 @@ function parseResult(result) {
|
|
|
59
52
|
}
|
|
60
53
|
};
|
|
61
54
|
}
|
|
55
|
+
/** A descriptor as the wire carries it: checked for the fields the projector reads first. */
|
|
56
|
+
function isTableDescriptor(value) {
|
|
57
|
+
return isRecord(value) && typeof value.slug === "string" && typeof value.table === "string" && Array.isArray(value.columns) && Array.isArray(value.relations) && Array.isArray(value.primaryKey) && isRecord(value.rls);
|
|
58
|
+
}
|
|
59
|
+
/** One layer as sent, keeping only valid table preferences: data from the wire, narrowed like the panel's. */
|
|
60
|
+
function layerOf(raw) {
|
|
61
|
+
const tables = {};
|
|
62
|
+
const listed = isRecord(raw) && isRecord(raw.tables) ? raw.tables : {};
|
|
63
|
+
for (const [slug, preferences] of Object.entries(listed)) if (isUiTablePreferences(preferences)) tables[slug] = preferences;
|
|
64
|
+
return { tables };
|
|
65
|
+
}
|
|
66
|
+
/** The preference layers as sent; an absent layer is empty. */
|
|
67
|
+
function preferencesOf(raw) {
|
|
68
|
+
const sent = isRecord(raw) ? raw : {};
|
|
69
|
+
return {
|
|
70
|
+
file: layerOf(sent.file),
|
|
71
|
+
workspace: layerOf(sent.workspace),
|
|
72
|
+
user: layerOf(sent.user)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** Each table's grant as sent; a table the server sent none for is read-only. */
|
|
76
|
+
function grantsOf(raw, tables) {
|
|
77
|
+
const sent = isRecord(raw) ? raw : {};
|
|
78
|
+
return Object.fromEntries(tables.map((table) => {
|
|
79
|
+
const grant = sent[table.slug];
|
|
80
|
+
return [table.slug, {
|
|
81
|
+
read: !isRecord(grant) || grant.read !== false,
|
|
82
|
+
write: isRecord(grant) && grant.write === true,
|
|
83
|
+
delete: isRecord(grant) && grant.delete === true
|
|
84
|
+
}];
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
62
87
|
/**
|
|
63
|
-
* The rows a
|
|
88
|
+
* The rows a show_table result carries beside its screen — the page the
|
|
64
89
|
* server read for the model — and the arguments that read them: the block's,
|
|
65
90
|
* with the window the server says it read.
|
|
66
91
|
*/
|
|
67
92
|
function firstPageOf(block, content) {
|
|
68
|
-
if (block.type !== "
|
|
93
|
+
if (block.type !== "table" || !Array.isArray(content.data)) return void 0;
|
|
69
94
|
const meta = isRecord(content.meta) ? content.meta : {};
|
|
70
95
|
const limit = typeof meta.limit === "number" ? meta.limit : block.limit;
|
|
71
96
|
return {
|
|
72
|
-
collection: block.
|
|
97
|
+
collection: block.table,
|
|
73
98
|
args: {
|
|
74
99
|
...block.where && { where: block.where },
|
|
75
100
|
...block.orderBy !== void 0 && { orderBy: block.orderBy },
|
|
@@ -82,9 +107,9 @@ function firstPageOf(block, content) {
|
|
|
82
107
|
}
|
|
83
108
|
/** One page show_app read ahead, as the server sent it; nothing for one malformed. */
|
|
84
109
|
function seedOf(value) {
|
|
85
|
-
if (!isRecord(value) || typeof value.
|
|
110
|
+
if (!isRecord(value) || typeof value.table !== "string" || !isRecord(value.args) || !Array.isArray(value.rows)) return [];
|
|
86
111
|
return [{
|
|
87
|
-
collection: value.
|
|
112
|
+
collection: value.table,
|
|
88
113
|
args: value.args,
|
|
89
114
|
rows: value.rows.filter(isRecord),
|
|
90
115
|
...typeof value.total === "number" && { total: value.total }
|
|
@@ -92,8 +117,8 @@ function seedOf(value) {
|
|
|
92
117
|
}
|
|
93
118
|
function isBlock(value) {
|
|
94
119
|
if (!isRecord(value) || typeof value.key !== "string") return false;
|
|
95
|
-
if (value.type === "app") return typeof value.code === "string" && Array.isArray(value.
|
|
96
|
-
return typeof value.
|
|
120
|
+
if (value.type === "app") return typeof value.code === "string" && Array.isArray(value.tables);
|
|
121
|
+
return typeof value.table === "string" && (value.type === "table" || value.type === "record");
|
|
97
122
|
}
|
|
98
123
|
/**
|
|
99
124
|
* The tools a result says to read and write with, over the defaults. The
|
|
@@ -116,9 +141,9 @@ function actionsOf(raw) {
|
|
|
116
141
|
aggregate: action(raw.aggregate, DEFAULT_ACTIONS.aggregate)
|
|
117
142
|
};
|
|
118
143
|
}
|
|
119
|
-
/** The collection a
|
|
144
|
+
/** The collection a table's slug names: the table's view in the admin panel has the same slug. */
|
|
120
145
|
function findCollection(collections, name) {
|
|
121
|
-
return collections.find((collection) =>
|
|
146
|
+
return collections.find((collection) => collection.slug === name);
|
|
122
147
|
}
|
|
123
148
|
/**
|
|
124
149
|
* A block's `where` as the admin panel's filter: each field's condition, or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload.js","names":[],"sources":["../../src/mcp_view/payload.ts"],"sourcesContent":["/**\n * The screen a show_* tool asked for, read from its result\n * (`McpViewPayload` in the server's `mcp/mcp-view.ts`).\n *\n * A result with no payload is one from a server that only knew the table\n * (show_collection before 0.29): the view draws that table.\n */\nimport {\n ALL_WHERE_FILTER_OPS,\n deserializeCollections,\n getCollectionDataPath,\n type CollectionConfig,\n type FilterValues,\n type WhereFilterOp\n} from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { isRecord, type ToolResult } from \"./bridge\";\nimport { DEFAULT_ACTIONS, textOf, type SeedPage, type ToolAction, type ViewActions } from \"./tool_driver\";\n\nexport type ViewMode = \"table\" | \"list\" | \"cards\" | \"kanban\";\n\nexport interface CollectionBlock {\n key: string;\n type: \"collection\";\n collection: string;\n view?: ViewMode;\n where?: Record<string, unknown>;\n orderBy?: unknown;\n searchString?: string;\n limit?: number;\n}\n\nexport interface RecordBlock {\n key: string;\n type: \"record\";\n collection: string;\n id?: string;\n values?: Record<string, unknown>;\n}\n\n/** An app the model wrote: compiled CommonJS, and the collections it reads. */\nexport interface AppBlock {\n key: string;\n type: \"app\";\n code: string;\n collections: string[];\n}\n\nexport type Block = CollectionBlock | RecordBlock | AppBlock;\n\nexport interface Screen {\n title?: string;\n blocks: Block[];\n collections: AdminCollection[];\n viewer: { uid: string; roles: string[] };\n actions: ViewActions;\n /** The page show_collection read for the model: what the collection block reads first. */\n firstPage?: SeedPage;\n /** The pages show_app read ahead of the app's first render, one per collection it names. */\n seeds?: SeedPage[];\n}\n\nexport type Parsed =\n | { kind: \"screen\"; screen: Screen }\n /** A result from before the admin panel's views: the table's own columns. */\n | { kind: \"table\" }\n | { kind: \"error\"; message: string };\n\nconst PAYLOAD_VERSION = 1;\n\nexport function parseResult(result: ToolResult): Parsed {\n if (result.isError) return { kind: \"error\", message: textOf(result) ?? \"The view could not be opened.\" };\n const content = result.structuredContent;\n if (!isRecord(content)) {\n return { kind: \"error\", message: \"This view needs the tool's structured result, and the host did not pass it.\" };\n }\n const view = content.view;\n if (!isRecord(view)) {\n return Array.isArray(content.columns)\n ? { kind: \"table\" }\n : { kind: \"error\", message: \"The result carries nothing this view can draw.\" };\n }\n if (view.version !== PAYLOAD_VERSION) {\n return { kind: \"error\", message: \"This view is older than the server that answered; it cannot draw this screen.\" };\n }\n const collections = Array.isArray(view.collections)\n ? deserializeCollections(view.collections) as AdminCollection[]\n : [];\n const blocks = Array.isArray(view.blocks) ? view.blocks.filter(isBlock) : [];\n if (blocks.length === 0) return { kind: \"error\", message: \"The screen has no blocks.\" };\n const viewer = isRecord(view.viewer) ? view.viewer : {};\n // When the server read the rows the result carries: they are that old\n // however late the host draws it. A server from before the stamp sends none.\n const readAt = typeof view.readAt === \"number\" && Number.isFinite(view.readAt) ? view.readAt : undefined;\n const stamped = (page: SeedPage): SeedPage => readAt === undefined ? page : { ...page, readAt };\n const firstPage = firstPageOf(blocks[0], content);\n const seeds = Array.isArray(view.seeds) ? view.seeds.flatMap(seedOf).map(stamped) : [];\n return {\n kind: \"screen\",\n screen: {\n ...(typeof view.title === \"string\" && { title: view.title }),\n blocks,\n collections,\n viewer: {\n uid: typeof viewer.uid === \"string\" ? viewer.uid : \"\",\n roles: Array.isArray(viewer.roles) ? viewer.roles.filter((role): role is string => typeof role === \"string\") : []\n },\n actions: actionsOf(content.actions),\n ...(firstPage && { firstPage: stamped(firstPage) }),\n ...(seeds.length > 0 && { seeds })\n }\n };\n}\n\n/**\n * The rows a show_collection result carries beside its screen — the page the\n * server read for the model — and the arguments that read them: the block's,\n * with the window the server says it read.\n */\nfunction firstPageOf(block: Block, content: Record<string, unknown>): SeedPage | undefined {\n if (block.type !== \"collection\" || !Array.isArray(content.data)) return undefined;\n const meta = isRecord(content.meta) ? content.meta : {};\n const limit = typeof meta.limit === \"number\" ? meta.limit : block.limit;\n return {\n collection: block.collection,\n args: {\n ...(block.where && { where: block.where }),\n ...(block.orderBy !== undefined && { orderBy: block.orderBy }),\n ...(block.searchString && { searchString: block.searchString }),\n ...(limit !== undefined && { limit }),\n ...(typeof meta.offset === \"number\" && { offset: meta.offset })\n },\n rows: content.data.filter(isRecord)\n };\n}\n\n/** One page show_app read ahead, as the server sent it; nothing for one malformed. */\nfunction seedOf(value: unknown): SeedPage[] {\n if (!isRecord(value) || typeof value.collection !== \"string\" || !isRecord(value.args) || !Array.isArray(value.rows)) return [];\n return [{\n collection: value.collection,\n args: value.args,\n rows: value.rows.filter(isRecord),\n ...(typeof value.total === \"number\" && { total: value.total })\n }];\n}\n\nfunction isBlock(value: unknown): value is Block {\n if (!isRecord(value) || typeof value.key !== \"string\") return false;\n if (value.type === \"app\") return typeof value.code === \"string\" && Array.isArray(value.collections);\n return typeof value.collection === \"string\" && (value.type === \"collection\" || value.type === \"record\");\n}\n\n/**\n * The tools a result says to read and write with, over the defaults. The\n * hosted connector's table named `edit` for what is `update` here.\n */\nexport function actionsOf(raw: unknown): ViewActions {\n if (!isRecord(raw)) return DEFAULT_ACTIONS;\n const action = (value: unknown, fallback: ToolAction): ToolAction => isRecord(value) && typeof value.tool === \"string\"\n ? { tool: value.tool, arguments: isRecord(value.arguments) ? value.arguments : {}, ...(value.plans === true && { plans: true }) }\n : fallback;\n return {\n page: action(raw.page, DEFAULT_ACTIONS.page),\n get: action(raw.get, DEFAULT_ACTIONS.get),\n count: action(raw.count, DEFAULT_ACTIONS.count),\n create: action(raw.create, DEFAULT_ACTIONS.create),\n update: action(raw.update ?? raw.edit, DEFAULT_ACTIONS.update),\n delete: action(raw.delete, DEFAULT_ACTIONS.delete),\n aggregate: action(raw.aggregate, DEFAULT_ACTIONS.aggregate)\n };\n}\n\n/** The collection a block names: by the name the tools take, which is its data path, or by slug. */\nexport function findCollection(collections: readonly AdminCollection[], name: string): AdminCollection | undefined {\n return collections.find(collection => getCollectionDataPath(collection as CollectionConfig) === name)\n ?? collections.find(collection => collection.slug === name);\n}\n\n/**\n * A block's `where` as the admin panel's filter: each field's condition, or\n * list of conditions, kept where it is one the read tools take. The server\n * checked it before it opened the screen.\n */\nexport function filterOf(where: Record<string, unknown> | undefined): FilterValues<string> | undefined {\n if (!where) return undefined;\n const filter: FilterValues<string> = {};\n for (const [key, raw] of Object.entries(where)) {\n const single = conditionOf(raw);\n if (single) {\n filter[key] = single;\n } else if (Array.isArray(raw)) {\n const conditions = raw.map(conditionOf).filter((entry): entry is [WhereFilterOp, unknown] => entry !== undefined);\n if (conditions.length > 0 && conditions.length === raw.length) filter[key] = conditions;\n }\n }\n return filter;\n}\n\nfunction conditionOf(raw: unknown): [WhereFilterOp, unknown] | undefined {\n if (!Array.isArray(raw) || raw.length !== 2) return undefined;\n const op = ALL_WHERE_FILTER_OPS.find(candidate => candidate === raw[0]);\n return op ? [op, raw[1]] : undefined;\n}\n\n/** A sort as the collection view takes it: its first key. */\nexport function orderOf(raw: unknown): [string, \"asc\" | \"desc\"] | undefined {\n if (typeof raw === \"string\" && raw !== \"\") {\n const [field, direction] = raw.split(\":\");\n return [field, direction === \"desc\" ? \"desc\" : \"asc\"];\n }\n if (Array.isArray(raw) && raw.length > 0) {\n const first: unknown[] = Array.isArray(raw[0]) ? raw[0] : raw;\n if (typeof first[0] === \"string\") return [first[0], first[1] === \"desc\" ? \"desc\" : \"asc\"];\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;AAoEA,IAAM,kBAAkB;AAExB,SAAgB,YAAY,QAA4B;CACpD,IAAI,OAAO,SAAS,OAAO;EAAE,MAAM;EAAS,SAAS,OAAO,MAAM,KAAK;CAAgC;CACvG,MAAM,UAAU,OAAO;CACvB,IAAI,CAAC,SAAS,OAAO,GACjB,OAAO;EAAE,MAAM;EAAS,SAAS;CAA8E;CAEnH,MAAM,OAAO,QAAQ;CACrB,IAAI,CAAC,SAAS,IAAI,GACd,OAAO,MAAM,QAAQ,QAAQ,OAAO,IAC9B,EAAE,MAAM,QAAQ,IAChB;EAAE,MAAM;EAAS,SAAS;C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C,IAAI,IAAI,EAAE,IAAI,KAAA;AAC/B;;AAGA,SAAgB,QAAQ,KAAoD;CACxE,IAAI,OAAO,QAAQ,YAAY,QAAQ,IAAI;EACvC,MAAM,CAAC,OAAO,aAAa,IAAI,MAAM,GAAG;EACxC,OAAO,CAAC,OAAO,cAAc,SAAS,SAAS,KAAK;CACxD;CACA,IAAI,MAAM,QAAQ,GAAG,KAAK,IAAI,SAAS,GAAG;EACtC,MAAM,QAAmB,MAAM,QAAQ,IAAI,EAAE,IAAI,IAAI,KAAK;EAC1D,IAAI,OAAO,MAAM,OAAO,UAAU,OAAO,CAAC,MAAM,IAAI,MAAM,OAAO,SAAS,SAAS,KAAK;CAC5F;AAEJ"}
|
|
1
|
+
{"version":3,"file":"payload.js","names":[],"sources":["../../src/mcp_view/payload.ts"],"sourcesContent":["/**\n * The screen a show_* tool asked for, read from its result\n * (`McpViewPayload` in the server's `mcp/mcp-view.ts`).\n *\n * The payload carries the descriptors of the tables the screen draws, as the\n * server serves this caller (columns they may not read and raw policy SQL\n * already left out), and what the connection was granted on each. The view\n * renders them as the admin panel renders the tables `GET /api/schema/tables`\n * serves: projected, with the project's `customizeTable` customizations where\n * the view was built from the project's frontend, then the UI preferences the\n * payload carries (the workspace's and the caller's), folded as the panel\n * folds them.\n */\nimport {\n ALL_WHERE_FILTER_OPS,\n isUiTablePreferences,\n type FilterValues,\n type TableDescriptor,\n type UiPreferences,\n type WhereFilterOp\n} from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { isRecord, type ToolResult } from \"./bridge\";\nimport { DEFAULT_ACTIONS, textOf, type SeedPage, type ToolAction, type ViewActions } from \"./tool_driver\";\n\nexport type ViewMode = \"table\" | \"list\" | \"cards\" | \"kanban\";\n\n/** Rows of one table, in the admin panel's collection view (show_table). */\nexport interface TableBlock {\n key: string;\n type: \"table\";\n /** The table's slug, as the tools take it. */\n table: string;\n view?: ViewMode;\n where?: Record<string, unknown>;\n orderBy?: unknown;\n searchString?: string;\n limit?: number;\n}\n\n/** One row's form, or a new row's (show_record). */\nexport interface RecordBlock {\n key: string;\n type: \"record\";\n table: string;\n id?: string;\n values?: Record<string, unknown>;\n}\n\n/** An app the model wrote: compiled CommonJS, and the tables it reads. */\nexport interface AppBlock {\n key: string;\n type: \"app\";\n code: string;\n tables: string[];\n}\n\nexport type Block = TableBlock | RecordBlock | AppBlock;\n\n/** What the connection's scopes allow on one table. */\nexport interface TableGrant {\n read: boolean;\n write: boolean;\n delete: boolean;\n}\n\n/**\n * How the screen's tables are presented: the UI preference layers the server\n * holds, folded by `<RebaseCMS>` as on the project's page — `file` as its\n * `uiConfig`, then `workspace`, then `user`.\n */\nexport interface ScreenPreferences {\n /** `ui-config.json`, as the server knows it. */\n file: UiPreferences;\n /** The workspace's, stored by the server. */\n workspace: UiPreferences;\n /** The person's own. */\n user: UiPreferences;\n}\n\nexport interface Screen {\n title?: string;\n blocks: Block[];\n /** The descriptors the screen draws, as the server serves this caller. */\n tables: TableDescriptor[];\n /** What the connection was granted on each table in {@link tables}, by slug. */\n grants: Record<string, TableGrant>;\n /** How the tables are presented: the server's UI preference layers. */\n preferences: ScreenPreferences;\n viewer: { uid: string; roles: string[] };\n actions: ViewActions;\n /** The page show_table read for the model: what the table block reads first. */\n firstPage?: SeedPage;\n /** The pages show_app read ahead of the app's first render, one per table it names. */\n seeds?: SeedPage[];\n}\n\nexport type Parsed =\n | { kind: \"screen\"; screen: Screen }\n | { kind: \"error\"; message: string };\n\n/**\n * The payload version this view draws: `MCP_VIEW_PAYLOAD_VERSION` in the\n * server's `mcp/mcp-view.ts`, bumped together. A host fetches the view for\n * the listing it holds (its address carries the document's hash), so a\n * mismatch is a host holding a stale document.\n */\nexport const PAYLOAD_VERSION = 3;\n\nexport function parseResult(result: ToolResult): Parsed {\n if (result.isError) return { kind: \"error\", message: textOf(result) ?? \"The view could not be opened.\" };\n const content = result.structuredContent;\n if (!isRecord(content)) {\n return { kind: \"error\", message: \"This view needs the tool's structured result, and the host did not pass it.\" };\n }\n const view = content.view;\n if (!isRecord(view)) return { kind: \"error\", message: \"The result carries nothing this view can draw.\" };\n if (view.version !== PAYLOAD_VERSION) {\n return {\n kind: \"error\",\n message: typeof view.version === \"number\" && view.version > PAYLOAD_VERSION\n ? \"This view is older than the server that answered; it cannot draw this screen.\"\n : \"This view is newer than the server that answered; it cannot draw this screen.\"\n };\n }\n const tables = Array.isArray(view.tables) ? view.tables.filter(isTableDescriptor) : [];\n const blocks = Array.isArray(view.blocks) ? view.blocks.filter(isBlock) : [];\n if (blocks.length === 0) return { kind: \"error\", message: \"The screen has no blocks.\" };\n const viewer = isRecord(view.viewer) ? view.viewer : {};\n // When the server read the rows the result carries: they are that old\n // however late the host draws it.\n const readAt = typeof view.readAt === \"number\" && Number.isFinite(view.readAt) ? view.readAt : undefined;\n const stamped = (page: SeedPage): SeedPage => readAt === undefined ? page : { ...page, readAt };\n const firstPage = firstPageOf(blocks[0], content);\n const seeds = Array.isArray(view.seeds) ? view.seeds.flatMap(seedOf).map(stamped) : [];\n return {\n kind: \"screen\",\n screen: {\n ...(typeof view.title === \"string\" && { title: view.title }),\n blocks,\n tables,\n grants: grantsOf(view.grants, tables),\n preferences: preferencesOf(view.preferences),\n viewer: {\n uid: typeof viewer.uid === \"string\" ? viewer.uid : \"\",\n roles: Array.isArray(viewer.roles) ? viewer.roles.filter((role): role is string => typeof role === \"string\") : []\n },\n actions: actionsOf(content.actions),\n ...(firstPage && { firstPage: stamped(firstPage) }),\n ...(seeds.length > 0 && { seeds })\n }\n };\n}\n\n/** A descriptor as the wire carries it: checked for the fields the projector reads first. */\nfunction isTableDescriptor(value: unknown): value is TableDescriptor {\n return isRecord(value)\n && typeof value.slug === \"string\"\n && typeof value.table === \"string\"\n && Array.isArray(value.columns)\n && Array.isArray(value.relations)\n && Array.isArray(value.primaryKey)\n && isRecord(value.rls);\n}\n\n/** One layer as sent, keeping only valid table preferences: data from the wire, narrowed like the panel's. */\nfunction layerOf(raw: unknown): UiPreferences {\n const tables: UiPreferences[\"tables\"] = {};\n const listed = isRecord(raw) && isRecord(raw.tables) ? raw.tables : {};\n for (const [slug, preferences] of Object.entries(listed)) {\n if (isUiTablePreferences(preferences)) tables[slug] = preferences;\n }\n return { tables };\n}\n\n/** The preference layers as sent; an absent layer is empty. */\nfunction preferencesOf(raw: unknown): ScreenPreferences {\n const sent = isRecord(raw) ? raw : {};\n return { file: layerOf(sent.file), workspace: layerOf(sent.workspace), user: layerOf(sent.user) };\n}\n\n/** Each table's grant as sent; a table the server sent none for is read-only. */\nfunction grantsOf(raw: unknown, tables: readonly TableDescriptor[]): Record<string, TableGrant> {\n const sent = isRecord(raw) ? raw : {};\n return Object.fromEntries(tables.map(table => {\n const grant = sent[table.slug];\n return [table.slug, {\n read: !isRecord(grant) || grant.read !== false,\n write: isRecord(grant) && grant.write === true,\n delete: isRecord(grant) && grant.delete === true\n }];\n }));\n}\n\n/**\n * The rows a show_table result carries beside its screen — the page the\n * server read for the model — and the arguments that read them: the block's,\n * with the window the server says it read.\n */\nfunction firstPageOf(block: Block, content: Record<string, unknown>): SeedPage | undefined {\n if (block.type !== \"table\" || !Array.isArray(content.data)) return undefined;\n const meta = isRecord(content.meta) ? content.meta : {};\n const limit = typeof meta.limit === \"number\" ? meta.limit : block.limit;\n return {\n collection: block.table,\n args: {\n ...(block.where && { where: block.where }),\n ...(block.orderBy !== undefined && { orderBy: block.orderBy }),\n ...(block.searchString && { searchString: block.searchString }),\n ...(limit !== undefined && { limit }),\n ...(typeof meta.offset === \"number\" && { offset: meta.offset })\n },\n rows: content.data.filter(isRecord)\n };\n}\n\n/** One page show_app read ahead, as the server sent it; nothing for one malformed. */\nfunction seedOf(value: unknown): SeedPage[] {\n if (!isRecord(value) || typeof value.table !== \"string\" || !isRecord(value.args) || !Array.isArray(value.rows)) return [];\n return [{\n collection: value.table,\n args: value.args,\n rows: value.rows.filter(isRecord),\n ...(typeof value.total === \"number\" && { total: value.total })\n }];\n}\n\nfunction isBlock(value: unknown): value is Block {\n if (!isRecord(value) || typeof value.key !== \"string\") return false;\n if (value.type === \"app\") return typeof value.code === \"string\" && Array.isArray(value.tables);\n return typeof value.table === \"string\" && (value.type === \"table\" || value.type === \"record\");\n}\n\n/**\n * The tools a result says to read and write with, over the defaults. The\n * hosted connector's table named `edit` for what is `update` here.\n */\nexport function actionsOf(raw: unknown): ViewActions {\n if (!isRecord(raw)) return DEFAULT_ACTIONS;\n const action = (value: unknown, fallback: ToolAction): ToolAction => isRecord(value) && typeof value.tool === \"string\"\n ? { tool: value.tool, arguments: isRecord(value.arguments) ? value.arguments : {}, ...(value.plans === true && { plans: true }) }\n : fallback;\n return {\n page: action(raw.page, DEFAULT_ACTIONS.page),\n get: action(raw.get, DEFAULT_ACTIONS.get),\n count: action(raw.count, DEFAULT_ACTIONS.count),\n create: action(raw.create, DEFAULT_ACTIONS.create),\n update: action(raw.update ?? raw.edit, DEFAULT_ACTIONS.update),\n delete: action(raw.delete, DEFAULT_ACTIONS.delete),\n aggregate: action(raw.aggregate, DEFAULT_ACTIONS.aggregate)\n };\n}\n\n/** The collection a table's slug names: the table's view in the admin panel has the same slug. */\nexport function findCollection(collections: readonly AdminCollection[], name: string): AdminCollection | undefined {\n return collections.find(collection => collection.slug === name);\n}\n\n/**\n * A block's `where` as the admin panel's filter: each field's condition, or\n * list of conditions, kept where it is one the read tools take. The server\n * checked it before it opened the screen.\n */\nexport function filterOf(where: Record<string, unknown> | undefined): FilterValues<string> | undefined {\n if (!where) return undefined;\n const filter: FilterValues<string> = {};\n for (const [key, raw] of Object.entries(where)) {\n const single = conditionOf(raw);\n if (single) {\n filter[key] = single;\n } else if (Array.isArray(raw)) {\n const conditions = raw.map(conditionOf).filter((entry): entry is [WhereFilterOp, unknown] => entry !== undefined);\n if (conditions.length > 0 && conditions.length === raw.length) filter[key] = conditions;\n }\n }\n return filter;\n}\n\nfunction conditionOf(raw: unknown): [WhereFilterOp, unknown] | undefined {\n if (!Array.isArray(raw) || raw.length !== 2) return undefined;\n const op = ALL_WHERE_FILTER_OPS.find(candidate => candidate === raw[0]);\n return op ? [op, raw[1]] : undefined;\n}\n\n/** A sort as the collection view takes it: its first key. */\nexport function orderOf(raw: unknown): [string, \"asc\" | \"desc\"] | undefined {\n if (typeof raw === \"string\" && raw !== \"\") {\n const [field, direction] = raw.split(\":\");\n return [field, direction === \"desc\" ? \"desc\" : \"asc\"];\n }\n if (Array.isArray(raw) && raw.length > 0) {\n const first: unknown[] = Array.isArray(raw[0]) ? raw[0] : raw;\n if (typeof first[0] === \"string\") return [first[0], first[1] === \"desc\" ? \"desc\" : \"asc\"];\n }\n return undefined;\n}\n"],"mappings":";;;AA6GA,SAAgB,YAAY,QAA4B;CACpD,IAAI,OAAO,SAAS,OAAO;EAAE,MAAM;EAAS,SAAS,OAAO,MAAM,KAAK;CAAgC;CACvG,MAAM,UAAU,OAAO;CACvB,IAAI,CAAC,SAAS,OAAO,GACjB,OAAO;EAAE,MAAM;EAAS,SAAS;CAA8E;CAEnH,MAAM,OAAO,QAAQ;CACrB,IAAI,CAAC,SAAS,IAAI,GAAG,OAAO;EAAE,MAAM;EAAS,SAAS;CAAiD;CACvG,IAAI,KAAK,YAAA,GACL,OAAO;EACH,MAAM;EACN,SAAS,OAAO,KAAK,YAAY,YAAY,KAAK,UAAA,IAC5C,kFACA;CACV;CAEJ,MAAM,SAAS,MAAM,QAAQ,KAAK,MAAM,IAAI,KAAK,OAAO,OAAO,iBAAiB,IAAI,CAAC;CACrF,MAAM,SAAS,MAAM,QAAQ,KAAK,MAAM,IAAI,KAAK,OAAO,OAAO,OAAO,IAAI,CAAC;CAC3E,IAAI,OAAO,WAAW,GAAG,OAAO;EAAE,MAAM;EAAS,SAAS;CAA4B;CACtF,MAAM,SAAS,SAAS,KAAK,MAAM,IAAI,KAAK,SAAS,CAAC;CAGtD,MAAM,SAAS,OAAO,KAAK,WAAW,YAAY,OAAO,SAAS,KAAK,MAAM,IAAI,KAAK,SAAS,KAAA;CAC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,SAAS,OAA8E;CACnG,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,MAAM,SAA+B,CAAC;CACtC,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,KAAK,GAAG;EAC5C,MAAM,SAAS,YAAY,GAAG;EAC9B,IAAI,QACA,OAAO,OAAO;OACX,IAAI,MAAM,QAAQ,GAAG,GAAG;GAC3B,MAAM,aAAa,IAAI,IAAI,WAAW,CAAC,CAAC,QAAQ,UAA6C,UAAU,KAAA,CAAS;GAChH,IAAI,WAAW,SAAS,KAAK,WAAW,WAAW,IAAI,QAAQ,OAAO,OAAO;EACjF;CACJ;CACA,OAAO;AACX;AAEA,SAAS,YAAY,KAAoD;CACrE,IAAI,CAAC,MAAM,QAAQ,GAAG,KAAK,IAAI,WAAW,GAAG,OAAO,KAAA;CACpD,MAAM,KAAK,qBAAqB,MAAK,cAAa,cAAc,IAAI,EAAE;CACtE,OAAO,KAAK,CAAC,IAAI,IAAI,EAAE,IAAI,KAAA;AAC/B;;AAGA,SAAgB,QAAQ,KAAoD;CACxE,IAAI,OAAO,QAAQ,YAAY,QAAQ,IAAI;EACvC,MAAM,CAAC,OAAO,aAAa,IAAI,MAAM,GAAG;EACxC,OAAO,CAAC,OAAO,cAAc,SAAS,SAAS,KAAK;CACxD;CACA,IAAI,MAAM,QAAQ,GAAG,KAAK,IAAI,SAAS,GAAG;EACtC,MAAM,QAAmB,MAAM,QAAQ,IAAI,EAAE,IAAI,IAAI,KAAK;EAC1D,IAAI,OAAO,MAAM,OAAO,UAAU,OAAO,CAAC,MAAM,IAAI,MAAM,OAAO,SAAS,SAAS,KAAK;CAC5F;AAEJ"}
|
package/dist/mcp_view/screen.js
CHANGED
|
@@ -53,7 +53,7 @@ function McpScreen({ bridge, screen, hostContext, pendingPlan, writeFailure, sav
|
|
|
53
53
|
return () => observer.disconnect();
|
|
54
54
|
}, [bridge]);
|
|
55
55
|
const collectionOf = (name) => registry.getCollection(name);
|
|
56
|
-
const heading = screen.title ?? (block.type === "app" ? void 0 : blockTitle(block, collectionOf(block.
|
|
56
|
+
const heading = screen.title ?? (block.type === "app" ? void 0 : blockTitle(block, collectionOf(block.table)));
|
|
57
57
|
let body;
|
|
58
58
|
if (!registry.initialised && !registry.collections?.length) body = /* @__PURE__ */ jsx(CircularProgress, { size: "smallest" });
|
|
59
59
|
else if (block.type === "app") body = /* @__PURE__ */ jsx(AppView, {
|
|
@@ -61,16 +61,16 @@ function McpScreen({ bridge, screen, hostContext, pendingPlan, writeFailure, sav
|
|
|
61
61
|
onError: onAppError
|
|
62
62
|
});
|
|
63
63
|
else {
|
|
64
|
-
const collection = collectionOf(block.
|
|
64
|
+
const collection = collectionOf(block.table);
|
|
65
65
|
body = !collection ? /* @__PURE__ */ jsxs(Alert, {
|
|
66
66
|
color: "error",
|
|
67
67
|
size: "small",
|
|
68
68
|
children: [
|
|
69
|
-
"The
|
|
70
|
-
block.
|
|
69
|
+
"The table \"",
|
|
70
|
+
block.table,
|
|
71
71
|
"\" is not in this view."
|
|
72
72
|
]
|
|
73
|
-
}) : block.type === "
|
|
73
|
+
}) : block.type === "table" ? /* @__PURE__ */ jsx(TableView, {
|
|
74
74
|
block,
|
|
75
75
|
collection
|
|
76
76
|
}) : /* @__PURE__ */ jsx(RecordView, {
|
|
@@ -122,18 +122,18 @@ function McpScreen({ bridge, screen, hostContext, pendingPlan, writeFailure, sav
|
|
|
122
122
|
}
|
|
123
123
|
function blockTitle(block, collection) {
|
|
124
124
|
if (block.type === "record") {
|
|
125
|
-
const name = collection?.singularName ?? collection?.name ?? block.
|
|
125
|
+
const name = collection?.singularName ?? collection?.name ?? block.table;
|
|
126
126
|
return block.id === void 0 ? `New ${name.toLowerCase()}` : name;
|
|
127
127
|
}
|
|
128
|
-
return collection?.name ?? block.
|
|
128
|
+
return collection?.name ?? block.table;
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
|
-
*
|
|
131
|
+
* show_table: the admin panel's collection view of the table, where a row opens its
|
|
132
132
|
* form over the screen. It sizes to its rows, up to what the screen leaves
|
|
133
133
|
* it — inline, the screen's height cap; full screen, the window — and then
|
|
134
134
|
* scrolls inside.
|
|
135
135
|
*/
|
|
136
|
-
function
|
|
136
|
+
function TableView({ block, collection }) {
|
|
137
137
|
const overrides = useMemo(() => {
|
|
138
138
|
const where = filterOf(block.where);
|
|
139
139
|
return {
|
|
@@ -168,7 +168,7 @@ function RecordView({ block, collection }) {
|
|
|
168
168
|
});
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
171
|
-
* show_app: the app the model wrote, held to the
|
|
171
|
+
* show_app: the app the model wrote, held to the tables it was opened
|
|
172
172
|
* with, and its failure shown in its place.
|
|
173
173
|
*/
|
|
174
174
|
function AppView({ block, onError }) {
|
|
@@ -193,7 +193,7 @@ function AppView({ block, onError }) {
|
|
|
193
193
|
onError,
|
|
194
194
|
fallback: failure,
|
|
195
195
|
children: /* @__PURE__ */ jsx(AppCollections, {
|
|
196
|
-
names: block.
|
|
196
|
+
names: block.tables,
|
|
197
197
|
children: /* @__PURE__ */ jsx(Component, {})
|
|
198
198
|
})
|
|
199
199
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screen.js","names":[],"sources":["../../src/mcp_view/screen.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport {\n Alert,\n Card,\n CircularProgress,\n IconButton,\n Maximize2Icon,\n Tooltip,\n Typography,\n cls,\n iconSize\n} from \"@rebasepro/ui\";\nimport { CollectionPanel } from \"../components/CollectionPanel\";\nimport { RecordForm } from \"../components/RecordForm\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport type { HostContext, ViewBridge } from \"./bridge\";\nimport { describeFailedWrite, type WriteFailure, type WriteIntent, type WritePlan } from \"./tool_driver\";\nimport { SavedNotice, WriteConfirmDialog } from \"./write_review\";\nimport { filterOf, orderOf, type AppBlock, type CollectionBlock, type RecordBlock, type Screen } from \"./payload\";\nimport { AppErrorBoundary, loadApp, type AppError } from \"./code_app\";\nimport { AppCollections } from \"./app_modules\";\nimport { createViewStore, useViewStore, type ViewStore } from \"./store\";\n\n/**\n * The tallest the screen is in the conversation; past it, a collection\n * scrolls inside its own block, and anything else inside the screen. A\n * record's form and the confirmation of a save open over the frame, centred\n * in it: in a frame as tall as everything on the screen they would open where\n * the person is not looking.\n */\nconst INLINE_MAX_HEIGHT = 640;\n\n/** A write's plan waiting for the person's answer. */\nexport interface PendingPlan {\n plan: WritePlan;\n answer: (confirmed: boolean) => void;\n}\n\nexport interface McpScreenProps {\n bridge: ViewBridge;\n screen: Screen;\n /** The host's context, as it changes. */\n hostContext: ViewStore<HostContext>;\n /** The write plan to confirm, as it changes. */\n pendingPlan: ViewStore<PendingPlan | undefined>;\n /** A write that went through without asking, to say what it changed. */\n savedWrite: ViewStore<WriteIntent | undefined>;\n /** The last write the server refused, as it changes: shown to the person, once each. */\n writeFailure?: ViewStore<WriteFailure | undefined>;\n onAppError: (error: AppError) => void;\n}\n\n/**\n * What the embedded app's shell draws (`renderCms` of the embed host): the\n * one block the tool opened — a collection, a record, or an app the model\n * wrote — inside the providers the app's own `<RebaseShell>` set up, so its\n * collections, custom views, entity views, fields and actions are the ones\n * drawn.\n */\nexport function McpScreen({ bridge, screen, hostContext, pendingPlan, writeFailure, savedWrite, onAppError }: McpScreenProps) {\n const rootRef = useRef<HTMLDivElement>(null);\n const context = useViewStore(hostContext);\n const pending = useViewStore(pendingPlan);\n const saved = useViewStore(savedWrite);\n const dismissSaved = useCallback(() => savedWrite.set(undefined), [savedWrite]);\n const [refused, dismissRefused] = useRefusedWrite(writeFailure);\n const registry = useCollectionRegistryController();\n const fullscreen = context.displayMode === \"fullscreen\";\n const canExpand = !fullscreen && context.availableDisplayModes?.includes(\"fullscreen\") === true;\n const block = screen.blocks[0];\n\n // The host sizes the frame to the document, which it cannot measure\n // across the sandbox.\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n const measure = () => {\n const html = document.documentElement;\n const previous = html.style.height;\n html.style.height = \"max-content\";\n bridge.sizeChanged(Math.ceil(html.getBoundingClientRect().height));\n html.style.height = previous;\n };\n const observer = new ResizeObserver(measure);\n observer.observe(root);\n measure();\n return () => observer.disconnect();\n }, [bridge]);\n\n const collectionOf = (name: string): AdminCollection | undefined => registry.getCollection(name);\n const heading = screen.title ?? (block.type === \"app\" ? undefined : blockTitle(block, collectionOf(block.collection)));\n\n let body: React.ReactNode;\n if (!registry.initialised && !registry.collections?.length) {\n body = <CircularProgress size=\"smallest\"/>;\n } else if (block.type === \"app\") {\n body = <AppView block={block} onError={onAppError}/>;\n } else {\n const collection = collectionOf(block.collection);\n body = !collection\n ? <Alert color=\"error\" size=\"small\">The collection "{block.collection}" is not in this view.</Alert>\n : block.type === \"collection\"\n ? <CollectionView block={block} collection={collection}/>\n : <RecordView block={block} collection={collection}/>;\n }\n\n return (\n <div ref={rootRef}\n className={cls(\"flex flex-col gap-4 p-4 w-full min-w-0 bg-surface-sheet text-text-primary dark:text-text-primary-dark overflow-y-auto\", fullscreen && \"h-screen\")}\n style={fullscreen ? undefined : { maxHeight: INLINE_MAX_HEIGHT }}>\n {(heading || canExpand) && (\n <div className=\"flex items-center justify-between gap-3 min-h-8\">\n <Typography variant=\"subtitle2\" noWrap>{heading}</Typography>\n {canExpand && (\n <Tooltip title=\"Expand\">\n <IconButton\n size=\"small\"\n aria-label=\"Expand\"\n onClick={() => void bridge.requestDisplayMode(\"fullscreen\").catch(() => undefined)}\n >\n <Maximize2Icon size={iconSize.smallest}/>\n </IconButton>\n </Tooltip>\n )}\n </div>\n )}\n {refused && (\n // Sticky: the inline frame scrolls inside, and the button that\n // wrote may be far below its top.\n <Alert color=\"error\" size=\"small\" outerClassName=\"sticky top-0 z-10\" onDismiss={dismissRefused}>\n {`Could not ${describeFailedWrite(refused)}: ${refused.message}`}\n </Alert>\n )}\n <SavedNotice intent={saved} collectionOf={collectionOf} onDismiss={dismissSaved}/>\n {body}\n <WriteConfirmDialog plan={pending?.plan}\n collectionOf={collectionOf}\n onAnswer={confirmed => pending?.answer(confirmed)}/>\n </div>\n );\n}\n\nfunction blockTitle(block: CollectionBlock | RecordBlock, collection: AdminCollection | undefined): string {\n if (block.type === \"record\") {\n const name = collection?.singularName ?? collection?.name ?? block.collection;\n return block.id === undefined ? `New ${name.toLowerCase()}` : name;\n }\n return collection?.name ?? block.collection;\n}\n\n/**\n * show_collection: the admin panel's collection view, where a row opens its\n * form over the screen. It sizes to its rows, up to what the screen leaves\n * it — inline, the screen's height cap; full screen, the window — and then\n * scrolls inside.\n */\nfunction CollectionView({ block, collection }: {\n block: CollectionBlock;\n collection: AdminCollection;\n}) {\n const overrides = useMemo<Partial<AdminCollection>>(() => {\n // The model's filter, as one the person can clear.\n const where = filterOf(block.where);\n return {\n ...(where && { defaultFilter: where }),\n ...(block.limit !== undefined && { pagination: block.limit })\n };\n }, [block.where, block.limit]);\n const sort = orderOf(block.orderBy);\n\n return (\n <CollectionPanel\n collection={collection.slug}\n title={false}\n className=\"flex-1 rounded-xl overflow-hidden\"\n {...(block.view && { viewMode: block.view })}\n {...(sort && { orderBy: sort })}\n collectionOverrides={overrides}\n />\n );\n}\n\n/** show_record: the admin panel's form, for a row or a new one. */\nfunction RecordView({ block, collection }: { block: RecordBlock; collection: AdminCollection }) {\n // A new row's form becomes that row's once it is saved.\n const [created, setCreated] = useState<string | number>();\n const id = block.id ?? created;\n return (\n <Card className=\"min-w-0 overflow-hidden\">\n <RecordForm\n key={String(id ?? \"new\")}\n collection={collection}\n id={id}\n {...(id === undefined && block.values && { defaultValues: block.values })}\n onSaved={params => {\n if (id === undefined) setCreated(params.id);\n }}\n />\n </Card>\n );\n}\n\n/**\n * show_app: the app the model wrote, held to the collections it was opened\n * with, and its failure shown in its place.\n */\nfunction AppView({ block, onError }: {\n block: AppBlock;\n onError: (error: AppError) => void;\n}) {\n const loaded = useMemo(() => loadApp(block.code), [block.code]);\n\n // A module that failed as it loaded is told once.\n useEffect(() => {\n if (loaded.error) onError(loaded.error);\n }, [loaded, onError]);\n\n const failure = (error: AppError) => (\n <Alert color=\"error\" size=\"small\">\n The app failed{error.line ? ` at line ${error.line}` : \"\"}: {error.message}\n </Alert>\n );\n if (!loaded.Component) return failure(loaded.error ?? { message: \"The app did not load.\" });\n const { Component } = loaded;\n return (\n <AppErrorBoundary lineOffset={loaded.lineOffset} onError={onError} fallback={failure}>\n <AppCollections names={block.collections}>\n <Component/>\n </AppCollections>\n </AppErrorBoundary>\n );\n}\n\n/**\n * The last write the server refused, until the person dismisses it: an app's\n * code can drop the rejection, and a button the app drew shows nothing of its\n * own (the admin's own controls show theirs). Shown in the screen, not as a\n * snackbar, which the sandboxed frame left off its edge.\n */\nfunction useRefusedWrite(store: ViewStore<WriteFailure | undefined> | undefined): [WriteFailure | undefined, () => void] {\n const failure = useViewStore(store ?? NO_FAILURES);\n const [dismissed, setDismissed] = useState<WriteFailure | undefined>(undefined);\n const dismiss = useCallback(() => setDismissed(failure), [failure]);\n return [failure !== dismissed ? failure : undefined, dismiss];\n}\n\nconst NO_FAILURES = createViewStore<WriteFailure | undefined>(undefined);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA+BA,IAAM,oBAAoB;;;;;;;;AA6B1B,SAAgB,UAAU,EAAE,QAAQ,QAAQ,aAAa,aAAa,cAAc,YAAY,cAA8B;CAC1H,MAAM,UAAU,OAAuB,IAAI;CAC3C,MAAM,UAAU,aAAa,WAAW;CACxC,MAAM,UAAU,aAAa,WAAW;CACxC,MAAM,QAAQ,aAAa,UAAU;CACrC,MAAM,eAAe,kBAAkB,WAAW,IAAI,KAAA,CAAS,GAAG,CAAC,UAAU,CAAC;CAC9E,MAAM,CAAC,SAAS,kBAAkB,gBAAgB,YAAY;CAC9D,MAAM,WAAW,gCAAgC;CACjD,MAAM,aAAa,QAAQ,gBAAgB;CAC3C,MAAM,YAAY,CAAC,cAAc,QAAQ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AC,OAAO,CAAC;CAClE,OAAO,CAAC,YAAY,YAAY,UAAU,KAAA,GAAW,OAAO;AAChE;AAEA,IAAM,cAAc,gBAA0C,KAAA,CAAS"}
|
|
1
|
+
{"version":3,"file":"screen.js","names":[],"sources":["../../src/mcp_view/screen.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport {\n Alert,\n Card,\n CircularProgress,\n IconButton,\n Maximize2Icon,\n Tooltip,\n Typography,\n cls,\n iconSize\n} from \"@rebasepro/ui\";\nimport { CollectionPanel } from \"../components/CollectionPanel\";\nimport { RecordForm } from \"../components/RecordForm\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport type { HostContext, ViewBridge } from \"./bridge\";\nimport { describeFailedWrite, type WriteFailure, type WriteIntent, type WritePlan } from \"./tool_driver\";\nimport { SavedNotice, WriteConfirmDialog } from \"./write_review\";\nimport { filterOf, orderOf, type AppBlock, type RecordBlock, type Screen, type TableBlock } from \"./payload\";\nimport { AppErrorBoundary, loadApp, type AppError } from \"./code_app\";\nimport { AppCollections } from \"./app_modules\";\nimport { createViewStore, useViewStore, type ViewStore } from \"./store\";\n\n/**\n * The tallest the screen is in the conversation; past it, a collection\n * scrolls inside its own block, and anything else inside the screen. A\n * record's form and the confirmation of a save open over the frame, centred\n * in it: in a frame as tall as everything on the screen they would open where\n * the person is not looking.\n */\nconst INLINE_MAX_HEIGHT = 640;\n\n/** A write's plan waiting for the person's answer. */\nexport interface PendingPlan {\n plan: WritePlan;\n answer: (confirmed: boolean) => void;\n}\n\nexport interface McpScreenProps {\n bridge: ViewBridge;\n screen: Screen;\n /** The host's context, as it changes. */\n hostContext: ViewStore<HostContext>;\n /** The write plan to confirm, as it changes. */\n pendingPlan: ViewStore<PendingPlan | undefined>;\n /** A write that went through without asking, to say what it changed. */\n savedWrite: ViewStore<WriteIntent | undefined>;\n /** The last write the server refused, as it changes: shown to the person, once each. */\n writeFailure?: ViewStore<WriteFailure | undefined>;\n onAppError: (error: AppError) => void;\n}\n\n/**\n * What the embedded app's shell draws (`renderCms` of the embed host): the\n * one block the tool opened — a collection, a record, or an app the model\n * wrote — inside the providers the app's own `<RebaseShell>` set up, so its\n * collections, custom views, entity views, fields and actions are the ones\n * drawn.\n */\nexport function McpScreen({ bridge, screen, hostContext, pendingPlan, writeFailure, savedWrite, onAppError }: McpScreenProps) {\n const rootRef = useRef<HTMLDivElement>(null);\n const context = useViewStore(hostContext);\n const pending = useViewStore(pendingPlan);\n const saved = useViewStore(savedWrite);\n const dismissSaved = useCallback(() => savedWrite.set(undefined), [savedWrite]);\n const [refused, dismissRefused] = useRefusedWrite(writeFailure);\n const registry = useCollectionRegistryController();\n const fullscreen = context.displayMode === \"fullscreen\";\n const canExpand = !fullscreen && context.availableDisplayModes?.includes(\"fullscreen\") === true;\n const block = screen.blocks[0];\n\n // The host sizes the frame to the document, which it cannot measure\n // across the sandbox.\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n const measure = () => {\n const html = document.documentElement;\n const previous = html.style.height;\n html.style.height = \"max-content\";\n bridge.sizeChanged(Math.ceil(html.getBoundingClientRect().height));\n html.style.height = previous;\n };\n const observer = new ResizeObserver(measure);\n observer.observe(root);\n measure();\n return () => observer.disconnect();\n }, [bridge]);\n\n const collectionOf = (name: string): AdminCollection | undefined => registry.getCollection(name);\n const heading = screen.title ?? (block.type === \"app\" ? undefined : blockTitle(block, collectionOf(block.table)));\n\n let body: React.ReactNode;\n if (!registry.initialised && !registry.collections?.length) {\n body = <CircularProgress size=\"smallest\"/>;\n } else if (block.type === \"app\") {\n body = <AppView block={block} onError={onAppError}/>;\n } else {\n const collection = collectionOf(block.table);\n body = !collection\n ? <Alert color=\"error\" size=\"small\">The table "{block.table}" is not in this view.</Alert>\n : block.type === \"table\"\n ? <TableView block={block} collection={collection}/>\n : <RecordView block={block} collection={collection}/>;\n }\n\n return (\n <div ref={rootRef}\n className={cls(\"flex flex-col gap-4 p-4 w-full min-w-0 bg-surface-sheet text-text-primary dark:text-text-primary-dark overflow-y-auto\", fullscreen && \"h-screen\")}\n style={fullscreen ? undefined : { maxHeight: INLINE_MAX_HEIGHT }}>\n {(heading || canExpand) && (\n <div className=\"flex items-center justify-between gap-3 min-h-8\">\n <Typography variant=\"subtitle2\" noWrap>{heading}</Typography>\n {canExpand && (\n <Tooltip title=\"Expand\">\n <IconButton\n size=\"small\"\n aria-label=\"Expand\"\n onClick={() => void bridge.requestDisplayMode(\"fullscreen\").catch(() => undefined)}\n >\n <Maximize2Icon size={iconSize.smallest}/>\n </IconButton>\n </Tooltip>\n )}\n </div>\n )}\n {refused && (\n // Sticky: the inline frame scrolls inside, and the button that\n // wrote may be far below its top.\n <Alert color=\"error\" size=\"small\" outerClassName=\"sticky top-0 z-10\" onDismiss={dismissRefused}>\n {`Could not ${describeFailedWrite(refused)}: ${refused.message}`}\n </Alert>\n )}\n <SavedNotice intent={saved} collectionOf={collectionOf} onDismiss={dismissSaved}/>\n {body}\n <WriteConfirmDialog plan={pending?.plan}\n collectionOf={collectionOf}\n onAnswer={confirmed => pending?.answer(confirmed)}/>\n </div>\n );\n}\n\nfunction blockTitle(block: TableBlock | RecordBlock, collection: AdminCollection | undefined): string {\n if (block.type === \"record\") {\n const name = collection?.singularName ?? collection?.name ?? block.table;\n return block.id === undefined ? `New ${name.toLowerCase()}` : name;\n }\n return collection?.name ?? block.table;\n}\n\n/**\n * show_table: the admin panel's collection view of the table, where a row opens its\n * form over the screen. It sizes to its rows, up to what the screen leaves\n * it — inline, the screen's height cap; full screen, the window — and then\n * scrolls inside.\n */\nfunction TableView({ block, collection }: {\n block: TableBlock;\n collection: AdminCollection;\n}) {\n const overrides = useMemo<Partial<AdminCollection>>(() => {\n // The model's filter, as one the person can clear.\n const where = filterOf(block.where);\n return {\n ...(where && { defaultFilter: where }),\n ...(block.limit !== undefined && { pagination: block.limit })\n };\n }, [block.where, block.limit]);\n const sort = orderOf(block.orderBy);\n\n return (\n <CollectionPanel\n collection={collection.slug}\n title={false}\n className=\"flex-1 rounded-xl overflow-hidden\"\n {...(block.view && { viewMode: block.view })}\n {...(sort && { orderBy: sort })}\n collectionOverrides={overrides}\n />\n );\n}\n\n/** show_record: the admin panel's form, for a row or a new one. */\nfunction RecordView({ block, collection }: { block: RecordBlock; collection: AdminCollection }) {\n // A new row's form becomes that row's once it is saved.\n const [created, setCreated] = useState<string | number>();\n const id = block.id ?? created;\n return (\n <Card className=\"min-w-0 overflow-hidden\">\n <RecordForm\n key={String(id ?? \"new\")}\n collection={collection}\n id={id}\n {...(id === undefined && block.values && { defaultValues: block.values })}\n onSaved={params => {\n if (id === undefined) setCreated(params.id);\n }}\n />\n </Card>\n );\n}\n\n/**\n * show_app: the app the model wrote, held to the tables it was opened\n * with, and its failure shown in its place.\n */\nfunction AppView({ block, onError }: {\n block: AppBlock;\n onError: (error: AppError) => void;\n}) {\n const loaded = useMemo(() => loadApp(block.code), [block.code]);\n\n // A module that failed as it loaded is told once.\n useEffect(() => {\n if (loaded.error) onError(loaded.error);\n }, [loaded, onError]);\n\n const failure = (error: AppError) => (\n <Alert color=\"error\" size=\"small\">\n The app failed{error.line ? ` at line ${error.line}` : \"\"}: {error.message}\n </Alert>\n );\n if (!loaded.Component) return failure(loaded.error ?? { message: \"The app did not load.\" });\n const { Component } = loaded;\n return (\n <AppErrorBoundary lineOffset={loaded.lineOffset} onError={onError} fallback={failure}>\n <AppCollections names={block.tables}>\n <Component/>\n </AppCollections>\n </AppErrorBoundary>\n );\n}\n\n/**\n * The last write the server refused, until the person dismisses it: an app's\n * code can drop the rejection, and a button the app drew shows nothing of its\n * own (the admin's own controls show theirs). Shown in the screen, not as a\n * snackbar, which the sandboxed frame left off its edge.\n */\nfunction useRefusedWrite(store: ViewStore<WriteFailure | undefined> | undefined): [WriteFailure | undefined, () => void] {\n const failure = useViewStore(store ?? NO_FAILURES);\n const [dismissed, setDismissed] = useState<WriteFailure | undefined>(undefined);\n const dismiss = useCallback(() => setDismissed(failure), [failure]);\n return [failure !== dismissed ? failure : undefined, dismiss];\n}\n\nconst NO_FAILURES = createViewStore<WriteFailure | undefined>(undefined);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA+BA,IAAM,oBAAoB;;;;;;;;AA6B1B,SAAgB,UAAU,EAAE,QAAQ,QAAQ,aAAa,aAAa,cAAc,YAAY,cAA8B;CAC1H,MAAM,UAAU,OAAuB,IAAI;CAC3C,MAAM,UAAU,aAAa,WAAW;CACxC,MAAM,UAAU,aAAa,WAAW;CACxC,MAAM,QAAQ,aAAa,UAAU;CACrC,MAAM,eAAe,kBAAkB,WAAW,IAAI,KAAA,CAAS,GAAG,CAAC,UAAU,CAAC;CAC9E,MAAM,CAAC,SAAS,kBAAkB,gBAAgB,YAAY;CAC9D,MAAM,WAAW,gCAAgC;CACjD,MAAM,aAAa,QAAQ,gBAAgB;CAC3C,MAAM,YAAY,CAAC,cAAc,QAAQ,uBAAuB,SAAS,YAAY,MAAM;CAC3F,MAAM,QAAQ,OAAO,OAAO;CAI5B,gBAAgB;EACZ,MAAM,OAAO,QAAQ;EACrB,IAAI,CAAC,MAAM;EACX,MAAM,gBAAgB;GAClB,MAAM,OAAO,SAAS;GACtB,MAAM,WAAW,KAAK,MAAM;GAC5B,KAAK,MAAM,SAAS;GACpB,OAAO,YAAY,KAAK,KAAK,KAAK,sBAAsB,CAAC,CAAC,MAAM,CAAC;GACjE,KAAK,MAAM,SAAS;EACxB;EACA,MAAM,WAAW,IAAI,eAAe,OAAO;EAC3C,SAAS,QAAQ,IAAI;EACrB,QAAQ;EACR,aAAa,SAAS,WAAW;CACrC,GAAG,CAAC,MAAM,CAAC;CAEX,MAAM,gBAAgB,SAA8C,SAAS,cAAc,IAAI;CAC/F,MAAM,UAAU,OAAO,UAAU,MAAM,SAAS,QAAQ,KAAA,IAAY,WAAW,OAAO,aAAa,MAAM,KAAK,CAAC;CAE/G,IAAI;CACJ,IAAI,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,GAAG,CAAC,QAAQ,OAAO,CAAC;CAEpB,MAAM,WAAW,UACb,qBAAC,OAAD;EAAO,OAAM;EAAQ,MAAK;YAA1B;GAAkC;GACf,MAAM,OAAO,YAAY,MAAM,SAAS;GAAG;GAAG,MAAM;EAChE;;CAEX,IAAI,CAAC,OAAO,WAAW,OAAO,QAAQ,OAAO,SAAS,EAAE,SAAS,wBAAwB,CAAC;CAC1F,MAAM,EAAE,cAAc;CACtB,OACI,oBAAC,kBAAD;EAAkB,YAAY,OAAO;EAAqB;EAAS,UAAU;YACzE,oBAAC,gBAAD;GAAgB,OAAO,MAAM;aACzB,oBAAC,WAAD,CAAW,CAAA;EACC,CAAA;CACF,CAAA;AAE1B;;;;;;;AAQA,SAAS,gBAAgB,OAAgG;CACrH,MAAM,UAAU,aAAa,SAAS,WAAW;CACjD,MAAM,CAAC,WAAW,gBAAgB,SAAmC,KAAA,CAAS;CAC9E,MAAM,UAAU,kBAAkB,aAAa,OAAO,GAAG,CAAC,OAAO,CAAC;CAClE,OAAO,CAAC,YAAY,YAAY,UAAU,KAAA,GAAW,OAAO;AAChE;AAEA,IAAM,cAAc,gBAA0C,KAAA,CAAS"}
|
|
@@ -1,34 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* this view.
|
|
4
|
-
*
|
|
5
|
-
* `<Rebase>` reads and writes through a `DataDriver`; this one turns each read
|
|
6
|
-
* and write into a `tools/call` the host relays to the server — the same
|
|
7
|
-
* tools, the same person, the same RLS as the model's own calls. Rows go and
|
|
8
|
-
* come in the REST shape those tools speak (dates as ISO text, a belongsTo as
|
|
9
|
-
* its foreign key); `<Rebase>` turns them into the admin panel's view model
|
|
10
|
-
* and back, as it does for any driver.
|
|
11
|
-
*
|
|
12
|
-
* An app's row hooks (`useRows`, `useAggregate`, …) read the same driver
|
|
13
|
-
* through the flat data layer (`buildRebaseData`), which keeps the wire's
|
|
14
|
-
* rows and takes aggregates from `restFetchService`: here, the aggregate tool.
|
|
15
|
-
*
|
|
16
|
-
* A write the server answers with a plan (the hosted connector's two-step
|
|
17
|
-
* `write`) is held: the person is shown the plan and the write is sent again
|
|
18
|
-
* with its token only if they confirm. The row hooks write through
|
|
19
|
-
* `confirmingDriver`, which asks the person before any other write too: code
|
|
20
|
-
* can write without a click, while a save made with the admin's own controls
|
|
21
|
-
* was the person's click. Either way the admin panel sees one save that took
|
|
22
|
-
* a moment longer, or one that failed with "Not saved".
|
|
23
|
-
*
|
|
24
|
-
* The driver does not subscribe (no `listenCollection`/`listenOne`): every
|
|
25
|
-
* write it makes comes through `<Rebase>`'s data layers, which say so on the
|
|
26
|
-
* `<Rebase>`'s change signal, and each view of the collection reads again on
|
|
27
|
-
* it. It learns of no change it did not make — the host relays no other
|
|
28
|
-
* tool's calls — so it has nothing to announce either
|
|
29
|
-
* (`subscribeToExternalChanges`).
|
|
30
|
-
*/
|
|
31
|
-
import { type CollectionConfig, type DataDriver } from "@rebasepro/types";
|
|
1
|
+
import { type CollectionConfig } from "@rebasepro/cms-types";
|
|
2
|
+
import type { CmsDataDriver } from "@rebasepro/cms-types";
|
|
32
3
|
import { type ToolResult } from "./bridge.js";
|
|
33
4
|
/** A tool the view calls, and the arguments it always sends to it. */
|
|
34
5
|
export interface ToolAction {
|
|
@@ -122,7 +93,7 @@ export interface WriteFailure {
|
|
|
122
93
|
export type CallTool = (name: string, args: Record<string, unknown>) => Promise<ToolResult>;
|
|
123
94
|
/**
|
|
124
95
|
* A page a result already carries: the rows the server read — for the model
|
|
125
|
-
* (
|
|
96
|
+
* (show_table), or ahead of an app's first render (show_app) — and the
|
|
126
97
|
* arguments it read them with.
|
|
127
98
|
*/
|
|
128
99
|
export interface SeedPage {
|
|
@@ -185,14 +156,14 @@ export interface ToolDriverOptions {
|
|
|
185
156
|
}
|
|
186
157
|
export interface ToolDriver {
|
|
187
158
|
/** For `<Rebase>`: the admin panel's reads and saves. */
|
|
188
|
-
driver:
|
|
159
|
+
driver: CmsDataDriver;
|
|
189
160
|
/**
|
|
190
161
|
* The same driver, asking the person before each write the tool does not
|
|
191
162
|
* plan itself: for the row hooks (`useRowWrites`), since code can write
|
|
192
163
|
* without a click. A declined write rejects with {@link SaveCancelledError}
|
|
193
164
|
* and nothing is sent.
|
|
194
165
|
*/
|
|
195
|
-
confirmingDriver:
|
|
166
|
+
confirmingDriver: CmsDataDriver;
|
|
196
167
|
}
|
|
197
168
|
/** A save the person declined at the plan. The form shows it as the save's error. */
|
|
198
169
|
export declare class SaveCancelledError extends Error {
|