@rebasepro/cms 0.30.0 → 0.31.0-canary.g59cd6fd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/collection_editor/ConfigControllerProvider.js +25 -22
- package/dist/collection_editor/ConfigControllerProvider.js.map +1 -1
- package/dist/collection_editor/firestore_callee.d.ts +10 -0
- package/dist/collection_editor/firestore_callee.js +15 -0
- package/dist/collection_editor/firestore_callee.js.map +1 -0
- package/dist/collection_editor/firestore_edit.d.ts +62 -0
- package/dist/collection_editor/firestore_edit.js +339 -0
- package/dist/collection_editor/firestore_edit.js.map +1 -0
- package/dist/collection_editor/index.d.ts +2 -3
- package/dist/collection_editor/liveSchemaClient.d.ts +44 -22
- package/dist/collection_editor/liveSchemaClient.js +9 -3
- package/dist/collection_editor/liveSchemaClient.js.map +1 -1
- package/dist/collection_editor/property_column.d.ts +86 -0
- package/dist/collection_editor/property_column.js +719 -0
- package/dist/collection_editor/property_column.js.map +1 -0
- package/dist/collection_editor/serializable_types.d.ts +2 -24
- package/dist/collection_editor/serializable_utils.d.ts +1 -1
- package/dist/collection_editor/serializable_utils.js +2 -1
- package/dist/collection_editor/serializable_utils.js.map +1 -1
- package/dist/collection_editor/split_edit.d.ts +106 -0
- package/dist/collection_editor/split_edit.js +564 -0
- package/dist/collection_editor/split_edit.js.map +1 -0
- package/dist/collection_editor/split_edit_error.d.ts +25 -0
- package/dist/collection_editor/split_edit_error.js +35 -0
- package/dist/collection_editor/split_edit_error.js.map +1 -0
- package/dist/collection_editor/types/collection_editor_controller.d.ts +1 -1
- package/dist/collection_editor/types/config_controller.d.ts +67 -1
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.d.ts +6 -5
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js +44 -12
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js +18 -3
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js +94 -55
- package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/CollectionRelationsTab.d.ts +2 -1
- package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/EnumForm.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js +3 -3
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.d.ts +2 -3
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.js +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyTree.d.ts +7 -4
- package/dist/collection_editor/ui/collection_editor/PropertyTree.js +15 -5
- package/dist/collection_editor/ui/collection_editor/PropertyTree.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.d.ts +20 -0
- package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js +74 -0
- package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/conditions/ConditionsEditor.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/conditions/EnumConditionsEditor.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/conditions/property_paths.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/rlsRuleForm.d.ts +34 -0
- package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js +50 -0
- package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.d.ts +1 -2
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js.map +1 -1
- package/dist/collection_editor/useDetachRulesConfirmation.d.ts +16 -0
- package/dist/collection_editor/useDetachRulesConfirmation.js +48 -0
- package/dist/collection_editor/useDetachRulesConfirmation.js.map +1 -0
- package/dist/collection_editor/useLiveSchemaEditing.d.ts +2 -2
- package/dist/collection_editor/useLiveSchemaEditing.js +1 -1
- package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -1
- package/dist/collection_editor/useLocalCollectionsConfigController.d.ts +54 -10
- package/dist/collection_editor/useLocalCollectionsConfigController.js +394 -122
- package/dist/collection_editor/useLocalCollectionsConfigController.js.map +1 -1
- package/dist/collection_editor/validateCollectionJson.js.map +1 -1
- package/dist/components/CollectionPanel.d.ts +10 -9
- package/dist/components/CollectionPanel.js +5 -2
- package/dist/components/CollectionPanel.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +1 -2
- package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +3 -5
- package/dist/components/CollectionTableBinding/PropertyTableCell.d.ts +2 -2
- package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
- package/dist/components/CollectionTableBinding/column_utils.d.ts +1 -1
- package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +1 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationField.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js +1 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.d.ts +2 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableStorageUpload.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.d.ts +1 -1
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js +1 -1
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/common.d.ts +1 -2
- package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +2 -2
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
- package/dist/components/CollectionTableBinding/table_bindings.d.ts +2 -2
- package/dist/components/CollectionTableBinding/table_bindings.js.map +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -5
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +1 -1
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.js +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +2 -4
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +6 -6
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewContent.js +1 -2
- package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntitiesCount.js +3 -3
- package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -1
- package/dist/components/CollectionViewBinding/FilterPresetsButton.d.ts +1 -2
- package/dist/components/CollectionViewBinding/FilterPresetsButton.js +1 -1
- package/dist/components/CollectionViewBinding/FilterPresetsButton.js.map +1 -1
- package/dist/components/CollectionViewBinding/FiltersButton.d.ts +1 -2
- package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -1
- package/dist/components/CollectionViewBinding/FiltersDialog.d.ts +1 -1
- package/dist/components/CollectionViewBinding/FiltersDialog.js.map +1 -1
- package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +1 -2
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/RowActions.d.ts +1 -2
- package/dist/components/CollectionViewBinding/RowActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/SortButton.d.ts +1 -1
- package/dist/components/CollectionViewBinding/SortButton.js.map +1 -1
- package/dist/components/CollectionViewBinding/SplitListView.d.ts +1 -2
- package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.d.ts +1 -2
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js +1 -1
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js.map +1 -1
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.d.ts +1 -2
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js.map +1 -1
- package/dist/components/CollectionViewBinding/useBoardDataController.d.ts +2 -1
- package/dist/components/CollectionViewBinding/useBoardDataController.js +3 -3
- package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
- package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +2 -4
- package/dist/components/CollectionViewBinding/useCollectionViewState.js +14 -19
- package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -1
- package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +1 -3
- package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/useSelectionController.d.ts +1 -2
- package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
- package/dist/components/CollectionsProvider.d.ts +23 -8
- package/dist/components/CollectionsProvider.js +23 -7
- package/dist/components/CollectionsProvider.js.map +1 -1
- package/dist/components/DefaultDrawer.js +1 -1
- package/dist/components/DeleteEntityDialog.d.ts +1 -1
- package/dist/components/DeleteEntityDialog.js +1 -1
- package/dist/components/DeleteEntityDialog.js.map +1 -1
- package/dist/components/DetailViewBinding.js +3 -3
- package/dist/components/DetailViewBinding.js.map +1 -1
- package/dist/components/EditFormActions.js.map +1 -1
- package/dist/components/EditViewBinding.d.ts +2 -1
- package/dist/components/EditViewBinding.js +6 -6
- package/dist/components/EditViewBinding.js.map +1 -1
- package/dist/components/EntityDisplayHeader.d.ts +1 -2
- package/dist/components/EntityDisplayHeader.js.map +1 -1
- package/dist/components/EntityInspector.d.ts +1 -2
- package/dist/components/EntityInspector.js.map +1 -1
- package/dist/components/EntityPreviewBinding.d.ts +1 -1
- package/dist/components/EntityPreviewBinding.js +1 -1
- package/dist/components/EntityPreviewBinding.js.map +1 -1
- package/dist/components/EntityViewBinding.d.ts +1 -1
- package/dist/components/EntityViewBinding.js.map +1 -1
- package/dist/components/EntityViewBody.d.ts +1 -1
- package/dist/components/EntityViewBody.js +3 -4
- package/dist/components/EntityViewBody.js.map +1 -1
- package/dist/components/FieldValue.js +2 -2
- package/dist/components/FieldValue.js.map +1 -1
- package/dist/components/HomePage/ContentHomePage.js +12 -3
- package/dist/components/HomePage/ContentHomePage.js.map +1 -1
- package/dist/components/InlineEntityPreview.d.ts +1 -1
- package/dist/components/InlineEntityPreview.js.map +1 -1
- package/dist/components/PropertyCollectionView.d.ts +2 -2
- package/dist/components/PropertyCollectionView.js.map +1 -1
- package/dist/components/PropertyConfigBadge.js.map +1 -1
- package/dist/components/RebaseCMS.d.ts +22 -3
- package/dist/components/RebaseCMS.js +32 -14
- package/dist/components/RebaseCMS.js.map +1 -1
- package/dist/components/RebaseNavigation.js +106 -31
- package/dist/components/RebaseNavigation.js.map +1 -1
- package/dist/components/RecordDetail.js +4 -1
- package/dist/components/RecordDetail.js.map +1 -1
- package/dist/components/RecordForm.d.ts +5 -5
- package/dist/components/RecordForm.js +5 -2
- package/dist/components/RecordForm.js.map +1 -1
- package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +2 -2
- package/dist/components/ReferenceTable/SelectionTableBinding.js +1 -1
- package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
- package/dist/components/ReferenceWidget.d.ts +2 -1
- package/dist/components/ReferenceWidget.js +2 -2
- package/dist/components/ReferenceWidget.js.map +1 -1
- package/dist/components/RelationSelector.d.ts +2 -1
- package/dist/components/RelationSelector.js +2 -3
- package/dist/components/RelationSelector.js.map +1 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +2 -2
- package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
- package/dist/components/SelectableTable/filters/FilterFieldBinding.d.ts +2 -1
- package/dist/components/SelectableTable/filters/FilterFieldBinding.js +3 -3
- package/dist/components/SelectableTable/filters/FilterFieldBinding.js.map +1 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js +2 -2
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -1
- package/dist/components/SelectableTable/filters/RelationFilterField.d.ts +1 -1
- package/dist/components/SelectableTable/filters/RelationFilterField.js +1 -1
- package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -1
- package/dist/components/SelectableTable/filters/StringNumberFilterField.d.ts +1 -1
- package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -1
- package/dist/components/SelectableTable/filters/null_filter.d.ts +1 -3
- package/dist/components/SelectableTable/filters/null_filter.js.map +1 -1
- package/dist/components/SidePanelBinding.js +1 -1
- package/dist/components/SidePanelBinding.js.map +1 -1
- package/dist/components/field_configs.d.ts +1 -2
- package/dist/components/field_configs.js.map +1 -1
- package/dist/components/field_ids.d.ts +1 -1
- package/dist/components/field_ids.js +1 -1
- package/dist/components/field_ids.js.map +1 -1
- package/dist/components/history/EntityHistoryEntry.js.map +1 -1
- package/dist/components/history/EntityHistoryView.d.ts +1 -2
- package/dist/components/history/EntityHistoryView.js +1 -1
- package/dist/components/history/EntityHistoryView.js.map +1 -1
- package/dist/data_export/export/BasicExportAction.d.ts +1 -1
- package/dist/data_export/export/BasicExportAction.js.map +1 -1
- package/dist/data_export/export/ExportCollectionAction.js +2 -2
- package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
- package/dist/data_export/export/additional_fields.d.ts +1 -1
- package/dist/data_export/export/additional_fields.js.map +1 -1
- package/dist/data_export/export/export.d.ts +1 -1
- package/dist/data_export/export/export.js +1 -1
- package/dist/data_export/export/export.js.map +1 -1
- package/dist/data_export/export/fetch_export_data.d.ts +3 -2
- package/dist/data_export/export/fetch_export_data.js.map +1 -1
- package/dist/data_import/components/DataNewPropertiesMapping.d.ts +1 -1
- package/dist/data_import/components/DataNewPropertiesMapping.js.map +1 -1
- package/dist/data_import/components/ImportNewPropertyFieldPreview.d.ts +1 -1
- package/dist/data_import/components/ImportNewPropertyFieldPreview.js.map +1 -1
- package/dist/data_import/hooks/useImportConfig.js.map +1 -1
- package/dist/data_import/import/ImportCollectionAction.d.ts +2 -2
- package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
- package/dist/data_import/types/column_mapping.d.ts +1 -1
- package/dist/data_import/utils/data.d.ts +1 -2
- package/dist/data_import/utils/data.js +1 -2
- package/dist/data_import/utils/data.js.map +1 -1
- package/dist/data_import/utils/get_import_inference_type.d.ts +1 -1
- package/dist/data_import/utils/get_import_inference_type.js.map +1 -1
- package/dist/data_import/utils/id_column.d.ts +1 -1
- package/dist/data_import/utils/id_column.js.map +1 -1
- package/dist/data_import/utils/import_columns.d.ts +1 -1
- package/dist/data_import/utils/import_columns.js.map +1 -1
- package/dist/data_import/utils/save_entities.d.ts +3 -3
- package/dist/data_import/utils/save_entities.js +1 -1
- package/dist/data_import/utils/save_entities.js.map +1 -1
- package/dist/form/EntityForm.js +2 -1
- package/dist/form/EntityForm.js.map +1 -1
- package/dist/form/EntityFormActions.js.map +1 -1
- package/dist/form/EntityFormBinding.js +2 -2
- package/dist/form/EntityFormBinding.js.map +1 -1
- package/dist/form/FormFieldsContext.d.ts +1 -4
- package/dist/form/FormFieldsContext.js +1 -1
- package/dist/form/FormFieldsContext.js.map +1 -1
- package/dist/form/PropertyFieldBinding.js +6 -8
- package/dist/form/PropertyFieldBinding.js.map +1 -1
- package/dist/form/components/FieldBlock.d.ts +1 -2
- package/dist/form/components/FieldBlock.js.map +1 -1
- package/dist/form/components/FieldHelperText.d.ts +1 -1
- package/dist/form/components/FieldHelperText.js.map +1 -1
- package/dist/form/components/FormRail.d.ts +1 -1
- package/dist/form/components/FormRail.js.map +1 -1
- package/dist/form/components/LocalChangesMenu.d.ts +1 -1
- package/dist/form/components/LocalChangesMenu.js.map +1 -1
- package/dist/form/components/StorageItemPreview.d.ts +1 -1
- package/dist/form/components/StorageItemPreview.js.map +1 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js +1 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/BinaryFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.js +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/DateTimeFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/GeopointFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.js +1 -2
- package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MapFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MultiSelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MultiSelectFieldBinding.js +1 -1
- package/dist/form/field_bindings/MultiSelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MultipleRelationFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.js +2 -2
- package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/RelationFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/RelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.js +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.js +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +2 -2
- package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/SwitchFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/UserSelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/UserSelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/VectorFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/VectorFieldBinding.js.map +1 -1
- package/dist/form/form_utils.d.ts +3 -3
- package/dist/form/form_utils.js +1 -2
- package/dist/form/form_utils.js.map +1 -1
- package/dist/form/label_placement.d.ts +1 -2
- package/dist/form/label_placement.js.map +1 -1
- package/dist/form/resolve_cell_property.d.ts +1 -2
- package/dist/form/resolve_cell_property.js +1 -1
- package/dist/form/resolve_cell_property.js.map +1 -1
- package/dist/form/resolve_form_properties.d.ts +2 -2
- package/dist/form/resolve_form_properties.js +1 -1
- package/dist/form/resolve_form_properties.js.map +1 -1
- package/dist/form/useClearRestoreValue.d.ts +1 -1
- package/dist/form/useClearRestoreValue.js.map +1 -1
- package/dist/form/validation.d.ts +2 -2
- package/dist/form/validation.js +1 -1
- package/dist/form/validation.js.map +1 -1
- package/dist/hooks/navigation/compose_collections.d.ts +59 -0
- package/dist/hooks/navigation/compose_collections.js +48 -0
- package/dist/hooks/navigation/compose_collections.js.map +1 -0
- package/dist/hooks/navigation/compose_collections_input.d.ts +8 -0
- package/dist/hooks/navigation/compose_collections_input.js +17 -0
- package/dist/hooks/navigation/compose_collections_input.js.map +1 -0
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +1 -1
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.js.map +1 -1
- package/dist/hooks/navigation/registered_collection.d.ts +15 -0
- package/dist/hooks/navigation/registered_collection.js +20 -0
- package/dist/hooks/navigation/registered_collection.js.map +1 -0
- package/dist/hooks/navigation/ui_preferences.d.ts +47 -0
- package/dist/hooks/navigation/ui_preferences.js +179 -0
- package/dist/hooks/navigation/ui_preferences.js.map +1 -0
- package/dist/hooks/navigation/useAsyncResolver.d.ts +8 -1
- package/dist/hooks/navigation/useAsyncResolver.js +9 -3
- package/dist/hooks/navigation/useAsyncResolver.js.map +1 -1
- package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +1 -3
- package/dist/hooks/navigation/useBuildCollectionRegistryController.js +3 -3
- package/dist/hooks/navigation/useBuildCollectionRegistryController.js.map +1 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +9 -5
- package/dist/hooks/navigation/useBuildNavigationStateController.js +2 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
- package/dist/hooks/navigation/useBuildUrlController.d.ts +1 -1
- package/dist/hooks/navigation/useBuildUrlController.js.map +1 -1
- package/dist/hooks/navigation/useNavigationResolution.js +1 -2
- package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
- package/dist/hooks/navigation/usePanelTables.d.ts +11 -0
- package/dist/hooks/navigation/usePanelTables.js +33 -0
- package/dist/hooks/navigation/usePanelTables.js.map +1 -0
- package/dist/hooks/navigation/useResolvedCollections.d.ts +8 -3
- package/dist/hooks/navigation/useResolvedCollections.js +3 -2
- package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
- package/dist/hooks/navigation/useResolvedViews.d.ts +1 -2
- package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
- package/dist/hooks/navigation/useTopLevelNavigation.d.ts +1 -2
- package/dist/hooks/navigation/useTopLevelNavigation.js.map +1 -1
- package/dist/hooks/navigation/user_preferences_overlay.d.ts +21 -0
- package/dist/hooks/navigation/user_preferences_overlay.js +101 -0
- package/dist/hooks/navigation/user_preferences_overlay.js.map +1 -0
- package/dist/hooks/navigation/utils.js +1 -1
- package/dist/hooks/navigation/utils.js.map +1 -1
- package/dist/hooks/useAdminContext.d.ts +1 -2
- package/dist/hooks/useAdminContext.js.map +1 -1
- package/dist/hooks/useBuildSidePanel.d.ts +1 -2
- package/dist/hooks/useBuildSidePanel.js +2 -1
- package/dist/hooks/useBuildSidePanel.js.map +1 -1
- package/dist/hooks/useChildViewSource.d.ts +1 -1
- package/dist/hooks/useChildViewSource.js +1 -1
- package/dist/hooks/useChildViewSource.js.map +1 -1
- package/dist/hooks/useEntityDisplay.d.ts +1 -2
- package/dist/hooks/useEntityDisplay.js +1 -1
- package/dist/hooks/useEntityDisplay.js.map +1 -1
- package/dist/hooks/useEntityDisplayTitle.d.ts +2 -2
- package/dist/hooks/useEntityDisplayTitle.js.map +1 -1
- package/dist/hooks/useHistory.js +1 -1
- package/dist/hooks/useHistory.js.map +1 -1
- package/dist/hooks/useRecordActions.d.ts +1 -2
- package/dist/hooks/useRecordActions.js.map +1 -1
- package/dist/hooks/useReferencePaths.d.ts +21 -7
- package/dist/hooks/useReferencePaths.js +23 -6
- package/dist/hooks/useReferencePaths.js.map +1 -1
- package/dist/hooks/useResolvedNavigationFrom.d.ts +3 -3
- package/dist/hooks/useResolvedNavigationFrom.js +1 -1
- package/dist/hooks/useResolvedNavigationFrom.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +8 -2
- package/dist/mcp_view/app_modules.d.ts +2 -2
- package/dist/mcp_view/app_modules.js +4 -4
- package/dist/mcp_view/app_modules.js.map +1 -1
- package/dist/mcp_view/index.d.ts +16 -19
- package/dist/mcp_view/index.js +43 -62
- package/dist/mcp_view/index.js.map +1 -1
- package/dist/mcp_view/payload.d.ts +54 -18
- package/dist/mcp_view/payload.js +49 -24
- package/dist/mcp_view/payload.js.map +1 -1
- package/dist/mcp_view/screen.js +11 -11
- package/dist/mcp_view/screen.js.map +1 -1
- package/dist/mcp_view/tool_driver.d.ts +5 -34
- package/dist/mcp_view/tool_driver.js +17 -16
- package/dist/mcp_view/tool_driver.js.map +1 -1
- package/dist/mcp_view/write_review.d.ts +1 -2
- package/dist/mcp_view/write_review.js +1 -1
- package/dist/mcp_view/write_review.js.map +1 -1
- package/dist/preview/PropertyPreview.d.ts +1 -1
- package/dist/preview/PropertyPreview.js +4 -3
- package/dist/preview/PropertyPreview.js.map +1 -1
- package/dist/preview/components/ArrayEnumPreview.d.ts +1 -1
- package/dist/preview/components/ArrayEnumPreview.js.map +1 -1
- package/dist/preview/components/BooleanPreview.d.ts +1 -1
- package/dist/preview/components/BooleanPreview.js.map +1 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/EnumValuesChip.js +1 -1
- package/dist/preview/components/EnumValuesChip.js.map +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.js.map +1 -1
- package/dist/preview/components/RelationPreview.d.ts +1 -1
- package/dist/preview/components/RelationPreview.js.map +1 -1
- package/dist/preview/components/StorageThumbnail.js +2 -1
- package/dist/preview/components/StorageThumbnail.js.map +1 -1
- package/dist/preview/components/UserPreview.d.ts +1 -1
- package/dist/preview/components/UserPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfMapsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfMapsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfReferencesPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfReferencesPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfRelationsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfRelationsPreview.js +2 -1
- package/dist/preview/property_previews/ArrayOfRelationsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfStringsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfStringsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOneOfPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOneOfPreview.js +1 -1
- package/dist/preview/property_previews/ArrayOneOfPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.js +1 -1
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayPropertyPreview.js +1 -1
- package/dist/preview/property_previews/ArrayPropertyPreview.js.map +1 -1
- package/dist/preview/property_previews/MapPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/MapPropertyPreview.js.map +1 -1
- package/dist/preview/property_previews/NumberPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/NumberPropertyPreview.js +1 -1
- package/dist/preview/property_previews/NumberPropertyPreview.js.map +1 -1
- package/dist/preview/property_previews/SkeletonPropertyComponent.d.ts +1 -1
- package/dist/preview/property_previews/SkeletonPropertyComponent.js.map +1 -1
- package/dist/preview/property_previews/StringPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/StringPropertyPreview.js.map +1 -1
- package/dist/preview/util.d.ts +1 -1
- package/dist/preview/util.js.map +1 -1
- package/dist/routes/RebaseRoute.js +2 -2
- package/dist/routes/RebaseRoute.js.map +1 -1
- package/dist/saved_apps/SavedAppsView.d.ts +1 -1
- package/dist/saved_apps/SavedAppsView.js +1 -1
- package/dist/saved_apps/SavedAppsView.js.map +1 -1
- package/dist/selection/SelectionMenu.d.ts +1 -1
- package/dist/selection/SelectionMenu.js.map +1 -1
- package/dist/selection/resolve_selection.d.ts +3 -3
- package/dist/selection/resolve_selection.js +3 -2
- package/dist/selection/resolve_selection.js.map +1 -1
- package/dist/tables/apply_customization.d.ts +65 -0
- package/dist/tables/apply_customization.js +644 -0
- package/dist/tables/apply_customization.js.map +1 -0
- package/dist/tables/column_property.d.ts +64 -0
- package/dist/tables/column_property.js +549 -0
- package/dist/tables/column_property.js.map +1 -0
- package/dist/tables/customize_table.d.ts +39 -0
- package/dist/tables/customize_table.js +247 -0
- package/dist/tables/customize_table.js.map +1 -0
- package/dist/tables/index.d.ts +12 -0
- package/dist/tables/labels.d.ts +18 -0
- package/dist/tables/labels.js +18 -0
- package/dist/tables/labels.js.map +1 -0
- package/dist/tables/project_table.d.ts +79 -0
- package/dist/tables/project_table.js +148 -0
- package/dist/tables/project_table.js.map +1 -0
- package/dist/tables/relations.d.ts +47 -0
- package/dist/tables/relations.js +112 -0
- package/dist/tables/relations.js.map +1 -0
- package/dist/tables/rls.d.ts +39 -0
- package/dist/tables/rls.js +111 -0
- package/dist/tables/rls.js.map +1 -0
- package/dist/tables/update_record.d.ts +32 -0
- package/dist/tables/update_record.js +40 -0
- package/dist/tables/update_record.js.map +1 -0
- package/dist/types/components/EntityFormActionsProps.d.ts +1 -1
- package/dist/types/components/PropertyPreviewProps.d.ts +2 -2
- package/dist/types/fields.d.ts +2 -2
- package/dist/util/dataControllerAdapter.js.map +1 -1
- package/dist/util/entity_pages.d.ts +2 -1
- package/dist/util/entity_pages.js.map +1 -1
- package/dist/util/find_entities_by_ids.d.ts +2 -2
- package/dist/util/find_entities_by_ids.js +1 -1
- package/dist/util/find_entities_by_ids.js.map +1 -1
- package/dist/util/format_collection_date.d.ts +1 -1
- package/dist/util/format_collection_date.js.map +1 -1
- package/dist/util/identity.d.ts +8 -0
- package/dist/util/identity.js +16 -0
- package/dist/util/identity.js.map +1 -0
- package/dist/util/navigation_utils.js +1 -1
- package/dist/util/navigation_utils.js.map +1 -1
- package/dist/util/previews.js +1 -1
- package/dist/util/previews.js.map +1 -1
- package/dist/util/propertyConfigMapper.d.ts +1 -1
- package/dist/util/propertyConfigMapper.js.map +1 -1
- package/dist/util/property_utils.d.ts +1 -3
- package/dist/util/property_utils.js +1 -1
- package/dist/util/property_utils.js.map +1 -1
- package/dist/util/relations.d.ts +18 -0
- package/dist/util/relations.js +32 -0
- package/dist/util/relations.js.map +1 -0
- package/package.json +12 -10
- package/recipes/README.md +4 -4
- package/recipes/my-preferences.tsx +34 -26
- package/recipes/site-settings.tsx +34 -27
- package/dist/collection_editor/collection_wire.d.ts +0 -13
- package/dist/collection_editor/collection_wire.js +0 -49
- package/dist/collection_editor/collection_wire.js.map +0 -1
- package/dist/collection_editor/useJsonCollectionsConfigController.d.ts +0 -37
- package/dist/collection_editor/useJsonCollectionsConfigController.js +0 -191
- package/dist/collection_editor/useJsonCollectionsConfigController.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property_column.js","names":[],"sources":["../../src/collection_editor/property_column.ts"],"sourcesContent":["/**\n * The collection editor's property, as the column (or relation) the schema\n * editor writes.\n *\n * The editor renders and edits the panel's view model — a flat collection of\n * `Property`s, what `propertyFromColumn` projects a column to. A save sends\n * the server {@link WireColumnDef}s and {@link WireRelation}s. This module is\n * the inverse of the projector for the facts the editor can change: the\n * column type, nullability, the primary key and its strategy, the default,\n * validation, enum values, storage rules, the SQL name, field access and\n * stamps.\n *\n * Everything else a column says (a vector index, `.transform()`, a generated\n * expression, a JSON shape the editor does not draw) is kept from the column\n * as served: a property is always read **over** the column it was projected\n * from, so a fact the view model cannot carry is never dropped by a save.\n *\n * @module\n */\nimport type {\n ColumnDefault,\n ColumnDescriptor,\n ColumnStorage,\n ColumnType,\n ColumnValidation,\n JsonShape,\n RelationDescriptor,\n TableDescriptor,\n WireColumnDef,\n WireRelation\n} from \"@rebasepro/types\";\nimport type {\n ArrayProperty,\n DateProperty,\n EnumValues,\n MapProperty,\n NumberProperty,\n Properties,\n Property,\n Relation,\n StorageConfig,\n StringProperty\n} from \"@rebasepro/cms-types\";\n\n// ── From what the server serves ─────────────────────────────────────────────\n\n/**\n * A served column as the definition the wire carries: the flags that are off\n * left out, an array's item and a document's shape included.\n */\nexport function wireColumnOfDescriptor(column: ColumnDescriptor): WireColumnDef {\n const def: WireColumnDef = { type: column.type };\n if (column.column !== snakeCase(column.key)) def.column = column.column;\n if (!column.nullable) def.notNull = true;\n if (column.primaryKey) def.primaryKey = true;\n if (column.unique) def.unique = true;\n if (column.readOnly) def.readOnly = true;\n if (column.private) def.private = true;\n if (column.default !== undefined) def.default = column.default;\n if (column.generated !== undefined) def.generatedAs = column.generated.expression;\n if (column.access !== undefined) def.access = column.access;\n if (column.stamp !== undefined) def.stamp = column.stamp;\n if (column.validate !== undefined) def.validate = column.validate;\n if (column.oneOf !== undefined) def.oneOf = column.oneOf;\n if (column.description !== undefined) def.description = column.description;\n if (column.storage !== undefined) def.storage = column.storage;\n if (column.semantic !== undefined) def.semantic = column.semantic;\n if (column.vectorIndex !== undefined) def.vectorIndex = column.vectorIndex;\n if (column.json !== undefined) def.json = column.json;\n if (column.type.kind === \"array\" && column.element) {\n const element: WireColumnDef = { type: column.type.of };\n if (column.element.validate !== undefined) element.validate = column.element.validate;\n if (column.element.oneOf !== undefined) element.oneOf = column.element.oneOf;\n if (column.element.storage !== undefined) element.storage = column.element.storage;\n if (column.element.semantic !== undefined) element.semantic = column.element.semantic;\n def.element = element;\n }\n return def;\n}\n\n/**\n * A served relation as the wire carries it: its kind, its target by slug and\n * the options of its `rel.*` builder, every derived name stated.\n */\nexport function wireRelationOfDescriptor(relation: RelationDescriptor, owner: TableDescriptor): WireRelation {\n const access = {\n ...(relation.access !== undefined ? { access: relation.access } : {}),\n ...(relation.private ? { private: true } : {})\n };\n switch (relation.kind) {\n case \"belongsTo\": {\n const derived = owner.columns.find(column => column.key === relation.localField && column.derived === true);\n return {\n kind: \"belongsTo\",\n target: relation.target,\n localKey: relation.localKey,\n ...(derived && !derived.nullable ? { notNull: true } : {}),\n ...(derived?.unique ? { unique: true } : {}),\n ...(relation.onDelete !== undefined ? { onDelete: relation.onDelete } : {}),\n ...(relation.onUpdate !== undefined ? { onUpdate: relation.onUpdate } : {}),\n ...(relation.index ? {} : { index: false }),\n ...(relation.constraint ? {} : { constraint: false }),\n ...access\n };\n }\n case \"hasOne\":\n case \"hasMany\":\n return {\n kind: relation.kind,\n target: relation.target,\n foreignKey: relation.foreignKey,\n ...(relation.sourceKey !== undefined ? { sourceKey: relation.sourceKey } : {}),\n ...(relation.kind === \"hasMany\" && relation.orderBy !== undefined ? { orderBy: relation.orderBy } : {}),\n ...access\n };\n case \"manyToMany\": {\n const pivot: Record<string, WireColumnDef> = {};\n for (const column of relation.through.pivot) pivot[column.key] = wireColumnOfDescriptor(column);\n return {\n kind: \"manyToMany\",\n target: relation.target,\n through: relation.through.table,\n sourceKey: relation.through.sourceKey,\n targetKey: relation.through.targetKey,\n ...(relation.through.pivot.length > 0 ? { pivot } : {}),\n ...(relation.onDelete !== undefined ? { onDelete: relation.onDelete } : {}),\n ...access\n };\n }\n case \"via\":\n return {\n kind: \"via\",\n target: relation.target,\n steps: relation.steps.map(step => ({ ...step })),\n cardinality: relation.cardinality,\n ...access\n };\n }\n}\n\n// ── From the editor's property ──────────────────────────────────────────────\n\n/**\n * A property the editor cannot write as a column of a table, with why: a\n * relation is a relation, and a view-model type with no column equivalent is\n * not offered for a table.\n */\nexport class PropertyNotAColumnError extends Error {\n constructor(readonly key: string, message: string) {\n super(message);\n this.name = \"PropertyNotAColumnError\";\n }\n}\n\nconst snakeCase = (key: string): string => key\n .replace(/([a-z0-9])([A-Z])/g, \"$1_$2\")\n .replace(/([A-Z])([A-Z][a-z])/g, \"$1_$2\")\n .toLowerCase();\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/** The ids of a property's enum values, whichever form they were written in. */\nexport function enumIds(values: EnumValues | undefined): (string | number)[] | undefined {\n if (values === undefined) return undefined;\n if (Array.isArray(values)) return values.map(value => value.id);\n return Object.keys(values);\n}\n\n/**\n * What the projector makes of a column type — the property's type and its\n * `columnType` — as one key. Two types with the same key are the same choice\n * in the editor's type picker: a column keeps its exact type (a `smallint`, a\n * `varchar(80)`) while the editor leaves that choice alone.\n */\nfunction familyOfType(type: ColumnType, semantic?: string): string {\n switch (type.kind) {\n case \"text\": case \"varchar\": case \"char\": case \"uuid\": return `string:${type.kind}`;\n case \"other\": return \"string:\";\n case \"enum\": return \"string:enum\";\n case \"smallint\": case \"integer\": return \"number:integer\";\n case \"smallserial\": case \"serial\": return \"number:serial\";\n case \"bigint\": case \"bigserial\": case \"real\": case \"numeric\": return `number:${type.kind}`;\n case \"doublePrecision\": return \"number:double precision\";\n case \"boolean\": return \"boolean\";\n case \"timestamptz\": return \"date:timestamp\";\n case \"date\": return \"date:date\";\n case \"time\": return \"date:time\";\n case \"json\": case \"jsonb\": return semantic === \"geopoint\" ? \"geopoint\" : `json:${type.kind}`;\n case \"vector\": return `vector:${type.dimensions}`;\n case \"bytea\": return \"binary\";\n case \"array\": {\n const of = type.of.kind;\n if (of === \"text\" || of === \"varchar\") return \"array:text[]\";\n if (of === \"smallint\" || of === \"integer\" || of === \"bigint\") return \"array:integer[]\";\n if (of === \"boolean\") return \"array:boolean[]\";\n if (of === \"numeric\") return \"array:numeric[]\";\n return `array:${of}`;\n }\n }\n}\n\nfunction familyOfProperty(property: Property): string | undefined {\n switch (property.type) {\n case \"string\":\n if (property.columnType) return `string:${property.columnType}`;\n return property.enum !== undefined ? \"string:enum\" : \"string:\";\n case \"reference\":\n return \"string:\";\n case \"number\":\n return `number:${property.columnType ?? (property.validation?.integer ? \"integer\" : \"double precision\")}`;\n case \"boolean\": return \"boolean\";\n case \"date\": return `date:${property.columnType ?? \"timestamp\"}`;\n case \"geopoint\": return \"geopoint\";\n case \"map\": return `json:${property.columnType ?? \"jsonb\"}`;\n case \"vector\": return `vector:${property.dimensions}`;\n case \"binary\": return \"binary\";\n case \"array\":\n return property.columnType === undefined || property.columnType === \"json\" || property.columnType === \"jsonb\"\n ? `json:${property.columnType ?? \"jsonb\"}`\n : `array:${property.columnType}`;\n case \"relation\": return undefined;\n }\n}\n\n/** The column type a property asks for, read over the type it had. */\nfunction columnTypeOf(key: string, property: Property, base: ColumnType | undefined): ColumnType {\n const family = familyOfProperty(property);\n if (family === undefined) throw new PropertyNotAColumnError(key, `\"${key}\" is a relation, not a column.`);\n if (base && familyOfType(base) === family) {\n // The same choice: keep the exact type, with the editor's enum values.\n if (base.kind === \"enum\" && property.type === \"string\") {\n const values = enumIds(property.enum)?.map(String) ?? [...base.values];\n // The same values in another order is how they are offered, not\n // the type: the order stays as written.\n const sameSet = values.length === base.values.length && values.every(value => base.values.includes(value));\n return sameSet ? base : { ...base, values };\n }\n if (base.kind === \"numeric\" && property.type === \"number\") {\n return compact({ kind: \"numeric\", precision: property.precision, scale: property.scale });\n }\n return base;\n }\n switch (property.type) {\n case \"string\":\n case \"reference\": {\n const columnType = property.type === \"string\" ? property.columnType : undefined;\n if (columnType === \"varchar\" || columnType === \"char\") {\n const max = property.type === \"string\" ? property.validation?.max : undefined;\n return { kind: columnType, length: typeof max === \"number\" && max > 0 ? max : 255 };\n }\n if (columnType === \"uuid\") return { kind: \"uuid\" };\n if (property.type === \"string\" && columnType === undefined && property.enum !== undefined) {\n const values = (enumIds(property.enum) ?? []).map(String);\n if (values.length === 0) throw new PropertyNotAColumnError(key, `\"${key}\" lists no enum values. Add at least one value.`);\n return { kind: \"enum\", values };\n }\n return { kind: \"text\" };\n }\n case \"number\":\n switch (property.columnType) {\n case \"integer\": return { kind: \"integer\" };\n case \"bigint\": return { kind: \"bigint\" };\n case \"serial\": return { kind: \"serial\" };\n case \"bigserial\": return { kind: \"bigserial\" };\n case \"real\": return { kind: \"real\" };\n case \"numeric\": return compact({ kind: \"numeric\", precision: property.precision, scale: property.scale });\n case \"double precision\": return { kind: \"doublePrecision\" };\n default: return property.validation?.integer ? { kind: \"integer\" } : { kind: \"doublePrecision\" };\n }\n case \"boolean\": return { kind: \"boolean\" };\n case \"date\":\n return property.columnType === \"date\" ? { kind: \"date\" } : property.columnType === \"time\" ? { kind: \"time\" } : { kind: \"timestamptz\" };\n case \"geopoint\": return { kind: \"jsonb\" };\n case \"map\": return { kind: property.columnType ?? \"jsonb\" };\n case \"vector\":\n if (!(property.dimensions > 0)) throw new PropertyNotAColumnError(key, `\"${key}\" needs its number of dimensions.`);\n return { kind: \"vector\", dimensions: property.dimensions };\n case \"binary\": return { kind: \"bytea\" };\n case \"array\":\n switch (property.columnType) {\n case \"text[]\": return { kind: \"array\", of: { kind: \"text\" } };\n case \"integer[]\": return { kind: \"array\", of: { kind: \"integer\" } };\n case \"boolean[]\": return { kind: \"array\", of: { kind: \"boolean\" } };\n case \"numeric[]\": return { kind: \"array\", of: { kind: \"numeric\" } };\n default: return { kind: property.columnType ?? \"jsonb\" };\n }\n case \"relation\":\n throw new PropertyNotAColumnError(key, `\"${key}\" is a relation, not a column.`);\n }\n}\n\n/** Drop the keys a builder left `undefined`. */\nfunction compact<T extends object>(value: T): T {\n for (const key of Object.keys(value)) {\n if (Reflect.get(value, key) === undefined) Reflect.deleteProperty(value, key);\n }\n return value;\n}\n\nconst nonEmpty = <T extends object>(value: T): T | undefined =>\n Object.keys(compact(value)).length > 0 ? value : undefined;\n\nconst dateBound = (value: unknown): string | undefined =>\n value instanceof Date && !Number.isNaN(value.getTime()) ? value.toISOString() : typeof value === \"string\" ? value : undefined;\n\n/** A property's validation rules, as a column's `validate`. Required and unique are the column's flags, not rules. */\nfunction validateOf(property: Property, type: ColumnType): ColumnValidation | undefined {\n const rules = property.validation;\n const out: ColumnValidation = {};\n if (rules?.requiredMessage) out.requiredMessage = rules.requiredMessage;\n switch (property.type) {\n case \"string\": {\n const v = property.validation;\n if (v?.min !== undefined) out.min = v.min;\n // A varchar's length is projected as `max`; it is the type's, not a rule.\n const typeLength = type.kind === \"varchar\" || type.kind === \"char\" ? type.length : undefined;\n if (v?.max !== undefined && v.max !== typeLength) out.max = v.max;\n if (v?.length !== undefined) out.length = v.length;\n if (v?.matches !== undefined) {\n if (v.matches instanceof RegExp) {\n out.matches = v.matches.source;\n if (v.matches.flags) out.matchesFlags = v.matches.flags;\n } else {\n out.matches = v.matches;\n }\n }\n if (v?.matchesMessage !== undefined) out.matchesMessage = v.matchesMessage;\n if (v?.trim) out.trim = true;\n if (v?.lowercase) out.lowercase = true;\n if (v?.uppercase) out.uppercase = true;\n if (property.email) out.email = true;\n if (property.url) out.url = true;\n break;\n }\n case \"number\": {\n const v = property.validation;\n if (v?.min !== undefined) out.min = v.min;\n if (v?.max !== undefined) out.max = v.max;\n if (v?.lessThan !== undefined) out.lessThan = v.lessThan;\n if (v?.moreThan !== undefined) out.moreThan = v.moreThan;\n if (v?.positive) out.positive = true;\n if (v?.negative) out.negative = true;\n // An integer column is an integer: the projector says so, the type keeps it.\n const integerType = type.kind === \"smallint\" || type.kind === \"integer\" || type.kind === \"bigint\"\n || type.kind === \"smallserial\" || type.kind === \"serial\" || type.kind === \"bigserial\";\n if (v?.integer && !integerType) out.integer = true;\n break;\n }\n case \"date\": {\n const v = property.validation;\n const min = dateBound(v?.min);\n const max = dateBound(v?.max);\n if (min) out.min = min;\n if (max) out.max = max;\n break;\n }\n case \"array\": {\n const v = property.validation;\n if (v?.min !== undefined) out.minItems = v.min;\n if (v?.max !== undefined) out.maxItems = v.max;\n if (v?.uniqueInArray) out.uniqueItems = true;\n break;\n }\n default:\n break;\n }\n return nonEmpty(out);\n}\n\n/** An upload field's configuration as a column's storage rules. Function-valued options are code, and are not written. */\nexport function columnStorageOf(storage: StorageConfig): ColumnStorage {\n return compact<ColumnStorage>({\n source: typeof storage.storageSource === \"string\" ? storage.storageSource : undefined,\n path: typeof storage.storagePath === \"string\" ? storage.storagePath : \"\",\n accept: storage.acceptedFiles ? [...storage.acceptedFiles] : undefined,\n maxBytes: storage.maxSize,\n imageResize: storage.imageResize ? { ...storage.imageResize } : undefined,\n public: storage.public,\n fileName: typeof storage.fileName === \"string\" ? storage.fileName : undefined,\n metadata: storage.metadata ? { ...storage.metadata } : undefined,\n includeBucketUrl: storage.includeBucketUrl,\n storeUrl: storage.storeUrl\n });\n}\n\n/** The nominal column type a JSON node's rules are read against: never a length or an integer type. */\nconst NODE_RULE_TYPE: Readonly<Record<\"string\" | \"number\" | \"date\" | \"array\", ColumnType>> = {\n string: { kind: \"text\" },\n number: { kind: \"numeric\" },\n date: { kind: \"timestamptz\" },\n array: { kind: \"jsonb\" }\n};\n\n/**\n * A JSON node's rules: the ones the property states, and the API error for a\n * missing key, which the form never shows and so never edits, kept from the\n * served node.\n */\nfunction nodeRules(property: Property, kind: keyof typeof NODE_RULE_TYPE, served: JsonShape | undefined): ColumnValidation | undefined {\n const rules: ColumnValidation = { ...validateOf(property, NODE_RULE_TYPE[kind]) };\n const servedMessage = served && \"validate\" in served ? served.validate?.requiredMessage : undefined;\n if (rules.requiredMessage === undefined && servedMessage !== undefined) rules.requiredMessage = servedMessage;\n if (property.type === \"array\" && !Array.isArray(property.of) && property.of?.type === \"map\" && property.of.properties) {\n // `uniqueBy` is projected onto the item's fields as `uniqueInArray` —\n // on a field that is not itself an array, where it means `uniqueItems`.\n const uniqueBy = Object.entries(property.of.properties)\n .filter(([, field]) => marksUniqueBy(field))\n .map(([key]) => key);\n if (uniqueBy.length > 0) rules.uniqueBy = uniqueBy;\n }\n return nonEmpty(rules);\n}\n\n/**\n * The DEFAULT of a JSON node: the property's `defaultValue` for the kinds the\n * form opens with one, else the served node's, which the form never shows.\n */\nfunction nodeDefault(property: Property, served: JsonShape | undefined, kind: JsonShape[\"kind\"]): unknown {\n switch (property.type) {\n case \"string\":\n case \"number\":\n case \"boolean\":\n case \"map\":\n case \"array\":\n if (kind !== \"unknown\") return property.defaultValue;\n break;\n default:\n break;\n }\n return served?.kind === kind ? served.default : undefined;\n}\n\n/**\n * A JSON document's node, from the property that edits it, read over the\n * node as served: what the form does not carry (a user stamp, an open\n * object, the API error for a missing key, a default it does not open with)\n * is kept from `served`, so a save never drops it.\n *\n * @param property the property that edits the node\n * @param served the node as the column serves it, when there is one\n */\nexport function jsonShapeOf(property: Property, served?: JsonShape): JsonShape {\n return nodeShape(property, served, {\n description: property.description,\n required: property.validation?.required ? true : undefined\n });\n}\n\n/**\n * One node. `base` is what the node says about itself: for a nested node,\n * read from its property; for the document itself, the served node's — the\n * property's description and required flag are the column's.\n */\nfunction nodeShape(property: Property, served: JsonShape | undefined, base: { description?: string; required?: true }): JsonShape {\n const head = (kind: JsonShape[\"kind\"]) => compact({ ...base, default: nodeDefault(property, served, kind) });\n switch (property.type) {\n case \"string\":\n case \"reference\": {\n const oneOf = property.type === \"string\" ? enumIds(property.enum)?.map(String) : undefined;\n const storage = property.type === \"string\" && property.storage ? columnStorageOf(property.storage) : undefined;\n const stamp = served?.kind === \"string\" ? served.stamp : undefined;\n return compact({\n ...head(\"string\"),\n kind: \"string\" as const,\n validate: nodeRules(property, \"string\", served),\n oneOf,\n storage,\n stamp,\n semantic: property.type === \"string\" && property.userSelect ? \"user\" as const : undefined\n });\n }\n case \"number\": {\n const oneOf = enumIds(property.enum)?.filter((id): id is number => typeof id === \"number\");\n return compact({ ...head(\"number\"), kind: \"number\" as const, validate: nodeRules(property, \"number\", served), oneOf: oneOf && oneOf.length > 0 ? oneOf : undefined });\n }\n case \"boolean\": return { ...head(\"boolean\"), kind: \"boolean\" };\n case \"date\": {\n const stamp = property.autoValue === \"on_create\" ? \"create\" as const : property.autoValue === \"on_update\" ? \"update\" as const : undefined;\n return compact({ ...head(\"date\"), kind: \"date\" as const, validate: nodeRules(property, \"date\", served), stamp });\n }\n case \"geopoint\": return { ...head(\"geopoint\"), kind: \"geopoint\" };\n case \"map\": {\n if (!property.properties || property.keyValue) return { ...head(\"unknown\"), kind: \"unknown\" };\n const servedObject = served?.kind === \"object\" ? served : undefined;\n return compact({\n ...head(\"object\"),\n kind: \"object\" as const,\n fields: jsonFieldsOf(property.properties, property.propertiesOrder, servedObject?.fields),\n additional: servedObject?.additional\n });\n }\n case \"array\": {\n const servedArray = served?.kind === \"array\" ? served : undefined;\n const validate = nodeRules(property, \"array\", served);\n if (property.oneOf) {\n const servedVariants = servedArray?.of.kind === \"oneOf\" ? servedArray.of.variants : undefined;\n return compact({\n ...head(\"array\"),\n kind: \"array\" as const,\n validate,\n of: {\n kind: \"oneOf\" as const,\n typeField: property.oneOf.typeField ?? \"type\",\n valueField: property.oneOf.valueField ?? \"value\",\n variants: jsonFieldsOf(property.oneOf.properties, property.oneOf.propertiesOrder, servedVariants)\n }\n });\n }\n const item = Array.isArray(property.of) ? undefined : property.of;\n return compact({\n ...head(\"array\"),\n kind: \"array\" as const,\n validate,\n of: item ? jsonShapeOf(withoutItemUniqueness(item), servedArray?.of) : { kind: \"unknown\" as const }\n });\n }\n default:\n return { ...head(\"unknown\"), kind: \"unknown\" };\n }\n}\n\n/** Whether an array item's field carries the `uniqueInArray` mark of its array's `uniqueBy`. */\nfunction marksUniqueBy(field: Property): boolean {\n return field.type !== \"array\" && field.validation !== undefined\n && \"uniqueInArray\" in field.validation && field.validation.uniqueInArray === true;\n}\n\n/**\n * An array's item without the `uniqueInArray` marks `uniqueBy` put on its\n * fields: those are the array's rule ({@link nodeRules}), not the fields'.\n */\nfunction withoutItemUniqueness(item: Property): Property {\n if (item.type !== \"map\" || !item.properties) return item;\n const properties: Properties = {};\n for (const [key, field] of Object.entries(item.properties)) {\n if (!marksUniqueBy(field) || field.validation === undefined || !(\"uniqueInArray\" in field.validation)) {\n properties[key] = field;\n continue;\n }\n const { uniqueInArray: _unique, ...validation } = field.validation;\n void _unique;\n properties[key] = Object.assign({}, field, { validation });\n }\n return { ...item, properties };\n}\n\nfunction jsonFieldsOf(properties: Properties, order: readonly string[] | undefined, served: Record<string, JsonShape> | undefined): Record<string, JsonShape> {\n const keys = [...(order ?? []).filter(key => key in properties), ...Object.keys(properties).filter(key => !order?.includes(key))];\n const out: Record<string, JsonShape> = {};\n for (const key of keys) out[key] = jsonShapeOf(properties[key], served?.[key]);\n return out;\n}\n\n/** The DEFAULT a property states, if any. */\nfunction defaultOf(property: Property, base: ColumnDefault | undefined): ColumnDefault | undefined {\n const databaseDefault = property.databaseDefault;\n if (typeof databaseDefault === \"string\") {\n const expression = databaseDefault.replace(/^sql`/, \"\").replace(/`$/, \"\");\n return { kind: \"sql\", expression };\n }\n if (databaseDefault === true) {\n // The database's own default: keep what the column states, whatever kind it is.\n return base && base.kind !== \"literal\" ? base : { kind: \"database\" };\n }\n const value = \"defaultValue\" in property ? property.defaultValue : undefined;\n if (value === undefined || value === null) return undefined;\n if (value instanceof Date) return { kind: \"literal\", value: value.toISOString() };\n return { kind: \"literal\", value };\n}\n\n/** The id strategy of a primary-key property, as a column default. */\nfunction idDefault(property: Property, type: ColumnType): ColumnDefault | undefined {\n const isId = property.type === \"string\" || property.type === \"number\" || property.type === \"date\" ? property.isId : undefined;\n if (isId === \"uuid\") return { kind: \"random-uuid\" };\n if (isId === \"increment\") {\n return type.kind === \"serial\" || type.kind === \"bigserial\" || type.kind === \"smallserial\" ? undefined : { kind: \"identity\" };\n }\n return undefined;\n}\n\nconst isIdProperty = (property: Property): boolean => {\n const isId = property.type === \"string\" || property.type === \"number\" || property.type === \"date\" ? property.isId : undefined;\n return isId !== undefined && isId !== false;\n};\n\n/** The stamp a property's `autoValue` asks for. */\nfunction stampOf(property: Property): WireColumnDef[\"stamp\"] {\n const auto = property.type === \"date\" || property.type === \"string\" ? property.autoValue : undefined;\n switch (auto) {\n case \"on_create\": return { on: \"create\", value: \"now\" };\n case \"on_update\": return { on: \"update\", value: \"now\" };\n case \"user_on_create\": return { on: \"create\", value: \"user\" };\n case \"user_on_update\": return { on: \"update\", value: \"user\" };\n default: return undefined;\n }\n}\n\n/**\n * A property as the column the schema editor writes, read over `base` — the\n * column as served, when there is one.\n *\n * Throws {@link PropertyNotAColumnError} for a relation, and for a property\n * the editor cannot express as a column.\n */\nexport function wireColumnFromProperty(key: string, property: Property, base?: WireColumnDef): WireColumnDef {\n const type = columnTypeOf(key, property, base?.type);\n const sameType = base !== undefined && JSON.stringify(base.type) === JSON.stringify(type);\n const out: WireColumnDef = { type };\n\n if (property.columnName && property.columnName !== snakeCase(key)) out.column = property.columnName;\n else if (base?.column !== undefined && !property.columnName) out.column = base.column;\n\n const isKey = isIdProperty(property);\n const stamp = stampOf(property);\n if (isKey) out.primaryKey = true;\n const generatedId = isKey ? idDefault(property, type) : undefined;\n\n // Not null: required, or a primary key. A column the server fills (a\n // generated id, a stamp, a read-only or generated column) is never\n // \"required\" in the form, so its nullability is kept from the column.\n const writtenByServer = Boolean(generatedId || stamp || base?.readOnly || base?.generatedAs\n || (isKey && property.type === \"number\" && property.isId === \"increment\"));\n if (isKey || property.validation?.required || (writtenByServer && base?.notNull)) out.notNull = true;\n if (property.validation?.unique && !isKey) out.unique = true;\n if (base?.readOnly) out.readOnly = true;\n if (base?.private) out.private = true;\n\n const fallback = generatedId ?? (isKey && base?.default && base.default.kind !== \"literal\" ? base.default : undefined)\n ?? defaultOf(property, base?.default);\n if (fallback) out.default = fallback;\n if (base?.generatedAs !== undefined) out.generatedAs = base.generatedAs;\n\n if (property.access) {\n out.access = compact({\n read: property.access.read ? [...property.access.read] : undefined,\n write: property.access.write ? [...property.access.write] : undefined\n });\n }\n if (stamp) out.stamp = stamp;\n else if (base?.stamp && property.type !== \"date\" && property.type !== \"string\") out.stamp = base.stamp;\n\n // A document's rules are its shape's (below); the column's own, which the\n // form does not show, are kept as served.\n const isDocument = type.kind === \"json\" || type.kind === \"jsonb\";\n const validate = isDocument ? base?.validate : validateOf(property, type);\n if (validate) out.validate = validate;\n\n // Enum values on a non-enum column are `.oneOf()`.\n if (type.kind !== \"enum\" && (property.type === \"string\" || property.type === \"number\") && property.enum !== undefined) {\n out.oneOf = enumIds(property.enum);\n }\n if (property.description !== undefined) out.description = property.description;\n else if (base?.description !== undefined) out.description = base.description;\n\n if (property.type === \"string\" && property.storage) out.storage = columnStorageOf(property.storage);\n if (property.type === \"string\" && property.userSelect) out.semantic = \"user\";\n if (property.type === \"geopoint\") out.semantic = \"geopoint\";\n if (sameType && base?.vectorIndex !== undefined) out.vectorIndex = base.vectorIndex;\n\n if (property.type === \"array\" && type.kind === \"array\") {\n const item = Array.isArray(property.of) ? undefined : property.of;\n // A storage column with `.multiple()` states its storage on the column.\n if (item?.type === \"string\" && item.storage && base?.storage) out.storage = columnStorageOf(item.storage);\n else if (item) {\n const element: WireColumnDef = { type: type.of };\n if (item.type === \"string\" || item.type === \"number\") {\n const oneOf = enumIds(item.enum);\n if (oneOf) element.oneOf = oneOf;\n }\n if (item.type === \"string\" && item.storage) element.storage = columnStorageOf(item.storage);\n if (item.type === \"string\" && item.userSelect) element.semantic = \"user\";\n const itemRules = validateOf(item, type.of);\n if (itemRules) element.validate = itemRules;\n if (Object.keys(element).length > 1) out.element = element;\n }\n }\n if (isDocument) {\n const shaped = (property.type === \"map\" && property.properties && !property.keyValue) || property.type === \"array\";\n if (shaped) {\n const servedShape = sameType ? base?.json : undefined;\n // The document's own description and required flag are the\n // served node's: the property's are the column's.\n const shape = nodeShape(property, servedShape, compact({\n description: servedShape?.description,\n required: servedShape?.required ? true as const : undefined\n }));\n // A shape the editor reads the same way as the served one is the\n // served one: its nested hooks and defaults stay as written.\n out.json = sameType && base?.json && JSON.stringify(stripShape(base.json)) === JSON.stringify(stripShape(shape)) ? base.json : shape;\n } else if (sameType && base?.json && property.type === \"map\" && property.keyValue) {\n out.json = base.json;\n }\n }\n return out;\n}\n\n/** The parts of a JSON shape the editor reads, for comparing two. */\nfunction stripShape(shape: JsonShape): unknown {\n if (!isRecord(shape)) return shape;\n const { default: _default, ...rest } = shape;\n void _default;\n return rest;\n}\n\n/** The slug a relation's target points at. */\nexport function relationTargetSlug(relation: Relation, fallback?: string): string | undefined {\n try {\n const target: unknown = relation.target();\n if (isRecord(target) && typeof target.slug === \"string\") return target.slug;\n } catch {\n // A target that is not loaded: the caller's fallback stands.\n }\n return fallback;\n}\n\n/**\n * A relation the editor shows, as the relation the schema editor writes, read\n * over `base` — the relation as served, when there is one.\n */\nexport function wireRelationFromRelation(\n name: string,\n relation: Relation,\n options: {\n base?: WireRelation;\n /** The relation's field is required in the form. */\n required?: boolean;\n /**\n * The foreign key is the relation's own (no column declares it), so\n * its nullability is the relation's `notNull`. A foreign key a column\n * declares states its nullability on that column.\n */\n ownsForeignKey?: boolean;\n access?: Property[\"access\"];\n } = {}\n): WireRelation {\n const { base } = options;\n const target = relationTargetSlug(relation, base?.target);\n if (!target) throw new PropertyNotAColumnError(name, `The relation \"${name}\" has no target table. Pick the table it points at.`);\n const access = options.access\n ? { access: compact({ read: options.access.read ? [...options.access.read] : undefined, write: options.access.write ? [...options.access.write] : undefined }) }\n : base?.access !== undefined ? { access: base.access } : {};\n const isPrivate = base?.private ? { private: true } : {};\n switch (relation.kind) {\n case \"belongsTo\": {\n const from = base?.kind === \"belongsTo\" ? base : undefined;\n return compact({\n ...from,\n kind: \"belongsTo\" as const,\n target,\n localKey: relation.localKey ?? from?.localKey,\n notNull: options.ownsForeignKey === false ? from?.notNull : options.required ? true : undefined,\n onDelete: relation.onDelete,\n onUpdate: relation.onUpdate,\n index: relation.index === false ? false : relation.index === true ? undefined : from?.index,\n ...access,\n ...isPrivate\n });\n }\n case \"hasOne\":\n case \"hasMany\": {\n const from = base?.kind === relation.kind ? base : undefined;\n return compact({\n ...from,\n kind: relation.kind,\n target,\n foreignKey: relation.foreignKeyOnTarget ?? from?.foreignKey,\n sourceKey: relation.sourceKey ?? from?.sourceKey,\n ...access,\n ...isPrivate\n });\n }\n case \"manyToMany\": {\n const from = base?.kind === \"manyToMany\" ? base : undefined;\n return compact({\n ...from,\n kind: \"manyToMany\" as const,\n target,\n through: relation.through?.table ?? from?.through,\n sourceKey: relation.through?.sourceColumn ?? from?.sourceKey,\n targetKey: relation.through?.targetColumn ?? from?.targetKey,\n onDelete: relation.onDelete,\n ...access,\n ...isPrivate\n });\n }\n case \"via\":\n return compact({\n kind: \"via\" as const,\n target,\n steps: relation.joinPath.map(step => ({ ...step })),\n cardinality: relation.cardinality,\n ...access,\n ...isPrivate\n });\n }\n}\n\n/** Whether a property is one the editor writes as a column (not a relation). */\nexport function isColumnProperty(property: Property): boolean {\n return property.type !== \"relation\";\n}\n\n/** The view-model property types a table column can be, in the type picker's order. */\nexport const TABLE_PROPERTY_TYPES: readonly Property[\"type\"][] = [\n \"string\", \"number\", \"boolean\", \"date\", \"map\", \"array\", \"geopoint\", \"vector\", \"binary\", \"relation\"\n];\n\n/** Narrowings the module's callers need without importing the property types. */\nexport type { ArrayProperty, DateProperty, MapProperty, NumberProperty, StringProperty };\n"],"mappings":";;;;;AAkDA,SAAgB,uBAAuB,QAAyC;CAC5E,MAAM,MAAqB,EAAE,MAAM,OAAO,KAAK;CAC/C,IAAI,OAAO,WAAW,UAAU,OAAO,GAAG,GAAG,IAAI,SAAS,OAAO;CACjE,IAAI,CAAC,OAAO,UAAU,IAAI,UAAU;CACpC,IAAI,OAAO,YAAY,IAAI,aAAa;CACxC,IAAI,OAAO,QAAQ,IAAI,SAAS;CAChC,IAAI,OAAO,UAAU,IAAI,WAAW;CACpC,IAAI,OAAO,SAAS,IAAI,UAAU;CAClC,IAAI,OAAO,YAAY,KAAA,GAAW,IAAI,UAAU,OAAO;CACvD,IAAI,OAAO,cAAc,KAAA,GAAW,IAAI,cAAc,OAAO,UAAU;CACvE,IAAI,OA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G;IACH,GAAG;GACP,CAAC;EACL;EACA,KAAK;EACL,KAAK,WAAW;GACZ,MAAM,OAAO,MAAM,SAAS,SAAS,OAAO,OAAO,KAAA;GACnD,OAAO,QAAQ;IACX,GAAG;IACH,MAAM,SAAS;IACf;IACA,YAAY,SAAS,sBAAsB,MAAM;IACjD,WAAW,SAAS,aAAa,MAAM;IACvC,GAAG;IACH,GAAG;GACP,CAAC;EACL;EACA,KAAK,cAAc;GACf,MAAM,OAAO,MAAM,SAAS,eAAe,OAAO,KAAA;GAClD,OAAO,QAAQ;IACX,GAAG;IACH,MAAM;IACN;IACA,SAAS,SAAS,SAAS,SAAS,MAAM;IAC1C,WAAW,SAAS,SAAS,gBAAgB,MAAM;IACnD,WAAW,SAAS,SAAS,gBAAgB,MAAM;IACnD,UAAU,SAAS;IACnB,GAAG;IACH,GAAG;GACP,CAAC;EACL;EACA,KAAK,OACD,OAAO,QAAQ;GACX,MAAM;GACN;GACA,OAAO,SAAS,SAAS,KAAI,UAAS,EAAE,GAAG,KAAK,EAAE;GAClD,aAAa,SAAS;GACtB,GAAG;GACH,GAAG;EACP,CAAC;CACT;AACJ"}
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @module
|
|
12
12
|
*/
|
|
13
|
-
import type {
|
|
14
|
-
import type { CollectionSize, KanbanConfig,
|
|
13
|
+
import type { FilterValues, JoinStep, OnAction, SecurityRule, WhereFilterOp } from "@rebasepro/types";
|
|
14
|
+
import type { CollectionSize, KanbanConfig, ViewMode, FilterPreset, ArrayPropertyValidationSchema, EnumValues, FileType, ImageResize, NumberPropertyValidationSchema, PropertyConditions, PropertyValidationSchema, SqlExpression } from "@rebasepro/cms-types";
|
|
15
15
|
/**
|
|
16
16
|
* JSON-serializable version of `AdminPropertyOptions`.
|
|
17
17
|
* Drops `Field` and `Preview` (ComponentRef — functions/components).
|
|
@@ -450,25 +450,3 @@ export interface SerializableCollectionConfig {
|
|
|
450
450
|
*/
|
|
451
451
|
metadata?: Record<string, unknown>;
|
|
452
452
|
}
|
|
453
|
-
/**
|
|
454
|
-
* Adapter interface for persisting serializable collections to a JSON backend.
|
|
455
|
-
* Implement this to store collection configs in a database, API, localStorage, etc.
|
|
456
|
-
*/
|
|
457
|
-
export interface JsonCollectionStore {
|
|
458
|
-
/** Load all persisted collections. */
|
|
459
|
-
load(): Promise<SerializableCollectionConfig[]>;
|
|
460
|
-
/** Save (create or update) a single collection by its slug. */
|
|
461
|
-
save(slug: string, data: SerializableCollectionConfig): Promise<void>;
|
|
462
|
-
/** Delete a collection by its slug. */
|
|
463
|
-
delete(slug: string): Promise<void>;
|
|
464
|
-
/**
|
|
465
|
-
* Optional: save navigation group mappings.
|
|
466
|
-
* If not implemented, navigation entries are not persisted.
|
|
467
|
-
*/
|
|
468
|
-
saveNavigationEntries?(entries: NavigationGroupMapping[]): Promise<void>;
|
|
469
|
-
/**
|
|
470
|
-
* Optional: load navigation group mappings.
|
|
471
|
-
* If not implemented, an empty array is used.
|
|
472
|
-
*/
|
|
473
|
-
loadNavigationEntries?(): Promise<NavigationGroupMapping[]>;
|
|
474
|
-
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
|
-
import { type Properties, type Property } from "@rebasepro/types";
|
|
10
|
+
import { type Properties, type Property } from "@rebasepro/cms-types";
|
|
11
11
|
import type { AdminCollection } from "@rebasepro/cms-types";
|
|
12
12
|
import type { SerializableCollectionConfig, SerializableProperties, SerializableProperty } from "./serializable_types.js";
|
|
13
13
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isRelationalCollectionConfig
|
|
1
|
+
import { isRelationalCollectionConfig } from "@rebasepro/cms-types";
|
|
2
|
+
import { resourceKeyOf } from "@rebasepro/types";
|
|
2
3
|
import { serializeRegExp } from "@rebasepro/utils";
|
|
3
4
|
//#region src/collection_editor/serializable_utils.ts
|
|
4
5
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializable_utils.js","names":[],"sources":["../../src/collection_editor/serializable_utils.ts"],"sourcesContent":["/**\n * Conversion utilities between the full Rebase types and their\n * JSON-serializable counterparts.\n *\n * - `toSerializableCollectionConfig` / `toSerializableProperty` — strip non-serializable fields\n * - `fromSerializableCollectionConfig` / `fromSerializableProperty` — reconstruct original types\n *\n * @module\n */\n\nimport { resourceKeyOf } from \"@rebasepro/types\";\nimport { serializeRegExp } from \"@rebasepro/utils\";\nimport { isRelationalCollectionConfig, type Relation, type ArrayProperty, type BinaryProperty, type BooleanProperty, type DateProperty, type GeopointProperty, type MapProperty, type NumberProperty, type Properties, type Property, type ReferenceProperty, type RelationProperty, type StorageConfig, type StringProperty, type VectorProperty } from \"@rebasepro/types\";\nimport type { AdminPropertyOptions } from \"@rebasepro/cms-types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nimport type {\n SerializableArrayProperty,\n SerializableBaseProperty,\n SerializableAdminBaseOptions,\n SerializableBinaryProperty,\n SerializableBooleanProperty,\n SerializableCollectionConfig,\n SerializableDateProperty,\n SerializableDateValidation,\n SerializableGeopointProperty,\n SerializableMapProperty,\n SerializableNumberProperty,\n SerializableProperties,\n SerializableProperty,\n SerializableReferenceProperty,\n SerializableRelation,\n SerializableRelationProperty,\n SerializableStorageConfig,\n SerializableStringProperty,\n SerializableStringValidation,\n SerializableVectorProperty\n} from \"./serializable_types\";\n\n/**\n * Resolves a collection slug to the collection it names.\n *\n * Needed on the way back from JSON: a relation's `target` is a thunk, which\n * does not serialize, so it travels as a slug and has to be made callable\n * again against the other collections in the same set.\n */\nexport type CollectionLookup = (slug: string) => AdminCollection | undefined;\n\n/**\n * Rebuild a serialized relation's `target` slug into the thunk consumers call.\n *\n * Shared by the relation *property* and the collection-level `relations` array.\n * They are the same shape on the wire and they need the same treatment coming\n * back, but only the property path had it — so a collection imported from an\n * existing table came off disk with `relations[n].target` still a string, which\n * typechecks (the serializable shape erases the difference) and throws \"target\n * is not a function\" at the first consumer.\n *\n * The lookup is consulted lazily, inside the thunk, so collections may\n * reference each other in any order, including circularly.\n */\nfunction fromSerializableRelation<R extends { target?: string; relationName?: string }>(\n relation: R,\n label: string,\n lookup?: CollectionLookup\n): R & { target: () => AdminCollection } {\n const slug = relation.target;\n return {\n ...relation,\n target: () => {\n const found = slug ? lookup?.(slug) : undefined;\n if (!found) {\n throw new Error(\n `Relation \"${relation.relationName ?? label}\" targets collection \"${slug ?? \"(none)\"}\", ` +\n \"which is not among the collections it was deserialized with. Pass the whole set to \" +\n \"`fromSerializableCollectionConfigs` so slugs can be resolved against each other.\"\n );\n }\n return found;\n }\n };\n}\n\n// ═══════════════════════════════════════════════════════════════════════\n// PROPERTY CONVERSION: Original → Serializable\n// ═══════════════════════════════════════════════════════════════════════\n\n/**\n * Strip non-serializable fields from a `AdminPropertyOptions`.\n * Removes `Field` and `Preview` (ComponentRef).\n */\n/**\n * Every `ComponentRef` on a property's admin block. These are components, not\n * data, and none of them survives `JSON.stringify` — a function-valued key is\n * dropped from the output object with no error, so a component written here\n * would leave a key that reads back as missing rather than as itself.\n *\n * `Filter` was absent from this list while `Field` and `Preview` were named\n * twice, once destructured and once compared by string.\n */\nconst NON_SERIALIZABLE_ADMIN_KEYS = [\"Field\", \"Preview\", \"Filter\"];\n\nfunction toSerializableAdminOptions(ui: AdminPropertyOptions | undefined): SerializableAdminBaseOptions | undefined {\n if (!ui) return undefined;\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(ui as Record<string, unknown>)) {\n if (!NON_SERIALIZABLE_ADMIN_KEYS.includes(key) && value !== undefined) {\n result[key] = value;\n }\n }\n return Object.keys(result).length > 0 ? result as SerializableAdminBaseOptions : undefined;\n}\n\n/**\n * Convert a `StorageConfig` to its serializable form.\n * Drops function variants of `storagePath`, `fileName`, and all function fields.\n */\nfunction toSerializableStorageConfig(storage: StorageConfig | undefined): SerializableStorageConfig | undefined {\n if (!storage) return undefined;\n\n // storagePath must be a string for serialization\n const storagePath = typeof storage.storagePath === \"string\" ? storage.storagePath : undefined;\n if (!storagePath) return undefined;\n\n const result: SerializableStorageConfig = { storagePath };\n\n if (storage.acceptedFiles) result.acceptedFiles = storage.acceptedFiles;\n if (storage.imageResize) result.imageResize = storage.imageResize;\n if (storage.metadata) result.metadata = storage.metadata;\n if (typeof storage.fileName === \"string\") result.fileName = storage.fileName;\n if (storage.includeBucketUrl !== undefined) result.includeBucketUrl = storage.includeBucketUrl;\n if (storage.storeUrl !== undefined) result.storeUrl = storage.storeUrl;\n if (storage.maxSize !== undefined) result.maxSize = storage.maxSize;\n if (storage.storageSource !== undefined) result.storageSource = resourceKeyOf(storage.storageSource);\n // processFile, postProcess, previewUrl are intentionally dropped (functions)\n\n return result;\n}\n\n/**\n * Convert a RegExp or string `matches` validation to a plain string: the\n * `/source/flags` form `hydrateRegExp` reads back, so a flag such as `i`\n * survives the round trip.\n */\nfunction serializeMatches(matches: string | RegExp | undefined): string | undefined {\n if (matches === undefined) return undefined;\n if (typeof matches === \"string\") return matches;\n return serializeRegExp(matches);\n}\n\n/**\n * Resolve a relation target to a string slug.\n * Functions are called to extract the target; AdminCollection objects\n * use their slug.\n */\nfunction resolveRelationTarget(target: RelationProperty[\"relation\"] extends infer R ? R extends { target: infer T } ? T : never : never): string | undefined {\n if (!target) return undefined;\n if (typeof target === \"string\") return target;\n if (typeof target === \"function\") {\n try {\n const resolved = target();\n if (typeof resolved === \"string\") return resolved;\n if (resolved && typeof resolved === \"object\" && \"slug\" in resolved) {\n return (resolved as AdminCollection).slug;\n }\n } catch {\n // If the lazy resolver throws (e.g., circular dependency not yet ready), return undefined\n }\n }\n return undefined;\n}\n\n/**\n * A `Relation` as JSON: `target` resolved from its thunk down to a slug.\n *\n * Switched on `kind` and assigned without a cast, so the compiler checks that\n * each branch writes the fields its kind owns and no others. This used to be\n * built as an untyped bag and cast into place — which is how the target\n * interface drifted a whole refactor behind the code writing to it.\n *\n * Shared by the relation *property* and the collection-level `relations` array,\n * which had no serializer at all: `buildCollectionFromTableMetadata` fills that\n * array from the table's foreign keys and junctions on import, and every one of\n * them was dropped on save.\n */\nfunction toSerializableRelation(link: Relation): SerializableRelation {\n const target = resolveRelationTarget(link.target);\n const common = {\n ...(target ? { target } : {}),\n ...(link.relationName ? { relationName: link.relationName } : {}),\n ...(link.onUpdate ? { onUpdate: link.onUpdate } : {}),\n ...(link.onDelete ? { onDelete: link.onDelete } : {})\n };\n switch (link.kind) {\n case \"belongsTo\":\n return {\n kind: \"belongsTo\",\n ...common,\n ...(link.localKey ? { localKey: link.localKey } : {}),\n // Only the opt-out: `true` is the default, and writing it into\n // every saved relation would be noise in the author's file.\n ...(link.index === false ? { index: false } : {})\n };\n case \"hasOne\":\n case \"hasMany\":\n return {\n kind: link.kind,\n ...common,\n ...(link.foreignKeyOnTarget ? { foreignKeyOnTarget: link.foreignKeyOnTarget } : {}),\n ...(link.sourceKey ? { sourceKey: link.sourceKey } : {})\n };\n case \"manyToMany\":\n return { kind: \"manyToMany\", ...common, ...(link.through ? { through: link.through } : {}) };\n case \"via\":\n return { kind: \"via\", ...common, cardinality: link.cardinality, joinPath: link.joinPath };\n default: {\n const exhaustive: never = link;\n throw new Error(`Unhandled relation kind: ${JSON.stringify(exhaustive)}`);\n }\n }\n}\n\n/**\n * Strip non-serializable base property fields.\n * Returns a clean object with only the common serializable fields from BaseProperty.\n * Validation is intentionally excluded — each property type handles its own.\n */\nfunction toSerializableBaseFields(property: Property): Omit<SerializableBaseProperty, \"validation\"> {\n const result: Partial<Omit<SerializableBaseProperty, \"validation\">> = {\n name: property.name\n };\n\n if (property.description) result.description = property.description;\n if (property.propertyConfig) result.propertyConfig = property.propertyConfig;\n if (property.columnName) result.columnName = property.columnName;\n if (property.excludeFromApi !== undefined) result.excludeFromApi = property.excludeFromApi;\n if (property.access !== undefined) result.access = property.access;\n if (property.defaultValue !== undefined) result.defaultValue = property.defaultValue;\n if (property.databaseDefault !== undefined) result.databaseDefault = property.databaseDefault;\n if (property.conditions) result.conditions = property.conditions;\n if (property.metadata) result.metadata = property.metadata;\n // dynamicProps and callbacks are intentionally dropped (functions)\n\n const ui = toSerializableAdminOptions(property.admin);\n if (ui) result.admin = ui;\n\n return result as Omit<SerializableBaseProperty, \"validation\">;\n}\n\n/**\n * Convert a single `Property` to its JSON-serializable form.\n * Strips functions, converts RegExp to string, Date to ISO string.\n */\nexport function toSerializableProperty(property: Property): SerializableProperty {\n const base = toSerializableBaseFields(property);\n\n switch (property.type) {\n case \"string\": {\n const sp = property as StringProperty;\n const result: SerializableStringProperty = {\n ...base,\n type: \"string\"\n };\n if (sp.columnType) result.columnType = sp.columnType;\n if (sp.isId !== undefined) result.isId = sp.isId;\n if (sp.enum) result.enum = sp.enum;\n if (sp.userSelect) result.userSelect = sp.userSelect;\n if (sp.email) result.email = sp.email;\n if (sp.url) result.url = sp.url;\n if (sp.autoValue) result.autoValue = sp.autoValue;\n\n // Convert validation.matches from RegExp to string\n if (sp.validation) {\n const { matches, ...restValidation } = sp.validation;\n const serializedValidation: SerializableStringValidation = { ...restValidation };\n const matchStr = serializeMatches(matches);\n if (matchStr !== undefined) serializedValidation.matches = matchStr;\n result.validation = serializedValidation;\n }\n\n // Storage: convert to serializable form\n const storage = toSerializableStorageConfig(sp.storage);\n if (storage) result.storage = storage;\n\n return result;\n }\n\n case \"number\": {\n const np = property as NumberProperty;\n const result: SerializableNumberProperty = {\n ...base,\n type: \"number\"\n };\n if (np.columnType) result.columnType = np.columnType;\n if (np.validation) result.validation = np.validation;\n if (np.isId !== undefined) result.isId = np.isId;\n if (np.enum) result.enum = np.enum;\n if (np.precision !== undefined) result.precision = np.precision;\n if (np.scale !== undefined) result.scale = np.scale;\n return result;\n }\n\n case \"boolean\": {\n const bp = property as BooleanProperty;\n const result: SerializableBooleanProperty = {\n ...base,\n type: \"boolean\"\n };\n if (bp.validation) result.validation = bp.validation;\n return result;\n }\n\n case \"date\": {\n const dp = property as DateProperty;\n const result: SerializableDateProperty = {\n ...base,\n type: \"date\"\n };\n if (dp.columnType) result.columnType = dp.columnType;\n if (dp.mode) result.mode = dp.mode;\n if (dp.timezone) result.timezone = dp.timezone;\n if (dp.autoValue) result.autoValue = dp.autoValue;\n\n // Convert Date validation min/max to ISO strings\n if (dp.validation) {\n const serializedValidation: SerializableDateValidation = {};\n if (dp.validation.required !== undefined) serializedValidation.required = dp.validation.required;\n if (dp.validation.requiredMessage) serializedValidation.requiredMessage = dp.validation.requiredMessage;\n if (dp.validation.unique) serializedValidation.unique = dp.validation.unique;\n if (dp.validation.uniqueInArray) serializedValidation.uniqueInArray = dp.validation.uniqueInArray;\n if (dp.validation.min instanceof Date) {\n serializedValidation.min = dp.validation.min.toISOString();\n } else if (typeof dp.validation.min === \"string\") {\n serializedValidation.min = dp.validation.min;\n }\n if (dp.validation.max instanceof Date) {\n serializedValidation.max = dp.validation.max.toISOString();\n } else if (typeof dp.validation.max === \"string\") {\n serializedValidation.max = dp.validation.max;\n }\n result.validation = serializedValidation;\n }\n return result;\n }\n\n case \"geopoint\": {\n const gp = property as GeopointProperty;\n const result: SerializableGeopointProperty = {\n ...base,\n type: \"geopoint\"\n };\n if (gp.validation) result.validation = gp.validation;\n return result;\n }\n\n case \"reference\": {\n const rp = property as ReferenceProperty;\n const result: SerializableReferenceProperty = {\n ...base,\n type: \"reference\"\n };\n if (rp.isId !== undefined) result.isId = rp.isId;\n if (rp.path) result.path = rp.path;\n return result;\n }\n\n case \"relation\": {\n const rl = property as RelationProperty;\n const result: SerializableRelationProperty = {\n ...base,\n type: \"relation\"\n };\n if (rl.isId !== undefined) result.isId = rl.isId;\n // The link is one nested object now, so it serializes as one:\n // its `kind` says which fields are even meaningful.\n const link = rl.relation;\n if (link) {\n // Switched on `kind` and assigned without a cast: the\n // serialized union mirrors the authored one, so the compiler\n // checks that each branch writes the fields its kind owns and\n // no others. This used to be built as an untyped bag and cast\n // into place — which is how the target interface drifted a\n // whole refactor behind the code writing to it.\n result.relation = toSerializableRelation(link);\n }\n // overrides are dropped (may hold a non-serializable CollectionConfig)\n return result;\n }\n\n case \"array\": {\n const ap = property as ArrayProperty;\n const result: SerializableArrayProperty = {\n ...base,\n type: \"array\"\n };\n if (ap.columnType) result.columnType = ap.columnType;\n if (ap.validation) result.validation = ap.validation;\n\n // Recursively serialize the \"of\" property\n if (ap.of) {\n if (Array.isArray(ap.of)) {\n result.of = ap.of.map(toSerializableProperty);\n } else {\n result.of = toSerializableProperty(ap.of);\n }\n }\n\n // Recursively serialize oneOf properties\n if (ap.oneOf) {\n result.oneOf = {\n properties: toSerializableProperties(ap.oneOf.properties)\n };\n if (ap.oneOf.propertiesOrder) result.oneOf.propertiesOrder = ap.oneOf.propertiesOrder;\n if (ap.oneOf.typeField) result.oneOf.typeField = ap.oneOf.typeField;\n if (ap.oneOf.valueField) result.oneOf.valueField = ap.oneOf.valueField;\n }\n return result;\n }\n\n case \"map\": {\n const mp = property as MapProperty;\n const result: SerializableMapProperty = {\n ...base,\n type: \"map\"\n };\n if (mp.columnType) result.columnType = mp.columnType;\n if (mp.validation) result.validation = mp.validation;\n if (mp.propertiesOrder) result.propertiesOrder = mp.propertiesOrder;\n if (mp.keyValue) result.keyValue = mp.keyValue;\n\n // Recursively serialize nested properties\n if (mp.properties) {\n result.properties = toSerializableProperties(mp.properties);\n }\n return result;\n }\n\n case \"vector\": {\n const vp = property as VectorProperty;\n const result: SerializableVectorProperty = {\n ...base,\n type: \"vector\",\n dimensions: vp.dimensions\n };\n if (vp.validation) result.validation = vp.validation;\n return result;\n }\n\n case \"binary\": {\n const bp = property as BinaryProperty;\n const result: SerializableBinaryProperty = {\n ...base,\n type: \"binary\"\n };\n if (bp.validation) result.validation = bp.validation;\n return result;\n }\n\n default:\n // Exhaustive check: if new types are added, this will produce a compile error\n return base as SerializableProperty;\n }\n}\n\n/**\n * Convert a `Properties` record to its serializable form.\n */\nexport function toSerializableProperties(properties: Properties): SerializableProperties {\n const result: SerializableProperties = {};\n for (const [key, property] of Object.entries(properties)) {\n result[key] = toSerializableProperty(property);\n }\n return result;\n}\n\n// ═══════════════════════════════════════════════════════════════════════\n// COLLECTION CONVERSION: Original → Serializable\n// ═══════════════════════════════════════════════════════════════════════\n\n/**\n * Convert an `AdminCollection` to its JSON-serializable form.\n *\n * Strips all non-serializable fields (functions, React nodes, class instances)\n * while preserving the structural schema that the collection editor works with.\n *\n * The result is safe for `JSON.stringify()` and database storage.\n */\nexport function toSerializableCollectionConfig(collection: AdminCollection): SerializableCollectionConfig {\n const result: SerializableCollectionConfig = {\n slug: collection.slug,\n name: collection.name,\n properties: toSerializableProperties(collection.properties)\n };\n\n // String fields\n if (collection.singularName) result.singularName = collection.singularName;\n if (collection.description) result.description = collection.description;\n if (collection.group) result.group = collection.group;\n if (collection.engine) result.engine = collection.engine;\n if (collection.dataSource) result.dataSource = collection.dataSource;\n if (collection.databaseId) result.databaseId = collection.databaseId;\n if (collection.ownerId) result.ownerId = collection.ownerId;\n if (collection.metadata) result.metadata = collection.metadata;\n if (isRelationalCollectionConfig(collection) && collection.table) result.table = collection.table;\n if (isRelationalCollectionConfig(collection) && collection.relations?.length) {\n result.relations = collection.relations.map(toSerializableRelation);\n }\n if (\"schema\" in collection && collection.schema) result.schema = collection.schema as string;\n if (collection.orderProperty) result.orderProperty = collection.orderProperty as string;\n\n // Icon: only keep string variant\n if (typeof collection.icon === \"string\") result.icon = collection.icon;\n\n // Array fields\n if (collection.propertiesOrder) result.propertiesOrder = collection.propertiesOrder as string[];\n if (collection.previewProperties) result.previewProperties = collection.previewProperties;\n if (collection.listProperties) result.listProperties = collection.listProperties;\n if (collection.enabledViews) result.enabledViews = collection.enabledViews;\n // Inline views are dropped rather than mangled: their `Builder` cannot be\n // serialized, and writing back a half of one would delete it from the\n // running config. Keys survive, so a collection edited in the panel keeps\n // whichever registered views it named.\n if (collection.customViews) {\n const keys = collection.customViews.filter((v): v is string => typeof v === \"string\");\n if (keys.length > 0) result.customViews = keys;\n }\n if (collection.disableDefaultActions) result.disableDefaultActions = collection.disableDefaultActions;\n if (collection.securityRules) result.securityRules = collection.securityRules;\n if (isRelationalCollectionConfig(collection) && collection.disableDefaultPolicies !== undefined) {\n result.disableDefaultPolicies = collection.disableDefaultPolicies;\n }\n if (collection.strictWrites !== undefined) result.strictWrites = collection.strictWrites;\n\n // Enum-like fields\n if (collection.openEntityMode) result.openEntityMode = collection.openEntityMode;\n if (collection.defaultEntityAction) result.defaultEntityAction = collection.defaultEntityAction;\n if (collection.defaultViewMode) result.defaultViewMode = collection.defaultViewMode;\n if (collection.defaultSize) result.defaultSize = collection.defaultSize;\n if (collection.localChangesBackup !== undefined) result.localChangesBackup = collection.localChangesBackup;\n\n // Kanban\n if (collection.kanban) result.kanban = collection.kanban as SerializableCollectionConfig[\"kanban\"];\n\n // Filters and sorting\n if (collection.fixedFilter) result.fixedFilter = collection.fixedFilter as SerializableCollectionConfig[\"fixedFilter\"];\n if (collection.defaultFilter) result.defaultFilter = collection.defaultFilter as SerializableCollectionConfig[\"defaultFilter\"];\n if (collection.filterPresets) result.filterPresets = collection.filterPresets as SerializableCollectionConfig[\"filterPresets\"];\n if (collection.sort) result.sort = collection.sort as SerializableCollectionConfig[\"sort\"];\n\n // Numeric / boolean flags\n if (collection.pagination !== undefined) result.pagination = collection.pagination;\n if (collection.selectionEnabled !== undefined) result.selectionEnabled = collection.selectionEnabled;\n if (collection.inlineEditing !== undefined) result.inlineEditing = collection.inlineEditing;\n if (collection.hideFromNavigation !== undefined) result.hideFromNavigation = collection.hideFromNavigation;\n if (collection.hideIdFromForm !== undefined) result.hideIdFromForm = collection.hideIdFromForm;\n if (collection.hideIdFromCollection !== undefined) result.hideIdFromCollection = collection.hideIdFromCollection;\n if (collection.formAutoSave !== undefined) result.formAutoSave = collection.formAutoSave;\n if (collection.alwaysApplyDefaultValues !== undefined) result.alwaysApplyDefaultValues = collection.alwaysApplyDefaultValues;\n if (collection.includeJsonView !== undefined) result.includeJsonView = collection.includeJsonView;\n if (collection.history !== undefined) result.history = collection.history;\n if (collection.sideDialogWidth !== undefined) result.sideDialogWidth = collection.sideDialogWidth;\n\n // Exportable: only keep boolean variant\n if (typeof collection.exportable === \"boolean\") result.exportable = collection.exportable;\n\n // Auth: only keep boolean variant\n if (typeof collection.auth === \"boolean\") result.auth = collection.auth;\n\n // defaultSelectedView: only keep string variant\n if (typeof collection.defaultSelectedView === \"string\") result.defaultSelectedView = collection.defaultSelectedView;\n\n return result;\n}\n\n// ═══════════════════════════════════════════════════════════════════════\n// PROPERTY CONVERSION: Serializable → Original\n// ═══════════════════════════════════════════════════════════════════════\n\n/**\n * Convert a serializable property back to the original `Property` type.\n *\n * This is a mostly pass-through operation since serializable properties\n * are a subset of the original types. The main conversions are:\n * - `validation.matches` (string) stays as string (compatible with Property)\n * - `validation.min/max` on dates: ISO strings → Date objects\n */\nexport function fromSerializableProperty(\n serialized: SerializableProperty,\n lookup?: CollectionLookup\n): Property {\n switch (serialized.type) {\n case \"date\": {\n const sp = serialized as SerializableDateProperty;\n const { validation: dateValidation, ...dateRest } = sp;\n const result: Record<string, unknown> = { ...dateRest,\ntype: \"date\" };\n // Convert ISO string dates back to Date objects\n if (dateValidation) {\n const convertedValidation: Record<string, unknown> = { ...dateValidation };\n if (typeof dateValidation.min === \"string\") {\n convertedValidation.min = new Date(dateValidation.min);\n }\n if (typeof dateValidation.max === \"string\") {\n convertedValidation.max = new Date(dateValidation.max);\n }\n result.validation = convertedValidation;\n }\n // `result` is assembled as an open record because `validation` is\n // rebuilt key by key — the ISO strings this deserializes come back\n // as `Date`s, and a partially-converted validation object is not a\n // `DateValidation` at any point in the loop above. The claim is\n // that it is one by the time we get here.\n return result as unknown as DateProperty;\n }\n\n case \"array\": {\n const sp = serialized as SerializableArrayProperty;\n const result = { ...sp } as ArrayProperty;\n // Recursively convert \"of\" property\n if (sp.of) {\n if (Array.isArray(sp.of)) {\n result.of = sp.of.map(prop => fromSerializableProperty(prop, lookup));\n } else {\n result.of = fromSerializableProperty(sp.of, lookup);\n }\n }\n // Recursively convert oneOf properties\n if (sp.oneOf) {\n result.oneOf = {\n ...sp.oneOf,\n properties: fromSerializableProperties(sp.oneOf.properties, lookup)\n };\n }\n return result;\n }\n\n case \"map\": {\n const sp = serialized as SerializableMapProperty;\n const result = { ...sp } as MapProperty;\n // Recursively convert nested properties\n if (sp.properties) {\n result.properties = fromSerializableProperties(sp.properties, lookup);\n }\n return result;\n }\n\n case \"string\": {\n const sp = serialized as SerializableStringProperty;\n const result = { ...sp } as StringProperty;\n return result;\n }\n\n case \"relation\": {\n // The one property whose serialized form is *not* already a valid\n // Property. `target` survives the round trip as a collection slug,\n // because a `() => CollectionConfig` thunk cannot be written to\n // JSON — so it has to be made callable again on the way back.\n //\n // Falling through to the pass-through below returned a relation\n // whose `target` was a string, and every consumer calls `target()`.\n // Nothing caught it: the cast to `Property` erased the difference.\n const sp = serialized as SerializableRelationProperty;\n const { relation, ...rest } = sp;\n const result = { ...rest,\ntype: \"relation\" } as RelationProperty;\n if (relation) {\n result.relation = fromSerializableRelation(\n relation,\n sp.name ?? \"\",\n lookup\n ) as RelationProperty[\"relation\"];\n }\n return result as Property;\n }\n\n default:\n // For all other types, the serializable form is already a valid Property\n return serialized as Property;\n }\n}\n\n/**\n * Convert a `SerializableProperties` record back to `Properties`.\n */\nexport function fromSerializableProperties(\n serialized: SerializableProperties,\n lookup?: CollectionLookup\n): Properties {\n const result: Properties = {};\n for (const [key, property] of Object.entries(serialized)) {\n result[key] = fromSerializableProperty(property, lookup);\n }\n return result;\n}\n\n// ═══════════════════════════════════════════════════════════════════════\n// COLLECTION CONVERSION: Serializable → Original\n// ═══════════════════════════════════════════════════════════════════════\n\n/**\n * Convert a `SerializableCollectionConfig` back to an `AdminCollection`.\n *\n * The result will NOT contain any of the non-serializable fields\n * (callbacks, entityActions, etc.) — those must be re-attached by the\n * consumer if needed.\n */\nexport function fromSerializableCollectionConfig(\n serialized: SerializableCollectionConfig,\n lookup?: CollectionLookup\n): AdminCollection {\n const { properties, relations, ...rest } = serialized as SerializableCollectionConfig & {\n relations?: SerializableRelation[]\n };\n\n return {\n ...rest,\n ...(relations\n ? {\n relations: relations.map((relation, index) =>\n fromSerializableRelation(relation, `relations[${index}]`, lookup))\n }\n : {}),\n properties: fromSerializableProperties(properties, lookup)\n } as AdminCollection;\n}\n\n/**\n * Deserialize a whole set of collections, resolving relation targets against\n * each other.\n *\n * This is the entry point to prefer. A relation's `target` is a slug on the\n * wire, and a slug only means something relative to the other collections — so\n * deserializing one at a time cannot rebuild a working thunk, and produces\n * relations that throw the moment anything resolves them.\n *\n * The lookup is consulted lazily, inside the thunk, so the collections may\n * reference each other in any order, including circularly.\n */\nexport function fromSerializableCollectionConfigs(\n serialized: SerializableCollectionConfig[]\n): AdminCollection[] {\n const bySlug = new Map<string, AdminCollection>();\n const lookup: CollectionLookup = slug => bySlug.get(slug);\n\n const collections = serialized.map(c => fromSerializableCollectionConfig(c, lookup));\n for (const collection of collections) {\n if (collection.slug) bySlug.set(collection.slug, collection);\n }\n return collections;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAS,yBACL,UACA,OACA,QACqC;CACrC,MAAM,OAAO,SAAS;CACtB,OAAO;EACH,GAAG;EACH,cAAc;GACV,MAAM,QAAQ,OAAO,SAAS,IAAI,IAAI,KAAA;GACtC,IAAI,CAAC,OACD,MAAM,IAAI,MACN,aAAa,SAAS,gBAAgB,MAAM,wBAAwB,QAAQ,SAAS,yKAGzF;GAEJ,OAAO;EACX;CACJ;AACJ;;;;;;;;;;;;;;AAmBA,IAAM,8BAA8B;CAAC;CAAS;CAAW;AAAQ;AAEjE,SAAS,2BAA2B,IAAgF;CAChH,IAAI,CAAC,IAAI,OAAO,KAAA;CAChB,MAAM,SAAkC,CAAC;CACzC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,EAA6B,GACnE,IAAI,CAAC,4BAA4B,SAAS,GAAG,KAAK,UAAU,KAAA,GACxD,OAAO,OAAO;CAGtB,OAAO,OAAO,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YACE,EACE,WAAW,UAAU,KAAK,UAAU,UAChC,yBAAyB,UAAU,aAAa,MAAM,IAAI,MAAM,CAAC,EACzE,IACE,CAAC;EACP,YAAY,2BAA2B,YAAY,MAAM;CAC7D;AACJ;;;;;;;;;;;;;AAcA,SAAgB,kCACZ,YACiB;CACjB,MAAM,yBAAS,IAAI,IAA6B;CAChD,MAAM,UAA2B,SAAQ,OAAO,IAAI,IAAI;CAExD,MAAM,cAAc,WAAW,KAAI,MAAK,iCAAiC,GAAG,MAAM,CAAC;CACnF,KAAK,MAAM,cAAc,aACrB,IAAI,WAAW,MAAM,OAAO,IAAI,WAAW,MAAM,UAAU;CAE/D,OAAO;AACX"}
|
|
1
|
+
{"version":3,"file":"serializable_utils.js","names":[],"sources":["../../src/collection_editor/serializable_utils.ts"],"sourcesContent":["/**\n * Conversion utilities between the full Rebase types and their\n * JSON-serializable counterparts.\n *\n * - `toSerializableCollectionConfig` / `toSerializableProperty` — strip non-serializable fields\n * - `fromSerializableCollectionConfig` / `fromSerializableProperty` — reconstruct original types\n *\n * @module\n */\n\nimport { resourceKeyOf } from \"@rebasepro/types\";\nimport { serializeRegExp } from \"@rebasepro/utils\";\nimport { isRelationalCollectionConfig, type Relation, type ArrayProperty, type BinaryProperty, type BooleanProperty, type DateProperty, type GeopointProperty, type MapProperty, type NumberProperty, type Properties, type Property, type ReferenceProperty, type RelationProperty, type StorageConfig, type StringProperty, type VectorProperty } from \"@rebasepro/cms-types\";\nimport type { AdminPropertyOptions } from \"@rebasepro/cms-types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nimport type {\n SerializableArrayProperty,\n SerializableBaseProperty,\n SerializableAdminBaseOptions,\n SerializableBinaryProperty,\n SerializableBooleanProperty,\n SerializableCollectionConfig,\n SerializableDateProperty,\n SerializableDateValidation,\n SerializableGeopointProperty,\n SerializableMapProperty,\n SerializableNumberProperty,\n SerializableProperties,\n SerializableProperty,\n SerializableReferenceProperty,\n SerializableRelation,\n SerializableRelationProperty,\n SerializableStorageConfig,\n SerializableStringProperty,\n SerializableStringValidation,\n SerializableVectorProperty\n} from \"./serializable_types\";\n\n/**\n * Resolves a collection slug to the collection it names.\n *\n * Needed on the way back from JSON: a relation's `target` is a thunk, which\n * does not serialize, so it travels as a slug and has to be made callable\n * again against the other collections in the same set.\n */\nexport type CollectionLookup = (slug: string) => AdminCollection | undefined;\n\n/**\n * Rebuild a serialized relation's `target` slug into the thunk consumers call.\n *\n * Shared by the relation *property* and the collection-level `relations` array.\n * They are the same shape on the wire and they need the same treatment coming\n * back, but only the property path had it — so a collection imported from an\n * existing table came off disk with `relations[n].target` still a string, which\n * typechecks (the serializable shape erases the difference) and throws \"target\n * is not a function\" at the first consumer.\n *\n * The lookup is consulted lazily, inside the thunk, so collections may\n * reference each other in any order, including circularly.\n */\nfunction fromSerializableRelation<R extends { target?: string; relationName?: string }>(\n relation: R,\n label: string,\n lookup?: CollectionLookup\n): R & { target: () => AdminCollection } {\n const slug = relation.target;\n return {\n ...relation,\n target: () => {\n const found = slug ? lookup?.(slug) : undefined;\n if (!found) {\n throw new Error(\n `Relation \"${relation.relationName ?? label}\" targets collection \"${slug ?? \"(none)\"}\", ` +\n \"which is not among the collections it was deserialized with. Pass the whole set to \" +\n \"`fromSerializableCollectionConfigs` so slugs can be resolved against each other.\"\n );\n }\n return found;\n }\n };\n}\n\n// ═══════════════════════════════════════════════════════════════════════\n// PROPERTY CONVERSION: Original → Serializable\n// ═══════════════════════════════════════════════════════════════════════\n\n/**\n * Strip non-serializable fields from a `AdminPropertyOptions`.\n * Removes `Field` and `Preview` (ComponentRef).\n */\n/**\n * Every `ComponentRef` on a property's admin block. These are components, not\n * data, and none of them survives `JSON.stringify` — a function-valued key is\n * dropped from the output object with no error, so a component written here\n * would leave a key that reads back as missing rather than as itself.\n *\n * `Filter` was absent from this list while `Field` and `Preview` were named\n * twice, once destructured and once compared by string.\n */\nconst NON_SERIALIZABLE_ADMIN_KEYS = [\"Field\", \"Preview\", \"Filter\"];\n\nfunction toSerializableAdminOptions(ui: AdminPropertyOptions | undefined): SerializableAdminBaseOptions | undefined {\n if (!ui) return undefined;\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(ui as Record<string, unknown>)) {\n if (!NON_SERIALIZABLE_ADMIN_KEYS.includes(key) && value !== undefined) {\n result[key] = value;\n }\n }\n return Object.keys(result).length > 0 ? result as SerializableAdminBaseOptions : undefined;\n}\n\n/**\n * Convert a `StorageConfig` to its serializable form.\n * Drops function variants of `storagePath`, `fileName`, and all function fields.\n */\nfunction toSerializableStorageConfig(storage: StorageConfig | undefined): SerializableStorageConfig | undefined {\n if (!storage) return undefined;\n\n // storagePath must be a string for serialization\n const storagePath = typeof storage.storagePath === \"string\" ? storage.storagePath : undefined;\n if (!storagePath) return undefined;\n\n const result: SerializableStorageConfig = { storagePath };\n\n if (storage.acceptedFiles) result.acceptedFiles = storage.acceptedFiles;\n if (storage.imageResize) result.imageResize = storage.imageResize;\n if (storage.metadata) result.metadata = storage.metadata;\n if (typeof storage.fileName === \"string\") result.fileName = storage.fileName;\n if (storage.includeBucketUrl !== undefined) result.includeBucketUrl = storage.includeBucketUrl;\n if (storage.storeUrl !== undefined) result.storeUrl = storage.storeUrl;\n if (storage.maxSize !== undefined) result.maxSize = storage.maxSize;\n if (storage.storageSource !== undefined) result.storageSource = resourceKeyOf(storage.storageSource);\n // processFile, postProcess, previewUrl are intentionally dropped (functions)\n\n return result;\n}\n\n/**\n * Convert a RegExp or string `matches` validation to a plain string: the\n * `/source/flags` form `hydrateRegExp` reads back, so a flag such as `i`\n * survives the round trip.\n */\nfunction serializeMatches(matches: string | RegExp | undefined): string | undefined {\n if (matches === undefined) return undefined;\n if (typeof matches === \"string\") return matches;\n return serializeRegExp(matches);\n}\n\n/**\n * Resolve a relation target to a string slug.\n * Functions are called to extract the target; AdminCollection objects\n * use their slug.\n */\nfunction resolveRelationTarget(target: RelationProperty[\"relation\"] extends infer R ? R extends { target: infer T } ? T : never : never): string | undefined {\n if (!target) return undefined;\n if (typeof target === \"string\") return target;\n if (typeof target === \"function\") {\n try {\n const resolved = target();\n if (typeof resolved === \"string\") return resolved;\n if (resolved && typeof resolved === \"object\" && \"slug\" in resolved) {\n return (resolved as AdminCollection).slug;\n }\n } catch {\n // If the lazy resolver throws (e.g., circular dependency not yet ready), return undefined\n }\n }\n return undefined;\n}\n\n/**\n * A `Relation` as JSON: `target` resolved from its thunk down to a slug.\n *\n * Switched on `kind` and assigned without a cast, so the compiler checks that\n * each branch writes the fields its kind owns and no others. This used to be\n * built as an untyped bag and cast into place — which is how the target\n * interface drifted a whole refactor behind the code writing to it.\n *\n * Shared by the relation *property* and the collection-level `relations` array,\n * which had no serializer at all: `buildCollectionFromTableMetadata` fills that\n * array from the table's foreign keys and junctions on import, and every one of\n * them was dropped on save.\n */\nfunction toSerializableRelation(link: Relation): SerializableRelation {\n const target = resolveRelationTarget(link.target);\n const common = {\n ...(target ? { target } : {}),\n ...(link.relationName ? { relationName: link.relationName } : {}),\n ...(link.onUpdate ? { onUpdate: link.onUpdate } : {}),\n ...(link.onDelete ? { onDelete: link.onDelete } : {})\n };\n switch (link.kind) {\n case \"belongsTo\":\n return {\n kind: \"belongsTo\",\n ...common,\n ...(link.localKey ? { localKey: link.localKey } : {}),\n // Only the opt-out: `true` is the default, and writing it into\n // every saved relation would be noise in the author's file.\n ...(link.index === false ? { index: false } : {})\n };\n case \"hasOne\":\n case \"hasMany\":\n return {\n kind: link.kind,\n ...common,\n ...(link.foreignKeyOnTarget ? { foreignKeyOnTarget: link.foreignKeyOnTarget } : {}),\n ...(link.sourceKey ? { sourceKey: link.sourceKey } : {})\n };\n case \"manyToMany\":\n return { kind: \"manyToMany\", ...common, ...(link.through ? { through: link.through } : {}) };\n case \"via\":\n return { kind: \"via\", ...common, cardinality: link.cardinality, joinPath: link.joinPath };\n default: {\n const exhaustive: never = link;\n throw new Error(`Unhandled relation kind: ${JSON.stringify(exhaustive)}`);\n }\n }\n}\n\n/**\n * Strip non-serializable base property fields.\n * Returns a clean object with only the common serializable fields from BaseProperty.\n * Validation is intentionally excluded — each property type handles its own.\n */\nfunction toSerializableBaseFields(property: Property): Omit<SerializableBaseProperty, \"validation\"> {\n const result: Partial<Omit<SerializableBaseProperty, \"validation\">> = {\n name: property.name\n };\n\n if (property.description) result.description = property.description;\n if (property.propertyConfig) result.propertyConfig = property.propertyConfig;\n if (property.columnName) result.columnName = property.columnName;\n if (property.excludeFromApi !== undefined) result.excludeFromApi = property.excludeFromApi;\n if (property.access !== undefined) result.access = property.access;\n if (property.defaultValue !== undefined) result.defaultValue = property.defaultValue;\n if (property.databaseDefault !== undefined) result.databaseDefault = property.databaseDefault;\n if (property.conditions) result.conditions = property.conditions;\n if (property.metadata) result.metadata = property.metadata;\n // dynamicProps and callbacks are intentionally dropped (functions)\n\n const ui = toSerializableAdminOptions(property.admin);\n if (ui) result.admin = ui;\n\n return result as Omit<SerializableBaseProperty, \"validation\">;\n}\n\n/**\n * Convert a single `Property` to its JSON-serializable form.\n * Strips functions, converts RegExp to string, Date to ISO string.\n */\nexport function toSerializableProperty(property: Property): SerializableProperty {\n const base = toSerializableBaseFields(property);\n\n switch (property.type) {\n case \"string\": {\n const sp = property as StringProperty;\n const result: SerializableStringProperty = {\n ...base,\n type: \"string\"\n };\n if (sp.columnType) result.columnType = sp.columnType;\n if (sp.isId !== undefined) result.isId = sp.isId;\n if (sp.enum) result.enum = sp.enum;\n if (sp.userSelect) result.userSelect = sp.userSelect;\n if (sp.email) result.email = sp.email;\n if (sp.url) result.url = sp.url;\n if (sp.autoValue) result.autoValue = sp.autoValue;\n\n // Convert validation.matches from RegExp to string\n if (sp.validation) {\n const { matches, ...restValidation } = sp.validation;\n const serializedValidation: SerializableStringValidation = { ...restValidation };\n const matchStr = serializeMatches(matches);\n if (matchStr !== undefined) serializedValidation.matches = matchStr;\n result.validation = serializedValidation;\n }\n\n // Storage: convert to serializable form\n const storage = toSerializableStorageConfig(sp.storage);\n if (storage) result.storage = storage;\n\n return result;\n }\n\n case \"number\": {\n const np = property as NumberProperty;\n const result: SerializableNumberProperty = {\n ...base,\n type: \"number\"\n };\n if (np.columnType) result.columnType = np.columnType;\n if (np.validation) result.validation = np.validation;\n if (np.isId !== undefined) result.isId = np.isId;\n if (np.enum) result.enum = np.enum;\n if (np.precision !== undefined) result.precision = np.precision;\n if (np.scale !== undefined) result.scale = np.scale;\n return result;\n }\n\n case \"boolean\": {\n const bp = property as BooleanProperty;\n const result: SerializableBooleanProperty = {\n ...base,\n type: \"boolean\"\n };\n if (bp.validation) result.validation = bp.validation;\n return result;\n }\n\n case \"date\": {\n const dp = property as DateProperty;\n const result: SerializableDateProperty = {\n ...base,\n type: \"date\"\n };\n if (dp.columnType) result.columnType = dp.columnType;\n if (dp.mode) result.mode = dp.mode;\n if (dp.timezone) result.timezone = dp.timezone;\n if (dp.autoValue) result.autoValue = dp.autoValue;\n\n // Convert Date validation min/max to ISO strings\n if (dp.validation) {\n const serializedValidation: SerializableDateValidation = {};\n if (dp.validation.required !== undefined) serializedValidation.required = dp.validation.required;\n if (dp.validation.requiredMessage) serializedValidation.requiredMessage = dp.validation.requiredMessage;\n if (dp.validation.unique) serializedValidation.unique = dp.validation.unique;\n if (dp.validation.uniqueInArray) serializedValidation.uniqueInArray = dp.validation.uniqueInArray;\n if (dp.validation.min instanceof Date) {\n serializedValidation.min = dp.validation.min.toISOString();\n } else if (typeof dp.validation.min === \"string\") {\n serializedValidation.min = dp.validation.min;\n }\n if (dp.validation.max instanceof Date) {\n serializedValidation.max = dp.validation.max.toISOString();\n } else if (typeof dp.validation.max === \"string\") {\n serializedValidation.max = dp.validation.max;\n }\n result.validation = serializedValidation;\n }\n return result;\n }\n\n case \"geopoint\": {\n const gp = property as GeopointProperty;\n const result: SerializableGeopointProperty = {\n ...base,\n type: \"geopoint\"\n };\n if (gp.validation) result.validation = gp.validation;\n return result;\n }\n\n case \"reference\": {\n const rp = property as ReferenceProperty;\n const result: SerializableReferenceProperty = {\n ...base,\n type: \"reference\"\n };\n if (rp.isId !== undefined) result.isId = rp.isId;\n if (rp.path) result.path = rp.path;\n return result;\n }\n\n case \"relation\": {\n const rl = property as RelationProperty;\n const result: SerializableRelationProperty = {\n ...base,\n type: \"relation\"\n };\n if (rl.isId !== undefined) result.isId = rl.isId;\n // The link is one nested object now, so it serializes as one:\n // its `kind` says which fields are even meaningful.\n const link = rl.relation;\n if (link) {\n // Switched on `kind` and assigned without a cast: the\n // serialized union mirrors the authored one, so the compiler\n // checks that each branch writes the fields its kind owns and\n // no others. This used to be built as an untyped bag and cast\n // into place — which is how the target interface drifted a\n // whole refactor behind the code writing to it.\n result.relation = toSerializableRelation(link);\n }\n // overrides are dropped (may hold a non-serializable CollectionConfig)\n return result;\n }\n\n case \"array\": {\n const ap = property as ArrayProperty;\n const result: SerializableArrayProperty = {\n ...base,\n type: \"array\"\n };\n if (ap.columnType) result.columnType = ap.columnType;\n if (ap.validation) result.validation = ap.validation;\n\n // Recursively serialize the \"of\" property\n if (ap.of) {\n if (Array.isArray(ap.of)) {\n result.of = ap.of.map(toSerializableProperty);\n } else {\n result.of = toSerializableProperty(ap.of);\n }\n }\n\n // Recursively serialize oneOf properties\n if (ap.oneOf) {\n result.oneOf = {\n properties: toSerializableProperties(ap.oneOf.properties)\n };\n if (ap.oneOf.propertiesOrder) result.oneOf.propertiesOrder = ap.oneOf.propertiesOrder;\n if (ap.oneOf.typeField) result.oneOf.typeField = ap.oneOf.typeField;\n if (ap.oneOf.valueField) result.oneOf.valueField = ap.oneOf.valueField;\n }\n return result;\n }\n\n case \"map\": {\n const mp = property as MapProperty;\n const result: SerializableMapProperty = {\n ...base,\n type: \"map\"\n };\n if (mp.columnType) result.columnType = mp.columnType;\n if (mp.validation) result.validation = mp.validation;\n if (mp.propertiesOrder) result.propertiesOrder = mp.propertiesOrder;\n if (mp.keyValue) result.keyValue = mp.keyValue;\n\n // Recursively serialize nested properties\n if (mp.properties) {\n result.properties = toSerializableProperties(mp.properties);\n }\n return result;\n }\n\n case \"vector\": {\n const vp = property as VectorProperty;\n const result: SerializableVectorProperty = {\n ...base,\n type: \"vector\",\n dimensions: vp.dimensions\n };\n if (vp.validation) result.validation = vp.validation;\n return result;\n }\n\n case \"binary\": {\n const bp = property as BinaryProperty;\n const result: SerializableBinaryProperty = {\n ...base,\n type: \"binary\"\n };\n if (bp.validation) result.validation = bp.validation;\n return result;\n }\n\n default:\n // Exhaustive check: if new types are added, this will produce a compile error\n return base as SerializableProperty;\n }\n}\n\n/**\n * Convert a `Properties` record to its serializable form.\n */\nexport function toSerializableProperties(properties: Properties): SerializableProperties {\n const result: SerializableProperties = {};\n for (const [key, property] of Object.entries(properties)) {\n result[key] = toSerializableProperty(property);\n }\n return result;\n}\n\n// ═══════════════════════════════════════════════════════════════════════\n// COLLECTION CONVERSION: Original → Serializable\n// ═══════════════════════════════════════════════════════════════════════\n\n/**\n * Convert an `AdminCollection` to its JSON-serializable form.\n *\n * Strips all non-serializable fields (functions, React nodes, class instances)\n * while preserving the structural schema that the collection editor works with.\n *\n * The result is safe for `JSON.stringify()` and database storage.\n */\nexport function toSerializableCollectionConfig(collection: AdminCollection): SerializableCollectionConfig {\n const result: SerializableCollectionConfig = {\n slug: collection.slug,\n name: collection.name,\n properties: toSerializableProperties(collection.properties)\n };\n\n // String fields\n if (collection.singularName) result.singularName = collection.singularName;\n if (collection.description) result.description = collection.description;\n if (collection.group) result.group = collection.group;\n if (collection.engine) result.engine = collection.engine;\n if (collection.dataSource) result.dataSource = collection.dataSource;\n if (collection.databaseId) result.databaseId = collection.databaseId;\n if (collection.ownerId) result.ownerId = collection.ownerId;\n if (collection.metadata) result.metadata = collection.metadata;\n if (isRelationalCollectionConfig(collection) && collection.table) result.table = collection.table;\n if (isRelationalCollectionConfig(collection) && collection.relations?.length) {\n result.relations = collection.relations.map(toSerializableRelation);\n }\n if (\"schema\" in collection && collection.schema) result.schema = collection.schema as string;\n if (collection.orderProperty) result.orderProperty = collection.orderProperty as string;\n\n // Icon: only keep string variant\n if (typeof collection.icon === \"string\") result.icon = collection.icon;\n\n // Array fields\n if (collection.propertiesOrder) result.propertiesOrder = collection.propertiesOrder as string[];\n if (collection.previewProperties) result.previewProperties = collection.previewProperties;\n if (collection.listProperties) result.listProperties = collection.listProperties;\n if (collection.enabledViews) result.enabledViews = collection.enabledViews;\n // Inline views are dropped rather than mangled: their `Builder` cannot be\n // serialized, and writing back a half of one would delete it from the\n // running config. Keys survive, so a collection edited in the panel keeps\n // whichever registered views it named.\n if (collection.customViews) {\n const keys = collection.customViews.filter((v): v is string => typeof v === \"string\");\n if (keys.length > 0) result.customViews = keys;\n }\n if (collection.disableDefaultActions) result.disableDefaultActions = collection.disableDefaultActions;\n if (collection.securityRules) result.securityRules = collection.securityRules;\n if (isRelationalCollectionConfig(collection) && collection.disableDefaultPolicies !== undefined) {\n result.disableDefaultPolicies = collection.disableDefaultPolicies;\n }\n if (collection.strictWrites !== undefined) result.strictWrites = collection.strictWrites;\n\n // Enum-like fields\n if (collection.openEntityMode) result.openEntityMode = collection.openEntityMode;\n if (collection.defaultEntityAction) result.defaultEntityAction = collection.defaultEntityAction;\n if (collection.defaultViewMode) result.defaultViewMode = collection.defaultViewMode;\n if (collection.defaultSize) result.defaultSize = collection.defaultSize;\n if (collection.localChangesBackup !== undefined) result.localChangesBackup = collection.localChangesBackup;\n\n // Kanban\n if (collection.kanban) result.kanban = collection.kanban as SerializableCollectionConfig[\"kanban\"];\n\n // Filters and sorting\n if (collection.fixedFilter) result.fixedFilter = collection.fixedFilter as SerializableCollectionConfig[\"fixedFilter\"];\n if (collection.defaultFilter) result.defaultFilter = collection.defaultFilter as SerializableCollectionConfig[\"defaultFilter\"];\n if (collection.filterPresets) result.filterPresets = collection.filterPresets as SerializableCollectionConfig[\"filterPresets\"];\n if (collection.sort) result.sort = collection.sort as SerializableCollectionConfig[\"sort\"];\n\n // Numeric / boolean flags\n if (collection.pagination !== undefined) result.pagination = collection.pagination;\n if (collection.selectionEnabled !== undefined) result.selectionEnabled = collection.selectionEnabled;\n if (collection.inlineEditing !== undefined) result.inlineEditing = collection.inlineEditing;\n if (collection.hideFromNavigation !== undefined) result.hideFromNavigation = collection.hideFromNavigation;\n if (collection.hideIdFromForm !== undefined) result.hideIdFromForm = collection.hideIdFromForm;\n if (collection.hideIdFromCollection !== undefined) result.hideIdFromCollection = collection.hideIdFromCollection;\n if (collection.formAutoSave !== undefined) result.formAutoSave = collection.formAutoSave;\n if (collection.alwaysApplyDefaultValues !== undefined) result.alwaysApplyDefaultValues = collection.alwaysApplyDefaultValues;\n if (collection.includeJsonView !== undefined) result.includeJsonView = collection.includeJsonView;\n if (collection.history !== undefined) result.history = collection.history;\n if (collection.sideDialogWidth !== undefined) result.sideDialogWidth = collection.sideDialogWidth;\n\n // Exportable: only keep boolean variant\n if (typeof collection.exportable === \"boolean\") result.exportable = collection.exportable;\n\n // Auth: only keep boolean variant\n if (typeof collection.auth === \"boolean\") result.auth = collection.auth;\n\n // defaultSelectedView: only keep string variant\n if (typeof collection.defaultSelectedView === \"string\") result.defaultSelectedView = collection.defaultSelectedView;\n\n return result;\n}\n\n// ═══════════════════════════════════════════════════════════════════════\n// PROPERTY CONVERSION: Serializable → Original\n// ═══════════════════════════════════════════════════════════════════════\n\n/**\n * Convert a serializable property back to the original `Property` type.\n *\n * This is a mostly pass-through operation since serializable properties\n * are a subset of the original types. The main conversions are:\n * - `validation.matches` (string) stays as string (compatible with Property)\n * - `validation.min/max` on dates: ISO strings → Date objects\n */\nexport function fromSerializableProperty(\n serialized: SerializableProperty,\n lookup?: CollectionLookup\n): Property {\n switch (serialized.type) {\n case \"date\": {\n const sp = serialized as SerializableDateProperty;\n const { validation: dateValidation, ...dateRest } = sp;\n const result: Record<string, unknown> = { ...dateRest,\ntype: \"date\" };\n // Convert ISO string dates back to Date objects\n if (dateValidation) {\n const convertedValidation: Record<string, unknown> = { ...dateValidation };\n if (typeof dateValidation.min === \"string\") {\n convertedValidation.min = new Date(dateValidation.min);\n }\n if (typeof dateValidation.max === \"string\") {\n convertedValidation.max = new Date(dateValidation.max);\n }\n result.validation = convertedValidation;\n }\n // `result` is assembled as an open record because `validation` is\n // rebuilt key by key — the ISO strings this deserializes come back\n // as `Date`s, and a partially-converted validation object is not a\n // `DateValidation` at any point in the loop above. The claim is\n // that it is one by the time we get here.\n return result as unknown as DateProperty;\n }\n\n case \"array\": {\n const sp = serialized as SerializableArrayProperty;\n const result = { ...sp } as ArrayProperty;\n // Recursively convert \"of\" property\n if (sp.of) {\n if (Array.isArray(sp.of)) {\n result.of = sp.of.map(prop => fromSerializableProperty(prop, lookup));\n } else {\n result.of = fromSerializableProperty(sp.of, lookup);\n }\n }\n // Recursively convert oneOf properties\n if (sp.oneOf) {\n result.oneOf = {\n ...sp.oneOf,\n properties: fromSerializableProperties(sp.oneOf.properties, lookup)\n };\n }\n return result;\n }\n\n case \"map\": {\n const sp = serialized as SerializableMapProperty;\n const result = { ...sp } as MapProperty;\n // Recursively convert nested properties\n if (sp.properties) {\n result.properties = fromSerializableProperties(sp.properties, lookup);\n }\n return result;\n }\n\n case \"string\": {\n const sp = serialized as SerializableStringProperty;\n const result = { ...sp } as StringProperty;\n return result;\n }\n\n case \"relation\": {\n // The one property whose serialized form is *not* already a valid\n // Property. `target` survives the round trip as a collection slug,\n // because a `() => CollectionConfig` thunk cannot be written to\n // JSON — so it has to be made callable again on the way back.\n //\n // Falling through to the pass-through below returned a relation\n // whose `target` was a string, and every consumer calls `target()`.\n // Nothing caught it: the cast to `Property` erased the difference.\n const sp = serialized as SerializableRelationProperty;\n const { relation, ...rest } = sp;\n const result = { ...rest,\ntype: \"relation\" } as RelationProperty;\n if (relation) {\n result.relation = fromSerializableRelation(\n relation,\n sp.name ?? \"\",\n lookup\n ) as RelationProperty[\"relation\"];\n }\n return result as Property;\n }\n\n default:\n // For all other types, the serializable form is already a valid Property\n return serialized as Property;\n }\n}\n\n/**\n * Convert a `SerializableProperties` record back to `Properties`.\n */\nexport function fromSerializableProperties(\n serialized: SerializableProperties,\n lookup?: CollectionLookup\n): Properties {\n const result: Properties = {};\n for (const [key, property] of Object.entries(serialized)) {\n result[key] = fromSerializableProperty(property, lookup);\n }\n return result;\n}\n\n// ═══════════════════════════════════════════════════════════════════════\n// COLLECTION CONVERSION: Serializable → Original\n// ═══════════════════════════════════════════════════════════════════════\n\n/**\n * Convert a `SerializableCollectionConfig` back to an `AdminCollection`.\n *\n * The result will NOT contain any of the non-serializable fields\n * (callbacks, entityActions, etc.) — those must be re-attached by the\n * consumer if needed.\n */\nexport function fromSerializableCollectionConfig(\n serialized: SerializableCollectionConfig,\n lookup?: CollectionLookup\n): AdminCollection {\n const { properties, relations, ...rest } = serialized as SerializableCollectionConfig & {\n relations?: SerializableRelation[]\n };\n\n return {\n ...rest,\n ...(relations\n ? {\n relations: relations.map((relation, index) =>\n fromSerializableRelation(relation, `relations[${index}]`, lookup))\n }\n : {}),\n properties: fromSerializableProperties(properties, lookup)\n } as AdminCollection;\n}\n\n/**\n * Deserialize a whole set of collections, resolving relation targets against\n * each other.\n *\n * This is the entry point to prefer. A relation's `target` is a slug on the\n * wire, and a slug only means something relative to the other collections — so\n * deserializing one at a time cannot rebuild a working thunk, and produces\n * relations that throw the moment anything resolves them.\n *\n * The lookup is consulted lazily, inside the thunk, so the collections may\n * reference each other in any order, including circularly.\n */\nexport function fromSerializableCollectionConfigs(\n serialized: SerializableCollectionConfig[]\n): AdminCollection[] {\n const bySlug = new Map<string, AdminCollection>();\n const lookup: CollectionLookup = slug => bySlug.get(slug);\n\n const collections = serialized.map(c => fromSerializableCollectionConfig(c, lookup));\n for (const collection of collections) {\n if (collection.slug) bySlug.set(collection.slug, collection);\n }\n return collections;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAS,yBACL,UACA,OACA,QACqC;CACrC,MAAM,OAAO,SAAS;CACtB,OAAO;EACH,GAAG;EACH,cAAc;GACV,MAAM,QAAQ,OAAO,SAAS,IAAI,IAAI,KAAA;GAC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S;IAAE,GAAG;IAChC,MAAM;GAAW;GACL,IAAI,UACA,OAAO,WAAW,yBACd,UACA,GAAG,QAAQ,IACX,MACJ;GAEJ,OAAO;EACX;EAEA,SAEI,OAAO;CACf;AACJ;;;;AAKA,SAAgB,2BACZ,YACA,QACU;CACV,MAAM,SAAqB,CAAC;CAC5B,KAAK,MAAM,CAAC,KAAK,aAAa,OAAO,QAAQ,UAAU,GACnD,OAAO,OAAO,yBAAyB,UAAU,MAAM;CAE3D,OAAO;AACX;;;;;;;;AAaA,SAAgB,iCACZ,YACA,QACe;CACf,MAAM,EAAE,YAAY,WAAW,GAAG,SAAS;CAI3C,OAAO;EACH,GAAG;EACH,GAAI,YACE,EACE,WAAW,UAAU,KAAK,UAAU,UAChC,yBAAyB,UAAU,aAAa,MAAM,IAAI,MAAM,CAAC,EACzE,IACE,CAAC;EACP,YAAY,2BAA2B,YAAY,MAAM;CAC7D;AACJ;;;;;;;;;;;;;AAcA,SAAgB,kCACZ,YACiB;CACjB,MAAM,yBAAS,IAAI,IAA6B;CAChD,MAAM,UAA2B,SAAQ,OAAO,IAAI,IAAI;CAExD,MAAM,cAAc,WAAW,KAAI,MAAK,iCAAiC,GAAG,MAAM,CAAC;CACnF,KAAK,MAAM,cAAc,aACrB,IAAI,WAAW,MAAM,OAAO,IAAI,WAAW,MAAM,UAAU;CAE/D,OAAO;AACX"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One edit in the collection editor, split into what it changes about the
|
|
3
|
+
* table and what it changes about how the panel presents it.
|
|
4
|
+
*
|
|
5
|
+
* The editor edits one collection view model at a time — the panel's flat
|
|
6
|
+
* collection of `Property`s, projected from the table the server serves and
|
|
7
|
+
* customized. Saving it is two different writes (POSTGRES-FIRST.md §6.4):
|
|
8
|
+
*
|
|
9
|
+
* - **Schema** — column types, nullability, defaults, validation, enum values,
|
|
10
|
+
* storage rules, relations, row-level security, `history`, `description` —
|
|
11
|
+
* is a list of {@link TablePatch} operations for the server's schema editor,
|
|
12
|
+
* which edits `backend/schema/*.ts` and nothing else.
|
|
13
|
+
* - **Presentation** — labels, icon, group, view modes, column order, hidden
|
|
14
|
+
* columns, widths, enum labels and colours, kanban — is a
|
|
15
|
+
* {@link UiTablePreferences} delta, stored as a UI preference (a JSON UI
|
|
16
|
+
* config in development, `rebase.ui_preferences` when deployed).
|
|
17
|
+
*
|
|
18
|
+
* Nothing presentational is ever sent to the schema routes and nothing about
|
|
19
|
+
* the schema is ever stored as a preference: the presentation keys are exactly
|
|
20
|
+
* `UI_PREFERENCE_TABLE_KEYS` / `UI_PREFERENCE_FIELD_KEYS`, every one of them a
|
|
21
|
+
* `customizeTable` key (checked at compile time below).
|
|
22
|
+
*
|
|
23
|
+
* The module is pure: given the collection before and after, and the table as
|
|
24
|
+
* served, it returns the two writes, or throws {@link SplitEditError} for an
|
|
25
|
+
* edit that is not an edit (renaming a slug is a migration).
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
import type { TableDescriptor, TablePatch, UiFieldPreferences, UiTablePreferences } from "@rebasepro/types";
|
|
30
|
+
import type { AdminCollection, Property } from "@rebasepro/cms-types";
|
|
31
|
+
import { SplitEditError } from "./split_edit_error.js";
|
|
32
|
+
export { SplitEditError };
|
|
33
|
+
/**
|
|
34
|
+
* What one save of the collection editor writes.
|
|
35
|
+
*/
|
|
36
|
+
export interface SplitEdit {
|
|
37
|
+
/** The table slug the edit is about. */
|
|
38
|
+
table: string;
|
|
39
|
+
/** The schema editor's operations, in the order they apply. Empty when the schema is unchanged. */
|
|
40
|
+
schema: TablePatch[];
|
|
41
|
+
/** The presentation delta: only the keys the edit changed. Empty when nothing presentational changed. */
|
|
42
|
+
presentation: UiTablePreferences;
|
|
43
|
+
/**
|
|
44
|
+
* The table's rules come from `defaultRls` and the edit gives it rules of
|
|
45
|
+
* its own: saving detaches it from the inherited rules. The caller asks
|
|
46
|
+
* before sending a schema edit with this set.
|
|
47
|
+
*/
|
|
48
|
+
detachesInheritedRules?: true;
|
|
49
|
+
}
|
|
50
|
+
/** What {@link splitEdit} reads. */
|
|
51
|
+
export interface SplitEditInput {
|
|
52
|
+
/** The collection as the editor loaded it; absent for a new table. */
|
|
53
|
+
before?: AdminCollection;
|
|
54
|
+
/** The collection as the editor is saving it. */
|
|
55
|
+
after: AdminCollection;
|
|
56
|
+
/** The table as the server serves it: the facts the view model cannot carry are kept from it. */
|
|
57
|
+
table?: TableDescriptor;
|
|
58
|
+
/**
|
|
59
|
+
* `table` is not in `backend/schema` yet: it is the database's table as
|
|
60
|
+
* introspection described it ("Import an existing table"), and `before`
|
|
61
|
+
* its projection. The edit adopts it first (`adoptTable`), then makes the
|
|
62
|
+
* person's changes to it.
|
|
63
|
+
*/
|
|
64
|
+
adopt?: true;
|
|
65
|
+
}
|
|
66
|
+
/** Deep equality of the JSON-like values a collection holds. Functions compare by identity. */
|
|
67
|
+
export declare function sameValue(a: unknown, b: unknown): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* The table-level presentation a collection states, in the preference
|
|
70
|
+
* vocabulary (`propertiesOrder` → `fieldOrder`, `kanban.columnProperty` →
|
|
71
|
+
* `kanban.columnField`, …). Code-valued options (an action object, a
|
|
72
|
+
* resolver) are not data and are left out.
|
|
73
|
+
*/
|
|
74
|
+
export declare function tablePresentationOf(collection: AdminCollection): UiTablePreferences;
|
|
75
|
+
/**
|
|
76
|
+
* The presentation of one property, in the preference vocabulary. `admin.*`
|
|
77
|
+
* keys keep their names except `hideFromCollection` (`hidden`),
|
|
78
|
+
* `disabled.hidden` (`hiddenInForm`) and `previewProperties`
|
|
79
|
+
* (`previewFields`).
|
|
80
|
+
*/
|
|
81
|
+
export declare function fieldPresentationOf(property: Property): UiFieldPreferences;
|
|
82
|
+
/**
|
|
83
|
+
* Split one save of the collection editor into the schema edit and the
|
|
84
|
+
* presentation delta it makes.
|
|
85
|
+
*
|
|
86
|
+
* - A column added, changed or removed is `addColumn` / `changeColumn` /
|
|
87
|
+
* `removeColumn`; a column whose schema facts did not change produces
|
|
88
|
+
* nothing, whatever happened to its label or width.
|
|
89
|
+
* - A relation added, changed or removed is `addRelation` /
|
|
90
|
+
* `changeRelation` / `removeRelation`.
|
|
91
|
+
* - The rules are {@link rulePatches} over the declared rules (an untouched
|
|
92
|
+
* rule is never rewritten), `setRls` for a posture.
|
|
93
|
+
* - `description` and `history` are `setOption`.
|
|
94
|
+
* - Everything else the edit changed that is a preference key is the
|
|
95
|
+
* presentation delta. A new table's presentation is everything it states.
|
|
96
|
+
*
|
|
97
|
+
* - Adopting a table the database has (`adopt`) is `adoptTable` with its
|
|
98
|
+
* description, then the edit made to its projection.
|
|
99
|
+
*
|
|
100
|
+
* @throws {@link SplitEditError} for a slug, table or database change, a
|
|
101
|
+
* property with no column equivalent, redacted rules, or a new table without
|
|
102
|
+
* a primary key.
|
|
103
|
+
*/
|
|
104
|
+
export declare function splitEdit({ before, after, table, adopt }: SplitEditInput): SplitEdit;
|
|
105
|
+
/** Whether a split edit writes nothing. */
|
|
106
|
+
export declare function isEmptyEdit(edit: SplitEdit): boolean;
|