@rebasepro/cms 0.28.2 → 0.29.0-canary.g0e3a0e7
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 +3 -3
- package/dist/collection_editor/_cms_internals.d.ts +0 -1
- package/dist/collection_editor/ui/EditorCollectionAction.d.ts +2 -2
- package/dist/collection_editor/ui/EditorCollectionAction.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js +2 -2
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js.map +1 -1
- package/dist/components/AdditionalFieldValue.d.ts +9 -3
- package/dist/components/AdditionalFieldValue.js +7 -4
- package/dist/components/AdditionalFieldValue.js.map +1 -1
- package/dist/components/CollectionPanel.d.ts +117 -18
- package/dist/components/CollectionPanel.js +115 -37
- package/dist/components/CollectionPanel.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +5 -5
- package/dist/components/CollectionTableBinding/CollectionRowActions.js +16 -12
- package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js +33 -8
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +8 -3
- package/dist/components/CollectionTableBinding/PropertyTableCell.js +2 -2
- package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
- package/dist/components/CollectionTableBinding/column_utils.d.ts +9 -1
- package/dist/components/CollectionTableBinding/column_utils.js +6 -3
- package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
- 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.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +3 -2
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js +9 -7
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/common.d.ts +26 -2
- package/dist/components/CollectionTableBinding/internal/common.js +88 -4
- package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +4 -3
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +7 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.js +19 -14
- package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionAddButton.d.ts +28 -0
- package/dist/components/CollectionViewBinding/CollectionAddButton.js +50 -0
- package/dist/components/CollectionViewBinding/CollectionAddButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +11 -3
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -4
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +5 -3
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js +5 -3
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +29 -0
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js +112 -0
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +58 -16
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.d.ts +57 -0
- package/dist/components/CollectionViewBinding/CollectionToolbar.js +146 -0
- package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewActions.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +22 -26
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +58 -22
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js +81 -1089
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewContent.d.ts +9 -0
- package/dist/components/CollectionViewBinding/CollectionViewContent.js +152 -0
- package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.d.ts +9 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.js +38 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.d.ts +13 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.js +32 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.d.ts +14 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.js +22 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js +39 -67
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +28 -0
- package/dist/components/CollectionViewBinding/CustomViewHost.js +54 -0
- package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.d.ts +24 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.js +69 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +7 -1
- package/dist/components/CollectionViewBinding/EntityCardBinding.js +34 -23
- package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.d.ts +17 -0
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +107 -0
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -0
- package/dist/components/CollectionViewBinding/FiltersButton.d.ts +15 -0
- package/dist/components/CollectionViewBinding/FiltersButton.js +49 -0
- package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +35 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js +45 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -0
- package/dist/components/CollectionViewBinding/RowActions.d.ts +40 -0
- package/dist/components/CollectionViewBinding/RowActions.js +60 -0
- package/dist/components/CollectionViewBinding/RowActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitListView.d.ts +7 -4
- package/dist/components/CollectionViewBinding/SplitListView.js +20 -21
- package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
- package/dist/components/CollectionViewBinding/builtin_action_props.d.ts +13 -0
- package/dist/components/CollectionViewBinding/fields.d.ts +22 -0
- package/dist/components/CollectionViewBinding/fields.js +47 -0
- package/dist/components/CollectionViewBinding/fields.js.map +1 -0
- package/dist/components/CollectionViewBinding/useBoardDataController.js +6 -7
- package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.d.ts +19 -0
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js +28 -0
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js.map +1 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +125 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.js +844 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +20 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.js +23 -2
- package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/useSelectionController.d.ts +21 -3
- package/dist/components/CollectionViewBinding/useSelectionController.js +37 -6
- package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
- package/dist/components/CollectionsProvider.d.ts +3 -3
- package/dist/components/CollectionsProvider.js +4 -4
- package/dist/components/CollectionsProvider.js.map +1 -1
- package/dist/components/CollectionsScopeContext.d.ts +1 -1
- package/dist/components/CollectionsScopeContext.js +1 -1
- package/dist/components/CollectionsScopeContext.js.map +1 -1
- package/dist/components/DeleteEntityDialog.d.ts +1 -1
- package/dist/components/DeleteEntityDialog.js +2 -2
- package/dist/components/DeleteEntityDialog.js.map +1 -1
- package/dist/components/DetailViewBinding.js +32 -68
- package/dist/components/DetailViewBinding.js.map +1 -1
- package/dist/components/EditFormActions.js +5 -4
- package/dist/components/EditFormActions.js.map +1 -1
- package/dist/components/EditViewBinding.d.ts +2 -2
- package/dist/components/EditViewBinding.js +25 -15
- package/dist/components/EditViewBinding.js.map +1 -1
- package/dist/components/EntityDisplayHeader.js +8 -5
- package/dist/components/EntityDisplayHeader.js.map +1 -1
- package/dist/components/EntityPreviewBinding.js +1 -1
- package/dist/components/EntityPreviewBinding.js.map +1 -1
- package/dist/components/EntityViewBinding.d.ts +8 -1
- package/dist/components/EntityViewBinding.js +43 -14
- package/dist/components/EntityViewBinding.js.map +1 -1
- package/dist/components/EntityViewBody.d.ts +40 -0
- package/dist/components/EntityViewBody.js +90 -0
- package/dist/components/EntityViewBody.js.map +1 -0
- package/dist/components/FieldValue.d.ts +50 -0
- package/dist/components/FieldValue.js +81 -0
- package/dist/components/FieldValue.js.map +1 -0
- package/dist/components/InlineEntityPreview.js +1 -1
- package/dist/components/InlineEntityPreview.js.map +1 -1
- package/dist/components/PanelNotFound.d.ts +5 -0
- package/dist/components/PanelNotFound.js +21 -0
- package/dist/components/PanelNotFound.js.map +1 -0
- package/dist/components/RebaseCMS.d.ts +1 -1
- package/dist/components/RebaseCMS.js +11 -3
- package/dist/components/RebaseCMS.js.map +1 -1
- package/dist/components/RebaseNavigation.js +9 -3
- package/dist/components/RebaseNavigation.js.map +1 -1
- package/dist/components/RebaseShell.js +10 -5
- package/dist/components/RebaseShell.js.map +1 -1
- package/dist/components/RecordDetail.d.ts +61 -0
- package/dist/components/RecordDetail.js +123 -0
- package/dist/components/RecordDetail.js.map +1 -0
- package/dist/components/RecordForm.d.ts +126 -0
- package/dist/components/{EntityFormPanel.js → RecordForm.js} +64 -36
- package/dist/components/RecordForm.js.map +1 -0
- package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +47 -17
- package/dist/components/ReferenceTable/SelectionTableBinding.js +89 -53
- package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
- package/dist/components/ReferenceWidget.d.ts +5 -3
- package/dist/components/ReferenceWidget.js +10 -7
- package/dist/components/ReferenceWidget.js.map +1 -1
- package/dist/components/RelationSelector.js +4 -4
- package/dist/components/RelationSelector.js.map +1 -1
- package/dist/components/SelectableTable/SelectableTable.js +2 -3
- package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
- package/dist/components/SelectableTable/SelectionStore.d.ts +1 -1
- package/dist/components/SelectableTable/SelectionStore.js +1 -1
- package/dist/components/SelectableTable/SelectionStore.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/SidePanelBinding.js +13 -12
- package/dist/components/SidePanelBinding.js.map +1 -1
- package/dist/components/collection_prop.d.ts +18 -0
- package/dist/components/collection_prop.js +23 -0
- package/dist/components/collection_prop.js.map +1 -0
- package/dist/components/common/default_entity_actions.js +54 -54
- package/dist/components/common/default_entity_actions.js.map +1 -1
- package/dist/components/history/EntityHistoryView.d.ts +4 -1
- package/dist/components/history/EntityHistoryView.js +1 -1
- package/dist/components/history/EntityHistoryView.js.map +1 -1
- package/dist/components/history/LastEditedByFormAction.d.ts +1 -1
- package/dist/components/index.d.ts +4 -2
- package/dist/data_export/export/ExportCollectionAction.d.ts +3 -2
- package/dist/data_export/export/ExportCollectionAction.js +4 -3
- package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
- package/dist/data_export/export/additional_fields.d.ts +6 -3
- package/dist/data_export/export/additional_fields.js +8 -4
- package/dist/data_export/export/additional_fields.js.map +1 -1
- package/dist/data_import/import/ImportCollectionAction.js +2 -2
- package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
- package/dist/form/EntityForm.d.ts +1 -1
- package/dist/form/EntityForm.js +252 -150
- package/dist/form/EntityForm.js.map +1 -1
- package/dist/form/EntityFormActions.js +3 -2
- package/dist/form/EntityFormActions.js.map +1 -1
- package/dist/form/EntityFormBinding.d.ts +1 -1
- package/dist/form/EntityFormBinding.js +22 -11
- package/dist/form/EntityFormBinding.js.map +1 -1
- package/dist/form/FormField.d.ts +36 -0
- package/dist/form/FormField.js +41 -0
- package/dist/form/FormField.js.map +1 -0
- package/dist/form/FormFieldsContext.d.ts +69 -0
- package/dist/form/FormFieldsContext.js +143 -0
- package/dist/form/FormFieldsContext.js.map +1 -0
- package/dist/form/PropertyFieldBinding.js +4 -4
- package/dist/form/PropertyFieldBinding.js.map +1 -1
- package/dist/form/collection_showing.d.ts +8 -0
- package/dist/form/collection_showing.js +29 -0
- package/dist/form/collection_showing.js.map +1 -0
- package/dist/form/components/ErrorFocus.js +2 -1
- package/dist/form/components/ErrorFocus.js.map +1 -1
- package/dist/form/components/FieldBlock.js +3 -1
- package/dist/form/components/FieldBlock.js.map +1 -1
- package/dist/form/components/FormRail.d.ts +5 -1
- package/dist/form/components/FormRail.js +5 -1
- package/dist/form/components/FormRail.js.map +1 -1
- package/dist/form/components/FormSections.d.ts +5 -1
- package/dist/form/components/FormSections.js +11 -4
- package/dist/form/components/FormSections.js.map +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +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/MultipleRelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +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.js +2 -2
- package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.js +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
- package/dist/form/form_dom_ids.d.ts +25 -0
- package/dist/form/form_dom_ids.js +42 -0
- package/dist/form/form_dom_ids.js.map +1 -0
- package/dist/form/index.d.ts +3 -1
- package/dist/form/resolve_cell_property.d.ts +5 -0
- package/dist/form/resolve_cell_property.js +22 -1
- package/dist/form/resolve_cell_property.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +2 -2
- package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
- package/dist/hooks/navigation/useNavigationResolution.d.ts +3 -3
- package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
- package/dist/hooks/navigation/useResolvedCollections.d.ts +2 -2
- package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
- package/dist/hooks/navigation/useResolvedViews.d.ts +2 -2
- package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
- package/dist/hooks/useBuildSidePanel.js +9 -9
- package/dist/hooks/useBuildSidePanel.js.map +1 -1
- package/dist/hooks/useEntityDisplay.js +6 -4
- package/dist/hooks/useEntityDisplay.js.map +1 -1
- package/dist/hooks/useRecordActions.js +2 -2
- package/dist/hooks/useRecordActions.js.map +1 -1
- package/dist/hooks/useSelectionDialog.d.ts +20 -7
- package/dist/hooks/useSelectionDialog.js +29 -8
- package/dist/hooks/useSelectionDialog.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +15 -9
- package/dist/mcp-view.d.ts +9 -0
- package/dist/mcp-view.js +2 -0
- package/dist/mcp_view/app_modules.d.ts +29 -0
- package/dist/mcp_view/app_modules.js +163 -0
- package/dist/mcp_view/app_modules.js.map +1 -0
- package/dist/mcp_view/bridge.d.ts +90 -0
- package/dist/mcp_view/bridge.js +205 -0
- package/dist/mcp_view/bridge.js.map +1 -0
- package/dist/mcp_view/code_app.d.ts +65 -0
- package/dist/mcp_view/code_app.js +139 -0
- package/dist/mcp_view/code_app.js.map +1 -0
- package/dist/mcp_view/index.d.ts +48 -0
- package/dist/mcp_view/index.js +235 -0
- package/dist/mcp_view/index.js.map +1 -0
- package/dist/mcp_view/payload.d.ts +78 -0
- package/dist/mcp_view/payload.js +155 -0
- package/dist/mcp_view/payload.js.map +1 -0
- package/dist/mcp_view/screen.d.ts +28 -0
- package/dist/mcp_view/screen.js +223 -0
- package/dist/mcp_view/screen.js.map +1 -0
- package/dist/mcp_view/storage_source.d.ts +14 -0
- package/dist/mcp_view/storage_source.js +29 -0
- package/dist/mcp_view/storage_source.js.map +1 -0
- package/dist/mcp_view/store.d.ts +9 -0
- package/dist/mcp_view/store.js +27 -0
- package/dist/mcp_view/store.js.map +1 -0
- package/dist/mcp_view/tool_driver.d.ts +135 -0
- package/dist/mcp_view/tool_driver.js +527 -0
- package/dist/mcp_view/tool_driver.js.map +1 -0
- package/dist/preview/components/DatePreview.d.ts +34 -1
- package/dist/preview/components/DatePreview.js +72 -37
- package/dist/preview/components/DatePreview.js.map +1 -1
- package/dist/routes/RebaseRoute.js +1 -1
- package/dist/routes/RebaseRoute.js.map +1 -1
- package/dist/selection/SelectionMenu.d.ts +5 -3
- package/dist/selection/SelectionMenu.js +16 -9
- package/dist/selection/SelectionMenu.js.map +1 -1
- package/dist/selection/index.d.ts +2 -1
- package/dist/selection/resolve_selection.d.ts +61 -7
- package/dist/selection/resolve_selection.js +93 -11
- package/dist/selection/resolve_selection.js.map +1 -1
- package/dist/types/components/EntityFormProps.d.ts +60 -10
- package/dist/types/fields.d.ts +2 -65
- package/dist/util/dataControllerAdapter.d.ts +8 -0
- package/dist/util/dataControllerAdapter.js +11 -0
- package/dist/util/dataControllerAdapter.js.map +1 -1
- package/dist/util/navigation_utils.d.ts +5 -4
- package/dist/util/navigation_utils.js +6 -6
- package/dist/util/navigation_utils.js.map +1 -1
- package/dist/util/propertyConfigMapper.d.ts +8 -0
- package/dist/util/propertyConfigMapper.js +16 -2
- package/dist/util/propertyConfigMapper.js.map +1 -1
- package/package.json +15 -9
- package/recipes/README.md +79 -26
- package/recipes/approval-queue.tsx +79 -0
- package/recipes/bulk-set-status.tsx +23 -17
- package/recipes/calendar-view.tsx +28 -23
- package/recipes/master-detail.tsx +75 -0
- package/recipes/my-preferences.tsx +3 -3
- package/recipes/orders-dashboard.tsx +58 -84
- package/recipes/site-settings.tsx +4 -4
- package/dist/components/EntityFormPanel.d.ts +0 -63
- package/dist/components/EntityFormPanel.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Entity, FindParams } from "@rebasepro/types";
|
|
2
|
-
import { EntitySelection, SelectionQuery } from "@rebasepro/cms-types";
|
|
1
|
+
import { CollectionConfig, Entity, FindParams, RebaseSdkData } from "@rebasepro/types";
|
|
2
|
+
import { EntitySelection, RowSelection, SelectionQuery } from "@rebasepro/cms-types";
|
|
3
3
|
import { EntityPageAccessor } from "../util/entity_pages.js";
|
|
4
4
|
/**
|
|
5
5
|
* Rows asked for per request while resolving a query selection.
|
|
@@ -31,7 +31,33 @@ export declare const MAX_SELECTION_ROWS = 20000;
|
|
|
31
31
|
export declare function serializeSelectionQuery<M extends Record<string, unknown>>(query: SelectionQuery<M>): string;
|
|
32
32
|
/** Turn a captured selection query into the `find` params that reproduce it. */
|
|
33
33
|
export declare function selectionQueryToFindParams<M extends Record<string, unknown>>(query: SelectionQuery<M>): Omit<FindParams<M>, "limit" | "offset" | "page">;
|
|
34
|
+
/**
|
|
35
|
+
* What {@link resolveSelection} takes: a view's selection, and where its rows
|
|
36
|
+
* are read.
|
|
37
|
+
*/
|
|
34
38
|
export interface ResolveSelectionParams<M extends Record<string, unknown>> {
|
|
39
|
+
/** `selectionController.selection`. */
|
|
40
|
+
selection: RowSelection<M>;
|
|
41
|
+
/** `context.data`: where a query selection's rows are read. */
|
|
42
|
+
data: Pick<RebaseSdkData, "collection">;
|
|
43
|
+
/** The selection's collection: what a row's id is read by. */
|
|
44
|
+
collection: CollectionConfig;
|
|
45
|
+
pageSize?: number;
|
|
46
|
+
maxRows?: number;
|
|
47
|
+
/** Called after every page, so a long resolve can show where it is. */
|
|
48
|
+
onProgress?: (loaded: number, total: number | undefined) => void;
|
|
49
|
+
/** Checked between pages; aborting returns the rows read so far. */
|
|
50
|
+
signal?: {
|
|
51
|
+
aborted: boolean;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* {@link resolveEntitySelection}'s parameters: the admin's own selection and
|
|
56
|
+
* the accessor of its own data.
|
|
57
|
+
*
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
export interface ResolveEntitySelectionParams<M extends Record<string, unknown>> {
|
|
35
61
|
selection: EntitySelection<M>;
|
|
36
62
|
/**
|
|
37
63
|
* Reads the rows a query selection stands for. Only consulted in query
|
|
@@ -41,22 +67,50 @@ export interface ResolveSelectionParams<M extends Record<string, unknown>> {
|
|
|
41
67
|
accessor: EntityPageAccessor<M>;
|
|
42
68
|
pageSize?: number;
|
|
43
69
|
maxRows?: number;
|
|
44
|
-
/** Called after every page, so a long resolve can show where it is. */
|
|
45
70
|
onProgress?: (loaded: number, total: number | undefined) => void;
|
|
46
|
-
/** Checked between pages; aborting returns the rows read so far. */
|
|
47
71
|
signal?: {
|
|
48
72
|
aborted: boolean;
|
|
49
73
|
};
|
|
50
74
|
}
|
|
51
75
|
/**
|
|
52
|
-
*
|
|
76
|
+
* What {@link resolveSelection} hands back: the rows and their ids, as a
|
|
77
|
+
* ticked selection holds them.
|
|
78
|
+
*/
|
|
79
|
+
export interface ResolvedSelection {
|
|
80
|
+
/** The rows, as the server sends them. */
|
|
81
|
+
rows: Record<string, unknown>[];
|
|
82
|
+
/**
|
|
83
|
+
* The id of each of `rows`, at the same position: the record's primary
|
|
84
|
+
* key as a string, a composite one's parts joined by `:::` — what
|
|
85
|
+
* `useRowWrites().update` and `useSidePanel().open` take.
|
|
86
|
+
*/
|
|
87
|
+
ids: string[];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The rows a selection covers, as the server sends them — ISO dates, a
|
|
91
|
+
* belongsTo as its foreign key, a relation the view loads nested under its
|
|
92
|
+
* name as REST's `include` returns it — one shape in both modes: a query
|
|
93
|
+
* selection's rows are read with the view's own include. Their ids come
|
|
94
|
+
* beside them.
|
|
53
95
|
*
|
|
54
96
|
* This is the *only* way to get rows out of a query selection, and it is why
|
|
55
|
-
* {@link
|
|
97
|
+
* {@link RowSelection} is a union: a bulk action has to call it, which means
|
|
56
98
|
* it has to deal with the wait, the ceiling and the failure. The array this
|
|
57
99
|
* replaced let the same code path read whatever the view had scrolled — 50 rows
|
|
58
100
|
* of 12,480 — and report success.
|
|
59
101
|
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* const { rows, ids } = await resolveSelection({ selection, data: context.data, collection });
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @throws When the query matches more than `maxRows` rows.
|
|
107
|
+
*/
|
|
108
|
+
export declare function resolveSelection<M extends Record<string, unknown>>({ data, collection, selection, ...rest }: ResolveSelectionParams<M>): Promise<ResolvedSelection>;
|
|
109
|
+
/**
|
|
110
|
+
* {@link resolveSelection} for the admin's own selection: the records it
|
|
111
|
+
* covers, in its `Entity` view model, read through `accessor`.
|
|
112
|
+
*
|
|
60
113
|
* @throws When the query matches more than `maxRows` rows.
|
|
114
|
+
* @internal
|
|
61
115
|
*/
|
|
62
|
-
export declare function
|
|
116
|
+
export declare function resolveEntitySelection<M extends Record<string, unknown>>({ selection, accessor, pageSize, maxRows, onProgress, signal }: ResolveEntitySelectionParams<M>): Promise<Entity<M>[]>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { walkEntityPages } from "../util/entity_pages.js";
|
|
2
|
+
import { buildCompositeId, resolvePrimaryKeys } from "@rebasepro/common";
|
|
3
|
+
import { getRelationIncludeParams } from "@rebasepro/app";
|
|
2
4
|
//#region src/selection/resolve_selection.ts
|
|
3
5
|
/**
|
|
4
6
|
* Rows asked for per request while resolving a query selection.
|
|
@@ -41,39 +43,119 @@ function selectionQueryToFindParams(query) {
|
|
|
41
43
|
};
|
|
42
44
|
}
|
|
43
45
|
/**
|
|
44
|
-
* The rows a selection covers
|
|
46
|
+
* The rows a selection covers, as the server sends them — ISO dates, a
|
|
47
|
+
* belongsTo as its foreign key, a relation the view loads nested under its
|
|
48
|
+
* name as REST's `include` returns it — one shape in both modes: a query
|
|
49
|
+
* selection's rows are read with the view's own include. Their ids come
|
|
50
|
+
* beside them.
|
|
45
51
|
*
|
|
46
52
|
* This is the *only* way to get rows out of a query selection, and it is why
|
|
47
|
-
* {@link
|
|
53
|
+
* {@link RowSelection} is a union: a bulk action has to call it, which means
|
|
48
54
|
* it has to deal with the wait, the ceiling and the failure. The array this
|
|
49
55
|
* replaced let the same code path read whatever the view had scrolled — 50 rows
|
|
50
56
|
* of 12,480 — and report success.
|
|
51
57
|
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* const { rows, ids } = await resolveSelection({ selection, data: context.data, collection });
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @throws When the query matches more than `maxRows` rows.
|
|
63
|
+
*/
|
|
64
|
+
async function resolveSelection({ data, collection, selection, ...rest }) {
|
|
65
|
+
if (selection.type === "rows") {
|
|
66
|
+
rest.onProgress?.(selection.rows.length, selection.rows.length);
|
|
67
|
+
return {
|
|
68
|
+
rows: selection.rows,
|
|
69
|
+
ids: selection.ids
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const keys = resolvePrimaryKeys(collection);
|
|
73
|
+
const path = selection.query.path;
|
|
74
|
+
const flat = data.collection(path);
|
|
75
|
+
const include = getRelationIncludeParams(collection);
|
|
76
|
+
const accessor = { find: async (findParams) => {
|
|
77
|
+
const page = await flat.find(include ? {
|
|
78
|
+
...findParams,
|
|
79
|
+
include
|
|
80
|
+
} : findParams);
|
|
81
|
+
return {
|
|
82
|
+
data: page.data.map((row) => ({
|
|
83
|
+
id: idOf(row, keys),
|
|
84
|
+
path,
|
|
85
|
+
values: row
|
|
86
|
+
})),
|
|
87
|
+
meta: page.meta
|
|
88
|
+
};
|
|
89
|
+
} };
|
|
90
|
+
const excluded = new Set(selection.excludedIds.map(String));
|
|
91
|
+
const entities = await walkQuerySelection({
|
|
92
|
+
...rest,
|
|
93
|
+
query: selection.query,
|
|
94
|
+
count: selection.count,
|
|
95
|
+
excludedCount: selection.excludedIds.length,
|
|
96
|
+
keep: (entity) => !excluded.has(String(entity.id)),
|
|
97
|
+
accessor
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
rows: entities.map((entity) => entity.values),
|
|
101
|
+
ids: entities.map((entity) => String(entity.id))
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function idOf(row, keys) {
|
|
105
|
+
if (keys.length > 0) return buildCompositeId(row, keys);
|
|
106
|
+
const id = row.id;
|
|
107
|
+
return typeof id === "string" || typeof id === "number" ? String(id) : "";
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* {@link resolveSelection} for the admin's own selection: the records it
|
|
111
|
+
* covers, in its `Entity` view model, read through `accessor`.
|
|
112
|
+
*
|
|
52
113
|
* @throws When the query matches more than `maxRows` rows.
|
|
114
|
+
* @internal
|
|
53
115
|
*/
|
|
54
|
-
async function
|
|
116
|
+
async function resolveEntitySelection({ selection, accessor, pageSize = 500, maxRows = MAX_SELECTION_ROWS, onProgress, signal }) {
|
|
55
117
|
if (selection.type === "entities") {
|
|
56
118
|
onProgress?.(selection.entities.length, selection.entities.length);
|
|
57
119
|
return selection.entities;
|
|
58
120
|
}
|
|
59
|
-
|
|
60
|
-
|
|
121
|
+
const excluded = new Set(selection.excluded.map((e) => `${e.path}/${e.id}`));
|
|
122
|
+
return walkQuerySelection({
|
|
61
123
|
accessor,
|
|
62
|
-
|
|
124
|
+
query: selection.query,
|
|
125
|
+
count: selection.count,
|
|
126
|
+
excludedCount: selection.excluded.length,
|
|
127
|
+
keep: (e) => !excluded.has(`${e.path}/${e.id}`),
|
|
63
128
|
pageSize,
|
|
64
129
|
maxRows,
|
|
65
130
|
onProgress,
|
|
131
|
+
signal
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Every row a query selection matches, less the ones ticked off. The ceiling
|
|
136
|
+
* is on the rows left once those are out: the ticked-off rows are read with
|
|
137
|
+
* the rest and dropped, so the walk may read that many past it.
|
|
138
|
+
*/
|
|
139
|
+
async function walkQuerySelection({ accessor, query, count, excludedCount, keep, pageSize = 500, maxRows = MAX_SELECTION_ROWS, onProgress, signal }) {
|
|
140
|
+
if (count !== void 0 && count - excludedCount > maxRows) throw new Error(selectionCeilingMessage(maxRows));
|
|
141
|
+
const rows = await walkEntityPages({
|
|
142
|
+
accessor,
|
|
143
|
+
params: selectionQueryToFindParams(query),
|
|
144
|
+
pageSize,
|
|
145
|
+
maxRows: maxRows + excludedCount,
|
|
146
|
+
onProgress,
|
|
66
147
|
signal,
|
|
67
|
-
onCeiling: selectionCeilingMessage
|
|
148
|
+
onCeiling: () => selectionCeilingMessage(maxRows)
|
|
68
149
|
});
|
|
69
|
-
if (
|
|
70
|
-
const
|
|
71
|
-
|
|
150
|
+
if (excludedCount === 0) return rows;
|
|
151
|
+
const kept = rows.filter(keep);
|
|
152
|
+
if (kept.length > maxRows) throw new Error(selectionCeilingMessage(maxRows));
|
|
153
|
+
return kept;
|
|
72
154
|
}
|
|
73
155
|
function selectionCeilingMessage(maxRows) {
|
|
74
156
|
return `This selection covers more than ${maxRows.toLocaleString()} rows, which is more than can be acted on from the browser in one go. Filter the collection down first.`;
|
|
75
157
|
}
|
|
76
158
|
//#endregion
|
|
77
|
-
export { MAX_SELECTION_ROWS, SELECTION_PAGE_SIZE, resolveSelection, selectionQueryToFindParams, serializeSelectionQuery };
|
|
159
|
+
export { MAX_SELECTION_ROWS, SELECTION_PAGE_SIZE, resolveEntitySelection, resolveSelection, selectionQueryToFindParams, serializeSelectionQuery };
|
|
78
160
|
|
|
79
161
|
//# sourceMappingURL=resolve_selection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve_selection.js","names":[],"sources":["../../src/selection/resolve_selection.ts"],"sourcesContent":["import { Entity, FindParams, OrderByTuple } from \"@rebasepro/types\";\nimport { EntitySelection, SelectionQuery } from \"@rebasepro/cms-types\";\nimport { EntityPageAccessor, walkEntityPages } from \"../util/entity_pages\";\n\n/**\n * Rows asked for per request while resolving a query selection.\n *\n * Same ceiling as the export walk, and for the same reason: the server refuses\n * a `limit` above its `MAX_LIST_LIMIT` rather than clamping it.\n */\nexport const SELECTION_PAGE_SIZE = 500;\n\n/**\n * Most rows one query selection will resolve to ids for.\n *\n * The write path is per-row — `deleteMany` loops the single-row delete server\n * side so hooks and row-level security still run for each — so this is a\n * genuine ceiling on the work, not just on memory. Going over it **throws**\n * rather than acting on a prefix, which is the failure that cannot be seen:\n * \"deleted 12,480 rows\" reads identically whether it was all of them or the\n * first page.\n */\nexport const MAX_SELECTION_ROWS = 20_000;\n\n/**\n * A stable string for a selection query, for comparing the query a selection\n * was made against with the one the view is showing now.\n *\n * Filter keys are sorted: `filterValues` is rebuilt on most renders and its key\n * order follows whatever order the user touched the columns in, so a plain\n * `JSON.stringify` would report the same filter as a different one and drop a\n * selection the moment anything re-rendered.\n */\nexport function serializeSelectionQuery<M extends Record<string, unknown>>(query: SelectionQuery<M>): string {\n const filter = query.filterValues\n ? Object.keys(query.filterValues).sort()\n .map(k => `${k}=${JSON.stringify((query.filterValues as Record<string, unknown>)[k])}`)\n .join(\"&\")\n : \"\";\n const order = query.sortBy?.map(([field, direction]) => `${String(field)}:${direction}`).join(\",\") ?? \"\";\n return `${query.path}|${filter}|${order}|${query.searchString ?? \"\"}`;\n}\n\n/** Turn a captured selection query into the `find` params that reproduce it. */\nexport function selectionQueryToFindParams<M extends Record<string, unknown>>(\n query: SelectionQuery<M>\n): Omit<FindParams<M>, \"limit\" | \"offset\" | \"page\"> {\n const where = query.filterValues && Object.keys(query.filterValues).length > 0\n ? query.filterValues\n : undefined;\n const orderBy = query.sortBy && query.sortBy.length > 0\n ? query.sortBy.map(([field, direction]) => [String(field), direction] as OrderByTuple)\n : undefined;\n return {\n where,\n orderBy,\n searchString: query.searchString\n } as Omit<FindParams<M>, \"limit\" | \"offset\" | \"page\">;\n}\n\nexport interface ResolveSelectionParams<M extends Record<string, unknown>> {\n selection: EntitySelection<M>;\n /**\n * Reads the rows a query selection stands for. Only consulted in query\n * mode — an entities selection is already resolved and never hits the\n * network.\n */\n accessor: EntityPageAccessor<M>;\n pageSize?: number;\n maxRows?: number;\n /** Called after every page, so a long resolve can show where it is. */\n onProgress?: (loaded: number, total: number | undefined) => void;\n /** Checked between pages; aborting returns the rows read so far. */\n signal?: { aborted: boolean };\n}\n\n/**\n * The rows a selection covers.\n *\n * This is the *only* way to get rows out of a query selection, and it is why\n * {@link EntitySelection} is a union: a bulk action has to call it, which means\n * it has to deal with the wait, the ceiling and the failure. The array this\n * replaced let the same code path read whatever the view had scrolled — 50 rows\n * of 12,480 — and report success.\n *\n * @throws When the query matches more than `maxRows` rows.\n */\nexport async function resolveSelection<M extends Record<string, unknown>>({\n selection,\n accessor,\n pageSize = SELECTION_PAGE_SIZE,\n maxRows = MAX_SELECTION_ROWS,\n onProgress,\n signal\n}: ResolveSelectionParams<M>): Promise<Entity<M>[]> {\n\n if (selection.type === \"entities\") {\n onProgress?.(selection.entities.length, selection.entities.length);\n return selection.entities;\n }\n\n // The count was taken when the selection was made, so it can only be a\n // forecast — but it is the one the user was shown and agreed to, and\n // refusing before the walk beats refusing forty pages in.\n if (selection.count !== undefined && selection.count - selection.excluded.length > maxRows)\n throw new Error(selectionCeilingMessage(maxRows));\n\n const rows = await walkEntityPages<M>({\n accessor,\n params: selectionQueryToFindParams(selection.query),\n pageSize,\n maxRows,\n onProgress,\n signal,\n onCeiling: selectionCeilingMessage\n });\n\n if (selection.excluded.length === 0) return rows;\n\n const excluded = new Set(selection.excluded.map(e => `${e.path}/${e.id}`));\n return rows.filter(e => !excluded.has(`${e.path}/${e.id}`));\n}\n\nfunction selectionCeilingMessage(maxRows: number): string {\n return `This selection covers more than ${maxRows.toLocaleString()} rows, which is more than ` +\n \"can be acted on from the browser in one go. Filter the collection down first.\";\n}\n"],"mappings":";;;;;;;;AAUA,IAAa,sBAAsB;;;;;;;;;;;AAYnC,IAAa,qBAAqB;;;;;;;;;;AAWlC,SAAgB,wBAA2D,OAAkC;CACzG,MAAM,SAAS,MAAM,eACf,OAAO,KAAK,MAAM,YAAY,CAAC,CAAC,KAAK,CAAC,CACnC,KAAI,MAAK,GAAG,EAAE,GAAG,KAAK,UAAW,MAAM,aAAyC,EAAE,GAAG,CAAC,CACtF,KAAK,GAAG,IACX;CACN,MAAM,QAAQ,MAAM,QAAQ,KAAK,CAAC,OAAO,eAAe,GAAG,OAAO,KAAK,EAAE,GAAG,WAAW,CAAC,CAAC,KAAK,GAAG,KAAK;CACtG,OAAO,GAAG,MAAM,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,gBAAgB;AACrE;;AAGA,SAAgB,2BACZ,OACgD;CAOhD,OAAO;EACH,OAPU,MAAM,gBAAgB,OAAO,KAAK,MAAM,YAAY,CAAC,CAAC,SAAS,IACvE,MAAM,eACN,KAAA;EAMF,SALY,MAAM,UAAU,MAAM,OAAO,SAAS,IAChD,MAAM,OAAO,KAAK,CAAC,OAAO,eAAe,CAAC,OAAO,KAAK,GAAG,SAAS,CAAiB,IACnF,KAAA;EAIF,cAAc,MAAM;CACxB;AACJ;;;;;;;;;;;;AA6BA,eAAsB,iBAAoD,EACtE,WACA,UACA,WAAA,KACA,UAAU,oBACV,YACA,UACgD;CAEhD,IAAI,UAAU,SAAS,YAAY;EAC/B,aAAa,UAAU,SAAS,QAAQ,UAAU,SAAS,MAAM;EACjE,OAAO,UAAU;CACrB;CAKA,IAAI,UAAU,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU,SAAS,SAAS,SAC/E,MAAM,IAAI,MAAM,wBAAwB,OAAO,CAAC;CAEpD,MAAM,OAAO,MAAM,gBAAmB;EAClC;EACA,QAAQ,2BAA2B,UAAU,KAAK;EAClD;EACA;EACA;EACA;EACA,WAAW;CACf,CAAC;CAED,IAAI,UAAU,SAAS,WAAW,GAAG,OAAO;CAE5C,MAAM,WAAW,IAAI,IAAI,UAAU,SAAS,KAAI,MAAK,GAAG,EAAE,KAAK,GAAG,EAAE,IAAI,CAAC;CACzE,OAAO,KAAK,QAAO,MAAK,CAAC,SAAS,IAAI,GAAG,EAAE,KAAK,GAAG,EAAE,IAAI,CAAC;AAC9D;AAEA,SAAS,wBAAwB,SAAyB;CACtD,OAAO,mCAAmC,QAAQ,eAAe,EAAE;AAEvE"}
|
|
1
|
+
{"version":3,"file":"resolve_selection.js","names":[],"sources":["../../src/selection/resolve_selection.ts"],"sourcesContent":["import { CollectionConfig, Entity, FindParams, OrderByTuple, RebaseSdkData } from \"@rebasepro/types\";\nimport { EntitySelection, RowSelection, SelectionQuery } from \"@rebasepro/cms-types\";\nimport { buildCompositeId, resolvePrimaryKeys } from \"@rebasepro/common\";\nimport { getRelationIncludeParams } from \"@rebasepro/app\";\nimport { EntityPageAccessor, walkEntityPages } from \"../util/entity_pages\";\n\n/**\n * Rows asked for per request while resolving a query selection.\n *\n * Same ceiling as the export walk, and for the same reason: the server refuses\n * a `limit` above its `MAX_LIST_LIMIT` rather than clamping it.\n */\nexport const SELECTION_PAGE_SIZE = 500;\n\n/**\n * Most rows one query selection will resolve to ids for.\n *\n * The write path is per-row — `deleteMany` loops the single-row delete server\n * side so hooks and row-level security still run for each — so this is a\n * genuine ceiling on the work, not just on memory. Going over it **throws**\n * rather than acting on a prefix, which is the failure that cannot be seen:\n * \"deleted 12,480 rows\" reads identically whether it was all of them or the\n * first page.\n */\nexport const MAX_SELECTION_ROWS = 20_000;\n\n/**\n * A stable string for a selection query, for comparing the query a selection\n * was made against with the one the view is showing now.\n *\n * Filter keys are sorted: `filterValues` is rebuilt on most renders and its key\n * order follows whatever order the user touched the columns in, so a plain\n * `JSON.stringify` would report the same filter as a different one and drop a\n * selection the moment anything re-rendered.\n */\nexport function serializeSelectionQuery<M extends Record<string, unknown>>(query: SelectionQuery<M>): string {\n const filter = query.filterValues\n ? Object.keys(query.filterValues).sort()\n .map(k => `${k}=${JSON.stringify((query.filterValues as Record<string, unknown>)[k])}`)\n .join(\"&\")\n : \"\";\n const order = query.sortBy?.map(([field, direction]) => `${String(field)}:${direction}`).join(\",\") ?? \"\";\n return `${query.path}|${filter}|${order}|${query.searchString ?? \"\"}`;\n}\n\n/** Turn a captured selection query into the `find` params that reproduce it. */\nexport function selectionQueryToFindParams<M extends Record<string, unknown>>(\n query: SelectionQuery<M>\n): Omit<FindParams<M>, \"limit\" | \"offset\" | \"page\"> {\n const where = query.filterValues && Object.keys(query.filterValues).length > 0\n ? query.filterValues\n : undefined;\n const orderBy = query.sortBy && query.sortBy.length > 0\n ? query.sortBy.map(([field, direction]) => [String(field), direction] as OrderByTuple)\n : undefined;\n return {\n where,\n orderBy,\n searchString: query.searchString\n } as Omit<FindParams<M>, \"limit\" | \"offset\" | \"page\">;\n}\n\n/**\n * What {@link resolveSelection} takes: a view's selection, and where its rows\n * are read.\n */\nexport interface ResolveSelectionParams<M extends Record<string, unknown>> {\n /** `selectionController.selection`. */\n selection: RowSelection<M>;\n /** `context.data`: where a query selection's rows are read. */\n data: Pick<RebaseSdkData, \"collection\">;\n /** The selection's collection: what a row's id is read by. */\n collection: CollectionConfig;\n pageSize?: number;\n maxRows?: number;\n /** Called after every page, so a long resolve can show where it is. */\n onProgress?: (loaded: number, total: number | undefined) => void;\n /** Checked between pages; aborting returns the rows read so far. */\n signal?: { aborted: boolean };\n}\n\n/**\n * {@link resolveEntitySelection}'s parameters: the admin's own selection and\n * the accessor of its own data.\n *\n * @internal\n */\nexport interface ResolveEntitySelectionParams<M extends Record<string, unknown>> {\n selection: EntitySelection<M>;\n /**\n * Reads the rows a query selection stands for. Only consulted in query\n * mode — an entities selection is already resolved and never hits the\n * network.\n */\n accessor: EntityPageAccessor<M>;\n pageSize?: number;\n maxRows?: number;\n onProgress?: (loaded: number, total: number | undefined) => void;\n signal?: { aborted: boolean };\n}\n\n/**\n * What {@link resolveSelection} hands back: the rows and their ids, as a\n * ticked selection holds them.\n */\nexport interface ResolvedSelection {\n /** The rows, as the server sends them. */\n rows: Record<string, unknown>[];\n /**\n * The id of each of `rows`, at the same position: the record's primary\n * key as a string, a composite one's parts joined by `:::` — what\n * `useRowWrites().update` and `useSidePanel().open` take.\n */\n ids: string[];\n}\n\n/**\n * The rows a selection covers, as the server sends them — ISO dates, a\n * belongsTo as its foreign key, a relation the view loads nested under its\n * name as REST's `include` returns it — one shape in both modes: a query\n * selection's rows are read with the view's own include. Their ids come\n * beside them.\n *\n * This is the *only* way to get rows out of a query selection, and it is why\n * {@link RowSelection} is a union: a bulk action has to call it, which means\n * it has to deal with the wait, the ceiling and the failure. The array this\n * replaced let the same code path read whatever the view had scrolled — 50 rows\n * of 12,480 — and report success.\n *\n * ```ts\n * const { rows, ids } = await resolveSelection({ selection, data: context.data, collection });\n * ```\n *\n * @throws When the query matches more than `maxRows` rows.\n */\nexport async function resolveSelection<M extends Record<string, unknown>>({\n data,\n collection,\n selection,\n ...rest\n}: ResolveSelectionParams<M>): Promise<ResolvedSelection> {\n if (selection.type === \"rows\") {\n rest.onProgress?.(selection.rows.length, selection.rows.length);\n return { rows: selection.rows, ids: selection.ids };\n }\n const keys = resolvePrimaryKeys(collection);\n const path = selection.query.path;\n const flat = data.collection<M>(path);\n // The relations the view reads its rows with, so a row read here is the\n // row a ticked one is.\n const include = getRelationIncludeParams(collection);\n // Walked as records, so the rows ticked off are told apart by the id the\n // view addressed them by; handed back as the rows read.\n const accessor: EntityPageAccessor<M> = {\n find: async (findParams) => {\n const page = await flat.find(include ? { ...findParams, include } : findParams);\n return {\n data: page.data.map((row) => ({ id: idOf(row, keys), path, values: row })),\n meta: page.meta\n };\n }\n };\n const excluded = new Set<string>(selection.excludedIds.map(String));\n const entities = await walkQuerySelection<M>({\n ...rest,\n query: selection.query,\n count: selection.count,\n excludedCount: selection.excludedIds.length,\n keep: (entity) => !excluded.has(String(entity.id)),\n accessor\n });\n return { rows: entities.map((entity) => entity.values), ids: entities.map((entity) => String(entity.id)) };\n}\n\nfunction idOf(row: Record<string, unknown>, keys: ReturnType<typeof resolvePrimaryKeys>): string {\n if (keys.length > 0) return buildCompositeId(row, keys);\n const id = row.id;\n return typeof id === \"string\" || typeof id === \"number\" ? String(id) : \"\";\n}\n\n/**\n * {@link resolveSelection} for the admin's own selection: the records it\n * covers, in its `Entity` view model, read through `accessor`.\n *\n * @throws When the query matches more than `maxRows` rows.\n * @internal\n */\nexport async function resolveEntitySelection<M extends Record<string, unknown>>({\n selection,\n accessor,\n pageSize = SELECTION_PAGE_SIZE,\n maxRows = MAX_SELECTION_ROWS,\n onProgress,\n signal\n}: ResolveEntitySelectionParams<M>): Promise<Entity<M>[]> {\n\n if (selection.type === \"entities\") {\n onProgress?.(selection.entities.length, selection.entities.length);\n return selection.entities;\n }\n\n const excluded = new Set(selection.excluded.map(e => `${e.path}/${e.id}`));\n return walkQuerySelection<M>({\n accessor,\n query: selection.query,\n count: selection.count,\n excludedCount: selection.excluded.length,\n keep: (e) => !excluded.has(`${e.path}/${e.id}`),\n pageSize,\n maxRows,\n onProgress,\n signal\n });\n}\n\n/**\n * Every row a query selection matches, less the ones ticked off. The ceiling\n * is on the rows left once those are out: the ticked-off rows are read with\n * the rest and dropped, so the walk may read that many past it.\n */\nasync function walkQuerySelection<M extends Record<string, unknown>>({\n accessor,\n query,\n count,\n excludedCount,\n keep,\n pageSize = SELECTION_PAGE_SIZE,\n maxRows = MAX_SELECTION_ROWS,\n onProgress,\n signal\n}: {\n accessor: EntityPageAccessor<M>;\n query: SelectionQuery<M>;\n count: number | undefined;\n excludedCount: number;\n keep: (entity: Entity<M>) => boolean;\n pageSize?: number;\n maxRows?: number;\n onProgress?: (loaded: number, total: number | undefined) => void;\n signal?: { aborted: boolean };\n}): Promise<Entity<M>[]> {\n // The count was taken when the selection was made, so it can only be a\n // forecast — but it is the one the user was shown and agreed to, and\n // refusing before the walk beats refusing forty pages in.\n if (count !== undefined && count - excludedCount > maxRows)\n throw new Error(selectionCeilingMessage(maxRows));\n\n const rows = await walkEntityPages<M>({\n accessor,\n params: selectionQueryToFindParams(query),\n pageSize,\n maxRows: maxRows + excludedCount,\n onProgress,\n signal,\n onCeiling: () => selectionCeilingMessage(maxRows)\n });\n\n if (excludedCount === 0) return rows;\n const kept = rows.filter(keep);\n if (kept.length > maxRows) throw new Error(selectionCeilingMessage(maxRows));\n return kept;\n}\n\nfunction selectionCeilingMessage(maxRows: number): string {\n return `This selection covers more than ${maxRows.toLocaleString()} rows, which is more than ` +\n \"can be acted on from the browser in one go. Filter the collection down first.\";\n}\n"],"mappings":";;;;;;;;;;AAYA,IAAa,sBAAsB;;;;;;;;;;;AAYnC,IAAa,qBAAqB;;;;;;;;;;AAWlC,SAAgB,wBAA2D,OAAkC;CACzG,MAAM,SAAS,MAAM,eACf,OAAO,KAAK,MAAM,YAAY,CAAC,CAAC,KAAK,CAAC,CACnC,KAAI,MAAK,GAAG,EAAE,GAAG,KAAK,UAAW,MAAM,aAAyC,EAAE,GAAG,CAAC,CACtF,KAAK,GAAG,IACX;CACN,MAAM,QAAQ,MAAM,QAAQ,KAAK,CAAC,OAAO,eAAe,GAAG,OAAO,KAAK,EAAE,GAAG,WAAW,CAAC,CAAC,KAAK,GAAG,KAAK;CACtG,OAAO,GAAG,MAAM,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,gBAAgB;AACrE;;AAGA,SAAgB,2BACZ,OACgD;CAOhD,OAAO;EACH,OAPU,MAAM,gBAAgB,OAAO,KAAK,MAAM,YAAY,CAAC,CAAC,SAAS,IACvE,MAAM,eACN,KAAA;EAMF,SALY,MAAM,UAAU,MAAM,OAAO,SAAS,IAChD,MAAM,OAAO,KAAK,CAAC,OAAO,eAAe,CAAC,OAAO,KAAK,GAAG,SAAS,CAAiB,IACnF,KAAA;EAIF,cAAc,MAAM;CACxB;AACJ;;;;;;;;;;;;;;;;;;;;AA2EA,eAAsB,iBAAoD,EACtE,MACA,YACA,WACA,GAAG,QACmD;CACtD,IAAI,UAAU,SAAS,QAAQ;EAC3B,KAAK,aAAa,UAAU,KAAK,QAAQ,UAAU,KAAK,MAAM;EAC9D,OAAO;GAAE,MAAM,UAAU;GAAM,KAAK,UAAU;EAAI;CACtD;CACA,MAAM,OAAO,mBAAmB,UAAU;CAC1C,MAAM,OAAO,UAAU,MAAM;CAC7B,MAAM,OAAO,KAAK,WAAc,IAAI;CAGpC,MAAM,UAAU,yBAAyB,UAAU;CAGnD,MAAM,WAAkC,EACpC,MAAM,OAAO,eAAe;EACxB,MAAM,OAAO,MAAM,KAAK,KAAK,UAAU;GAAE,GAAG;GAAY;EAAQ,IAAI,UAAU;EAC9E,OAAO;GACH,MAAM,KAAK,KAAK,KAAK,SAAS;IAAE,IAAI,KAAK,KAAK,IAAI;IAAG;IAAM,QAAQ;GAAI,EAAE;GACzE,MAAM,KAAK;EACf;CACJ,EACJ;CACA,MAAM,WAAW,IAAI,IAAY,UAAU,YAAY,IAAI,MAAM,CAAC;CAClE,MAAM,WAAW,MAAM,mBAAsB;EACzC,GAAG;EACH,OAAO,UAAU;EACjB,OAAO,UAAU;EACjB,eAAe,UAAU,YAAY;EACrC,OAAO,WAAW,CAAC,SAAS,IAAI,OAAO,OAAO,EAAE,CAAC;EACjD;CACJ,CAAC;CACD,OAAO;EAAE,MAAM,SAAS,KAAK,WAAW,OAAO,MAAM;EAAG,KAAK,SAAS,KAAK,WAAW,OAAO,OAAO,EAAE,CAAC;CAAE;AAC7G;AAEA,SAAS,KAAK,KAA8B,MAAqD;CAC7F,IAAI,KAAK,SAAS,GAAG,OAAO,iBAAiB,KAAK,IAAI;CACtD,MAAM,KAAK,IAAI;CACf,OAAO,OAAO,OAAO,YAAY,OAAO,OAAO,WAAW,OAAO,EAAE,IAAI;AAC3E;;;;;;;;AASA,eAAsB,uBAA0D,EAC5E,WACA,UACA,WAAA,KACA,UAAU,oBACV,YACA,UACsD;CAEtD,IAAI,UAAU,SAAS,YAAY;EAC/B,aAAa,UAAU,SAAS,QAAQ,UAAU,SAAS,MAAM;EACjE,OAAO,UAAU;CACrB;CAEA,MAAM,WAAW,IAAI,IAAI,UAAU,SAAS,KAAI,MAAK,GAAG,EAAE,KAAK,GAAG,EAAE,IAAI,CAAC;CACzE,OAAO,mBAAsB;EACzB;EACA,OAAO,UAAU;EACjB,OAAO,UAAU;EACjB,eAAe,UAAU,SAAS;EAClC,OAAO,MAAM,CAAC,SAAS,IAAI,GAAG,EAAE,KAAK,GAAG,EAAE,IAAI;EAC9C;EACA;EACA;EACA;CACJ,CAAC;AACL;;;;;;AAOA,eAAe,mBAAsD,EACjE,UACA,OACA,OACA,eACA,MACA,WAAA,KACA,UAAU,oBACV,YACA,UAWqB;CAIrB,IAAI,UAAU,KAAA,KAAa,QAAQ,gBAAgB,SAC/C,MAAM,IAAI,MAAM,wBAAwB,OAAO,CAAC;CAEpD,MAAM,OAAO,MAAM,gBAAmB;EAClC;EACA,QAAQ,2BAA2B,KAAK;EACxC;EACA,SAAS,UAAU;EACnB;EACA;EACA,iBAAiB,wBAAwB,OAAO;CACpD,CAAC;CAED,IAAI,kBAAkB,GAAG,OAAO;CAChC,MAAM,OAAO,KAAK,OAAO,IAAI;CAC7B,IAAI,KAAK,SAAS,SAAS,MAAM,IAAI,MAAM,wBAAwB,OAAO,CAAC;CAC3E,OAAO;AACX;AAEA,SAAS,wBAAwB,SAAyB;CACtD,OAAO,mCAAmC,QAAQ,eAAe,EAAE;AAEvE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EntityStatus } from "@rebasepro/types";
|
|
2
2
|
import { EntityCustomViewParams, AdminCollection } from "@rebasepro/cms-types";
|
|
3
3
|
import { FormContext } from "../fields.js";
|
|
4
4
|
import { FormexController } from "./formex.js";
|
|
@@ -16,18 +16,26 @@ export type EntityFormProps<M extends Record<string, unknown>> = {
|
|
|
16
16
|
* The record's id. On a new record (`initialStatus: "new"`), the id it is
|
|
17
17
|
* created under; omit it to let the data source assign one.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
id?: string | number;
|
|
20
|
+
/**
|
|
21
|
+
* The saved record, as the server sends the row — dates as ISO strings, a
|
|
22
|
+
* belongsTo as its foreign-key column. Absent for a new record.
|
|
23
|
+
*/
|
|
24
|
+
row?: Record<string, unknown>;
|
|
21
25
|
databaseId?: string;
|
|
22
26
|
onIdChange?: (id: string | number) => void;
|
|
23
27
|
onValuesModified?: (modified: boolean, values: M) => void;
|
|
24
|
-
onSaved?: (params:
|
|
28
|
+
onSaved?: (params: OnSavedParams) => void;
|
|
25
29
|
initialDirtyValues?: Partial<M>;
|
|
26
30
|
onFormContextReady?: (formContext: FormContext<M>) => void;
|
|
27
31
|
className?: string;
|
|
28
32
|
initialStatus: EntityStatus;
|
|
29
33
|
onStatusChange?: (status: EntityStatus) => void;
|
|
30
|
-
|
|
34
|
+
/** Called with the record as it now is, after each save: its row and its id. */
|
|
35
|
+
onRowChange?: (params: {
|
|
36
|
+
row: Record<string, unknown>;
|
|
37
|
+
id: string;
|
|
38
|
+
}) => void;
|
|
31
39
|
formex?: FormexController<M>;
|
|
32
40
|
openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
|
|
33
41
|
/**
|
|
@@ -54,13 +62,46 @@ export type EntityFormProps<M extends Record<string, unknown>> = {
|
|
|
54
62
|
*/
|
|
55
63
|
parentCollectionSlugs?: string[];
|
|
56
64
|
parentEntityIds?: string[];
|
|
65
|
+
/**
|
|
66
|
+
* Rendered above the fields, inside the form.
|
|
67
|
+
*/
|
|
57
68
|
children?: React.ReactNode;
|
|
58
69
|
/**
|
|
59
|
-
*
|
|
70
|
+
* The fields the generated form shows, in this order; any other property
|
|
71
|
+
* is left out. Sections and the rail keep their grouping, each holding
|
|
72
|
+
* only these fields, ordered as here. Unknown keys are ignored.
|
|
73
|
+
*
|
|
74
|
+
* The form validates only what it shows. Creating a record, it refuses —
|
|
75
|
+
* with an error naming them — when a required field it leaves out has no
|
|
76
|
+
* default value and is not filled by the server or the database.
|
|
77
|
+
*/
|
|
78
|
+
fields?: string[];
|
|
79
|
+
/**
|
|
80
|
+
* A denser form, for a side card or a 350–700px panel: no rail beside the
|
|
81
|
+
* fields (what it holds folds back into the column) and medium-height
|
|
82
|
+
* controls.
|
|
83
|
+
*/
|
|
84
|
+
compact?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Your own arrangement of the fields, rendered in place of the generated
|
|
87
|
+
* ones: `<FormField name="…"/>`s in any JSX. Wins over the collection's
|
|
88
|
+
* `formView.Builder`.
|
|
89
|
+
*
|
|
90
|
+
* The form validates only the fields its `<FormField>`s render, and
|
|
91
|
+
* refuses to create a record, as {@link fields} does, when a required
|
|
92
|
+
* field without a default is not among them.
|
|
93
|
+
*/
|
|
94
|
+
layout?: React.ReactNode;
|
|
95
|
+
/**
|
|
96
|
+
* Called on form submit with the values to save; resolves with the record
|
|
97
|
+
* as saved — its row, as the server sends it, and its id.
|
|
60
98
|
* The EntityFormBinding wrapper provides this automatically.
|
|
61
99
|
* When using EntityForm standalone, provide your own save logic.
|
|
62
100
|
*/
|
|
63
|
-
onSubmit?: (values: M, formex: FormexController<M>) => Promise<
|
|
101
|
+
onSubmit?: (values: M, formex: FormexController<M>) => Promise<{
|
|
102
|
+
row: Record<string, unknown>;
|
|
103
|
+
id: string | number;
|
|
104
|
+
} | void> | void;
|
|
64
105
|
/**
|
|
65
106
|
* Called when form values change (deferred).
|
|
66
107
|
* The EntityFormBinding wrapper uses this for entity caching.
|
|
@@ -117,11 +158,20 @@ export type EntityFormProps<M extends Record<string, unknown>> = {
|
|
|
117
158
|
*/
|
|
118
159
|
onClearLocalChanges?: () => void;
|
|
119
160
|
};
|
|
120
|
-
|
|
121
|
-
|
|
161
|
+
/**
|
|
162
|
+
* What `onSaved` is called with once a record is stored.
|
|
163
|
+
*/
|
|
164
|
+
export type OnSavedParams = {
|
|
165
|
+
/**
|
|
166
|
+
* The saved record, as the server sends the row — dates as ISO strings, a
|
|
167
|
+
* belongsTo as its foreign-key column, `id` only where the table has that column.
|
|
168
|
+
*/
|
|
169
|
+
row: Record<string, unknown>;
|
|
170
|
+
/** The saved record's id: its primary key as a string, a composite one's parts joined by `:::`. */
|
|
171
|
+
id: string;
|
|
172
|
+
/** What the record was before this save: `"new"` or `"copy"` for a record this save created. */
|
|
122
173
|
status: EntityStatus;
|
|
123
174
|
path: string;
|
|
124
|
-
entityId?: string | number;
|
|
125
175
|
selectedTab?: string;
|
|
126
176
|
collection: AdminCollection<Record<string, unknown>>;
|
|
127
177
|
};
|
package/dist/types/fields.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { InferPropertyType } from "@rebasepro/types";
|
|
2
|
-
import { Entity } from "@rebasepro/types";
|
|
3
|
-
import { FormexController } from "./components/formex.js";
|
|
4
2
|
import { Property } from "@rebasepro/types";
|
|
5
|
-
import type {
|
|
3
|
+
import type { FormContext } from "@rebasepro/cms-types";
|
|
4
|
+
export type { FormContext };
|
|
6
5
|
export type DefaultFieldConfig = "text_field" | "multiline" | "markdown" | "url" | "email" | "switch" | "select" | "multi_select" | "user_select" | "number_input" | "number_select" | "multi_number_select" | "file_upload" | "multi_file_upload" | "reference" | "multi_references" | "relation" | "date_time" | "group" | "key_value" | "repeat" | "custom_array" | "block" | "vector_input" | "geopoint" | "binary";
|
|
7
6
|
/**
|
|
8
7
|
* When building a custom field you need to create a React component that takes
|
|
@@ -118,68 +117,6 @@ export interface FieldProps<P extends Property | Property = Property, CustomProp
|
|
|
118
117
|
*/
|
|
119
118
|
onPropertyChange?: (property: Partial<Property>) => void;
|
|
120
119
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Context passed to custom fields
|
|
123
|
-
* @group Form custom fields
|
|
124
|
-
*/
|
|
125
|
-
export interface FormContext<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
126
|
-
/**
|
|
127
|
-
* Current values of the entity
|
|
128
|
-
*/
|
|
129
|
-
values: M;
|
|
130
|
-
/**
|
|
131
|
-
* Update the value of a field
|
|
132
|
-
* @param key
|
|
133
|
-
* @param value
|
|
134
|
-
* @param shouldValidate
|
|
135
|
-
*/
|
|
136
|
-
setFieldValue: (key: string, value: unknown, shouldValidate?: boolean) => void;
|
|
137
|
-
/**
|
|
138
|
-
* Quietly persist the entity to the database without any UI feedback
|
|
139
|
-
* (no validation, no snackbar, no form reset).
|
|
140
|
-
* Use this for programmatic/background saves from custom views.
|
|
141
|
-
*/
|
|
142
|
-
save: (values: M) => void;
|
|
143
|
-
/**
|
|
144
|
-
* Submit the form — validates, saves, resets the form, and shows
|
|
145
|
-
* a success snackbar. This is what the Save button calls.
|
|
146
|
-
* Use this from custom views when you want the full "user saved" experience.
|
|
147
|
-
*/
|
|
148
|
-
submit: () => void;
|
|
149
|
-
/**
|
|
150
|
-
* Collection of the entity being modified
|
|
151
|
-
*/
|
|
152
|
-
collection?: AdminCollection<M>;
|
|
153
|
-
/**
|
|
154
|
-
* Entity id, it can be undefined if it's a new entity
|
|
155
|
-
*/
|
|
156
|
-
entityId?: string | number;
|
|
157
|
-
/**
|
|
158
|
-
* Path this entity is located at
|
|
159
|
-
*/
|
|
160
|
-
path?: string;
|
|
161
|
-
status: "new" | "existing" | "copy";
|
|
162
|
-
entity?: Entity<M>;
|
|
163
|
-
savingError?: Error;
|
|
164
|
-
openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
|
|
165
|
-
/**
|
|
166
|
-
* This is the underlying formex controller that powers the form.
|
|
167
|
-
* If you are in a red only mode, the formex controller is there, but you can't
|
|
168
|
-
* operate with it
|
|
169
|
-
*/
|
|
170
|
-
formex: FormexController<M>;
|
|
171
|
-
disabled: boolean;
|
|
172
|
-
/**
|
|
173
|
-
* A save is in flight, including the autosave debounce, which `formex`
|
|
174
|
-
* cannot report because it never goes through `handleSubmit`.
|
|
175
|
-
*/
|
|
176
|
-
isSaving?: boolean;
|
|
177
|
-
/**
|
|
178
|
-
* Whether the form context is in read-only detail view mode.
|
|
179
|
-
* Custom entity views can use this to adjust their rendering.
|
|
180
|
-
*/
|
|
181
|
-
readOnly?: boolean;
|
|
182
|
-
}
|
|
183
120
|
/**
|
|
184
121
|
* In case you need to render a field bound to a Property inside your
|
|
185
122
|
* custom field you can use {@link PropertyFieldBinding} with these props.
|
|
@@ -15,11 +15,19 @@ import type { CollectionDataController } from "@rebasepro/ui";
|
|
|
15
15
|
*
|
|
16
16
|
* <CollectionView dataController={dataController} ... />
|
|
17
17
|
* ```
|
|
18
|
+
*
|
|
19
|
+
* @deprecated It feeds `CollectionView` from `@rebasepro/ui`, which is
|
|
20
|
+
* deprecated: render the collection with `CollectionPanel` instead. Will be
|
|
21
|
+
* removed in a future release.
|
|
18
22
|
*/
|
|
19
23
|
export declare function useCollectionDataController<M extends Record<string, unknown>>(tableController: EntityTableController<M>): CollectionDataController<M>;
|
|
20
24
|
/**
|
|
21
25
|
* Non-hook version for cases where you already have the data
|
|
22
26
|
* and just need to build a static controller.
|
|
27
|
+
*
|
|
28
|
+
* @deprecated It feeds `CollectionView` from `@rebasepro/ui`, which is
|
|
29
|
+
* deprecated: render the collection with `CollectionPanel` instead. Will be
|
|
30
|
+
* removed in a future release.
|
|
23
31
|
*/
|
|
24
32
|
export declare function createStaticDataController<T extends Record<string, unknown>>(data: T[], options?: {
|
|
25
33
|
loading?: boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
+
import { warnDeprecated } from "@rebasepro/common";
|
|
2
3
|
//#region src/util/dataControllerAdapter.ts
|
|
3
4
|
/**
|
|
4
5
|
* Adapts an `EntityTableController<M>` (from @rebasepro/types) to a
|
|
@@ -24,8 +25,13 @@ function flattenEntities(entities) {
|
|
|
24
25
|
*
|
|
25
26
|
* <CollectionView dataController={dataController} ... />
|
|
26
27
|
* ```
|
|
28
|
+
*
|
|
29
|
+
* @deprecated It feeds `CollectionView` from `@rebasepro/ui`, which is
|
|
30
|
+
* deprecated: render the collection with `CollectionPanel` instead. Will be
|
|
31
|
+
* removed in a future release.
|
|
27
32
|
*/
|
|
28
33
|
function useCollectionDataController(tableController) {
|
|
34
|
+
warnDeprecated("cms.useCollectionDataController", "`useCollectionDataController` is deprecated, with the `CollectionView` it feeds; render the collection with `CollectionPanel` instead.");
|
|
29
35
|
const flatData = useMemo(() => flattenEntities(tableController.data), [tableController.data]);
|
|
30
36
|
return useMemo(() => ({
|
|
31
37
|
data: flatData,
|
|
@@ -50,8 +56,13 @@ function useCollectionDataController(tableController) {
|
|
|
50
56
|
/**
|
|
51
57
|
* Non-hook version for cases where you already have the data
|
|
52
58
|
* and just need to build a static controller.
|
|
59
|
+
*
|
|
60
|
+
* @deprecated It feeds `CollectionView` from `@rebasepro/ui`, which is
|
|
61
|
+
* deprecated: render the collection with `CollectionPanel` instead. Will be
|
|
62
|
+
* removed in a future release.
|
|
53
63
|
*/
|
|
54
64
|
function createStaticDataController(data, options) {
|
|
65
|
+
warnDeprecated("cms.createStaticDataController", "`createStaticDataController` is deprecated, with the `CollectionView` it feeds; render the collection with `CollectionPanel` instead.");
|
|
55
66
|
return {
|
|
56
67
|
data,
|
|
57
68
|
loading: options?.loading ?? false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataControllerAdapter.js","names":[],"sources":["../../src/util/dataControllerAdapter.ts"],"sourcesContent":["/**\n * Adapts an `EntityTableController<M>` (from @rebasepro/types) to a\n * `CollectionDataController<T>` (from @rebasepro/ui), bridging the\n * entity-aware data layer to the headless collection view.\n */\n\nimport { useMemo } from \"react\";\nimport type { Entity } from \"@rebasepro/types\";\nimport type { EntityTableController } from \"@rebasepro/cms-types\";\nimport type { CollectionDataController } from \"@rebasepro/ui\";\n\n/**\n * Unwrap `Entity<M>` objects to flat rows for the headless view.\n * The entity system uses `{ id, path, values: M }`; `values` is already the\n * flat row `M` carrying its real primary key, so unwrapping is just `.values` —\n * no `id`/`path` merge (those are view-model metadata, not row columns).\n */\nfunction flattenEntities<M extends Record<string, unknown>>(\n entities: Entity<M>[]\n): M[] {\n return entities.map(entity => entity.values);\n}\n\n/**\n * React hook that adapts a EntityTableController to a CollectionDataController.\n *\n * Usage:\n * ```tsx\n * const tableController = useDataTableController({ path, collection });\n * const dataController = useCollectionDataController(tableController);\n *\n * <CollectionView dataController={dataController} ... />\n * ```\n */\nexport function useCollectionDataController<M extends Record<string, unknown>>(\n tableController: EntityTableController<M>\n): CollectionDataController<M> {\n const flatData = useMemo(\n () => flattenEntities(tableController.data),\n [tableController.data]\n );\n\n return useMemo((): CollectionDataController<M> => ({\n data: flatData,\n loading: tableController.dataLoading,\n noMoreToLoad: tableController.noMoreToLoad,\n error: tableController.dataLoadingError,\n\n filterValues: tableController.filterValues as Record<string, [string, unknown]> | undefined,\n setFilterValues: tableController.setFilterValues as\n ((values: Record<string, [string, unknown]> | undefined) => void) | undefined,\n\n sortBy: tableController.sortBy,\n setSortBy: tableController.setSortBy,\n\n searchString: tableController.searchString,\n setSearchString: tableController.setSearchString,\n\n clearFilter: tableController.clearFilter,\n\n initialScroll: tableController.initialScroll,\n onScroll: tableController.onScroll,\n\n paginationEnabled: tableController.paginationEnabled,\n pageSize: tableController.pageSize,\n itemCount: tableController.itemCount,\n setItemCount: tableController.setItemCount,\n }), [flatData, tableController]);\n}\n\n/**\n * Non-hook version for cases where you already have the data\n * and just need to build a static controller.\n */\nexport function createStaticDataController<T extends Record<string, unknown>>(\n data: T[],\n options?: {\n loading?: boolean;\n error?: Error;\n }\n): CollectionDataController<T> {\n return {\n data,\n loading: options?.loading ?? false,\n noMoreToLoad: true,\n error: options?.error,\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dataControllerAdapter.js","names":[],"sources":["../../src/util/dataControllerAdapter.ts"],"sourcesContent":["/**\n * Adapts an `EntityTableController<M>` (from @rebasepro/types) to a\n * `CollectionDataController<T>` (from @rebasepro/ui), bridging the\n * entity-aware data layer to the headless collection view.\n */\n\nimport { useMemo } from \"react\";\nimport type { Entity } from \"@rebasepro/types\";\nimport type { EntityTableController } from \"@rebasepro/cms-types\";\nimport type { CollectionDataController } from \"@rebasepro/ui\";\nimport { warnDeprecated } from \"@rebasepro/common\";\n\n/**\n * Unwrap `Entity<M>` objects to flat rows for the headless view.\n * The entity system uses `{ id, path, values: M }`; `values` is already the\n * flat row `M` carrying its real primary key, so unwrapping is just `.values` —\n * no `id`/`path` merge (those are view-model metadata, not row columns).\n */\nfunction flattenEntities<M extends Record<string, unknown>>(\n entities: Entity<M>[]\n): M[] {\n return entities.map(entity => entity.values);\n}\n\n/**\n * React hook that adapts a EntityTableController to a CollectionDataController.\n *\n * Usage:\n * ```tsx\n * const tableController = useDataTableController({ path, collection });\n * const dataController = useCollectionDataController(tableController);\n *\n * <CollectionView dataController={dataController} ... />\n * ```\n *\n * @deprecated It feeds `CollectionView` from `@rebasepro/ui`, which is\n * deprecated: render the collection with `CollectionPanel` instead. Will be\n * removed in a future release.\n */\nexport function useCollectionDataController<M extends Record<string, unknown>>(\n tableController: EntityTableController<M>\n): CollectionDataController<M> {\n warnDeprecated(\n \"cms.useCollectionDataController\",\n \"`useCollectionDataController` is deprecated, with the `CollectionView` it feeds; render the collection with `CollectionPanel` instead.\"\n );\n const flatData = useMemo(\n () => flattenEntities(tableController.data),\n [tableController.data]\n );\n\n return useMemo((): CollectionDataController<M> => ({\n data: flatData,\n loading: tableController.dataLoading,\n noMoreToLoad: tableController.noMoreToLoad,\n error: tableController.dataLoadingError,\n\n filterValues: tableController.filterValues as Record<string, [string, unknown]> | undefined,\n setFilterValues: tableController.setFilterValues as\n ((values: Record<string, [string, unknown]> | undefined) => void) | undefined,\n\n sortBy: tableController.sortBy,\n setSortBy: tableController.setSortBy,\n\n searchString: tableController.searchString,\n setSearchString: tableController.setSearchString,\n\n clearFilter: tableController.clearFilter,\n\n initialScroll: tableController.initialScroll,\n onScroll: tableController.onScroll,\n\n paginationEnabled: tableController.paginationEnabled,\n pageSize: tableController.pageSize,\n itemCount: tableController.itemCount,\n setItemCount: tableController.setItemCount,\n }), [flatData, tableController]);\n}\n\n/**\n * Non-hook version for cases where you already have the data\n * and just need to build a static controller.\n *\n * @deprecated It feeds `CollectionView` from `@rebasepro/ui`, which is\n * deprecated: render the collection with `CollectionPanel` instead. Will be\n * removed in a future release.\n */\nexport function createStaticDataController<T extends Record<string, unknown>>(\n data: T[],\n options?: {\n loading?: boolean;\n error?: Error;\n }\n): CollectionDataController<T> {\n warnDeprecated(\n \"cms.createStaticDataController\",\n \"`createStaticDataController` is deprecated, with the `CollectionView` it feeds; render the collection with `CollectionPanel` instead.\"\n );\n return {\n data,\n loading: options?.loading ?? false,\n noMoreToLoad: true,\n error: options?.error,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,SAAS,gBACL,UACG;CACH,OAAO,SAAS,KAAI,WAAU,OAAO,MAAM;AAC/C;;;;;;;;;;;;;;;;AAiBA,SAAgB,4BACZ,iBAC2B;CAC3B,eACI,mCACA,wIACJ;CACA,MAAM,WAAW,cACP,gBAAgB,gBAAgB,IAAI,GAC1C,CAAC,gBAAgB,IAAI,CACzB;CAEA,OAAO,eAA4C;EAC/C,MAAM;EACN,SAAS,gBAAgB;EACzB,cAAc,gBAAgB;EAC9B,OAAO,gBAAgB;EAEvB,cAAc,gBAAgB;EAC9B,iBAAiB,gBAAgB;EAGjC,QAAQ,gBAAgB;EACxB,WAAW,gBAAgB;EAE3B,cAAc,gBAAgB;EAC9B,iBAAiB,gBAAgB;EAEjC,aAAa,gBAAgB;EAE7B,eAAe,gBAAgB;EAC/B,UAAU,gBAAgB;EAE1B,mBAAmB,gBAAgB;EACnC,UAAU,gBAAgB;EAC1B,WAAW,gBAAgB;EAC3B,cAAc,gBAAgB;CAClC,IAAI,CAAC,UAAU,eAAe,CAAC;AACnC;;;;;;;;;AAUA,SAAgB,2BACZ,MACA,SAI2B;CAC3B,eACI,kCACA,uIACJ;CACA,OAAO;EACH;EACA,SAAS,SAAS,WAAW;EAC7B,cAAc;EACd,OAAO,SAAS;CACpB;AACJ"}
|
|
@@ -4,15 +4,16 @@ export { removeInitialAndTrailingSlashes, removeInitialSlash, removeTrailingSlas
|
|
|
4
4
|
* Navigate to a entity using either a side panel or full-screen mode.
|
|
5
5
|
* This is an admin-specific UI concern and lives here (not in common).
|
|
6
6
|
*/
|
|
7
|
-
export declare function navigateToEntity({ openEntityMode, collection,
|
|
7
|
+
export declare function navigateToEntity({ openEntityMode, collection, id, copy, path, selectedTab, defaultValues, sidePanelController, onClose, onSaved, navigation, replace }: {
|
|
8
8
|
openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
|
|
9
9
|
collection?: AdminCollection;
|
|
10
|
-
|
|
10
|
+
/** Id of the record to open; unset opens the form for a new record. */
|
|
11
|
+
id?: string | number;
|
|
11
12
|
selectedTab?: string;
|
|
12
13
|
copy?: boolean;
|
|
13
14
|
/**
|
|
14
15
|
* Pre-populate the new entity form with these values.
|
|
15
|
-
* Only applied when
|
|
16
|
+
* Only applied when `id` is not set (i.e. "new" mode).
|
|
16
17
|
*
|
|
17
18
|
* Side panel: passed through SidePanelBindingProps → EditViewBinding.
|
|
18
19
|
* Full screen: carried via React Router location.state so the route
|
|
@@ -27,7 +28,7 @@ export declare function navigateToEntity({ openEntityMode, collection, entityId,
|
|
|
27
28
|
* record replaces the view that opened it, and that view reads
|
|
28
29
|
* everything again when it comes back, so nothing is called there.
|
|
29
30
|
*/
|
|
30
|
-
|
|
31
|
+
onSaved?: SidePanelBindingProps["onSaved"];
|
|
31
32
|
navigation: UrlController;
|
|
32
33
|
replace?: boolean;
|
|
33
34
|
}): void;
|
|
@@ -6,24 +6,24 @@ import { addInitialSlash, getCollectionBySlugWithin, getCollectionPathsCombinati
|
|
|
6
6
|
* Navigate to a entity using either a side panel or full-screen mode.
|
|
7
7
|
* This is an admin-specific UI concern and lives here (not in common).
|
|
8
8
|
*/
|
|
9
|
-
function navigateToEntity({ openEntityMode, collection,
|
|
9
|
+
function navigateToEntity({ openEntityMode, collection, id, copy, path, selectedTab, defaultValues, sidePanelController, onClose, onSaved, navigation, replace }) {
|
|
10
10
|
const mode = navigation.routesMounted === false && openEntityMode !== "dialog" ? "side_panel" : openEntityMode;
|
|
11
11
|
if (mode === "side_panel" || mode === "dialog") sidePanelController.open({
|
|
12
|
-
|
|
12
|
+
id,
|
|
13
13
|
path,
|
|
14
14
|
copy,
|
|
15
15
|
selectedTab,
|
|
16
16
|
collection,
|
|
17
17
|
updateUrl: mode !== "dialog",
|
|
18
18
|
onClose,
|
|
19
|
-
|
|
19
|
+
onSaved,
|
|
20
20
|
defaultValues
|
|
21
21
|
});
|
|
22
22
|
else {
|
|
23
|
-
let to = navigation.buildUrlCollectionPath(hasEntityId(
|
|
24
|
-
if (hasEntityId(
|
|
23
|
+
let to = navigation.buildUrlCollectionPath(hasEntityId(id) ? `${path}/${id}` : path);
|
|
24
|
+
if (hasEntityId(id) && selectedTab) to += `/${selectedTab}`;
|
|
25
25
|
to = withListState(to);
|
|
26
|
-
if (!hasEntityId(
|
|
26
|
+
if (!hasEntityId(id)) to += "#new";
|
|
27
27
|
if (copy) to += "#copy";
|
|
28
28
|
const navigateOptions = {};
|
|
29
29
|
if (replace !== void 0) navigateOptions.replace = replace;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation_utils.js","names":[],"sources":["../../src/util/navigation_utils.ts"],"sourcesContent":["\nimport type { UrlController, SidePanelBindingProps, SidePanelController, NavigateOptions, AdminCollection } from \"@rebasepro/cms-types\";\nimport { hasEntityId } from \"@rebasepro/common\";\nimport { withListState } from \"./view_mode\";\n\n// Canonical path utilities — single source of truth in @rebasepro/common\nexport { removeInitialAndTrailingSlashes, removeInitialSlash, removeTrailingSlash, addInitialSlash, getLastSegment, resolveCollectionPathIds, getCollectionBySlugWithin, getCollectionPathsCombinations } from \"@rebasepro/app\";\n\n/**\n * Navigate to a entity using either a side panel or full-screen mode.\n * This is an admin-specific UI concern and lives here (not in common).\n */\nexport function navigateToEntity({\n openEntityMode,\n collection,\n
|
|
1
|
+
{"version":3,"file":"navigation_utils.js","names":[],"sources":["../../src/util/navigation_utils.ts"],"sourcesContent":["\nimport type { UrlController, SidePanelBindingProps, SidePanelController, NavigateOptions, AdminCollection } from \"@rebasepro/cms-types\";\nimport { hasEntityId } from \"@rebasepro/common\";\nimport { withListState } from \"./view_mode\";\n\n// Canonical path utilities — single source of truth in @rebasepro/common\nexport { removeInitialAndTrailingSlashes, removeInitialSlash, removeTrailingSlash, addInitialSlash, getLastSegment, resolveCollectionPathIds, getCollectionBySlugWithin, getCollectionPathsCombinations } from \"@rebasepro/app\";\n\n/**\n * Navigate to a entity using either a side panel or full-screen mode.\n * This is an admin-specific UI concern and lives here (not in common).\n */\nexport function navigateToEntity({\n openEntityMode,\n collection,\n id,\n copy,\n path,\n selectedTab,\n defaultValues,\n sidePanelController,\n onClose,\n onSaved,\n navigation,\n replace\n}:\n\n {\n openEntityMode?: \"side_panel\" | \"full_screen\" | \"split\" | \"dialog\";\n collection?: AdminCollection;\n /** Id of the record to open; unset opens the form for a new record. */\n id?: string | number;\n selectedTab?: string;\n copy?: boolean;\n /**\n * Pre-populate the new entity form with these values.\n * Only applied when `id` is not set (i.e. \"new\" mode).\n *\n * Side panel: passed through SidePanelBindingProps → EditViewBinding.\n * Full screen: carried via React Router location.state so the route\n * component can read it on mount without polluting the URL.\n */\n defaultValues?: Record<string, unknown>;\n path: string;\n sidePanelController: SidePanelController;\n onClose?: () => void;\n /**\n * Called when the side panel or dialog saves the record. A full-screen\n * record replaces the view that opened it, and that view reads\n * everything again when it comes back, so nothing is called there.\n */\n onSaved?: SidePanelBindingProps[\"onSaved\"];\n navigation: UrlController;\n replace?: boolean;\n }) {\n\n // No CMS route serves this page (a collection embedded in the host app's\n // own page): there is no URL to go to, so the record opens over the page.\n const mode = navigation.routesMounted === false && openEntityMode !== \"dialog\"\n ? \"side_panel\"\n : openEntityMode;\n\n if (mode === \"side_panel\" || mode === \"dialog\") {\n\n sidePanelController.open({\n id,\n path: path,\n copy,\n selectedTab,\n collection,\n updateUrl: mode !== \"dialog\",\n onClose,\n onSaved,\n defaultValues\n });\n\n } else {\n let to = navigation.buildUrlCollectionPath(hasEntityId(id) ? `${path}/${id}` : path);\n if (hasEntityId(id) && selectedTab) {\n to += `/${selectedTab}`;\n }\n // The whole list state, not just the view mode: a record opened from a\n // search must come back to that search.\n to = withListState(to);\n if (!hasEntityId(id)) {\n to += \"#new\";\n }\n if (copy) {\n to += \"#copy\";\n }\n // Use React Router location.state to carry defaultValues — the correct SPA\n // approach. No URL size limits, no encoding, nothing in the address bar.\n // EntityFullScreenRoute reads location.state.defaultValues on mount.\n const navigateOptions: NavigateOptions = {};\n if (replace !== undefined) {\n navigateOptions.replace = replace;\n }\n if (defaultValues) {\n navigateOptions.state = { defaultValues };\n }\n const hasOptions = Object.keys(navigateOptions).length > 0;\n navigation.navigate(to, hasOptions ? navigateOptions : undefined);\n }\n\n}\n\n/**\n * Whether `pathname` is the record at `entityPath` or somewhere below it — one\n * of its tabs, its `/edit`. A path segment, not a string prefix:\n * `/c/products/12` is another record, not a place inside `/c/products/1`.\n */\nexport function isPathWithinRecord(pathname: string, entityPath: string): boolean {\n return pathname === entityPath || pathname.startsWith(`${entityPath}/`);\n}\n"],"mappings":";;;;;;;;AAYA,SAAgB,iBAAiB,EAC7B,gBACA,YACA,IACA,MACA,MACA,aACA,eACA,qBACA,SACA,SACA,YACA,WA8BG;CAIH,MAAM,OAAO,WAAW,kBAAkB,SAAS,mBAAmB,WAChE,eACA;CAEN,IAAI,SAAS,gBAAgB,SAAS,UAElC,oBAAoB,KAAK;EACrB;EACM;EACN;EACA;EACA;EACA,WAAW,SAAS;EACpB;EACA;EACA;CACJ,CAAC;MAEE;EACH,IAAI,KAAK,WAAW,uBAAuB,YAAY,EAAE,IAAI,GAAG,KAAK,GAAG,OAAO,IAAI;EACnF,IAAI,YAAY,EAAE,KAAK,aACnB,MAAM,IAAI;EAId,KAAK,cAAc,EAAE;EACrB,IAAI,CAAC,YAAY,EAAE,GACf,MAAM;EAEV,IAAI,MACA,MAAM;EAKV,MAAM,kBAAmC,CAAC;EAC1C,IAAI,YAAY,KAAA,GACZ,gBAAgB,UAAU;EAE9B,IAAI,eACA,gBAAgB,QAAQ,EAAE,cAAc;EAE5C,MAAM,aAAa,OAAO,KAAK,eAAe,CAAC,CAAC,SAAS;EACzD,WAAW,SAAS,IAAI,aAAa,kBAAkB,KAAA,CAAS;CACpE;AAEJ;;;;;;AAOA,SAAgB,mBAAmB,UAAkB,YAA6B;CAC9E,OAAO,aAAa,cAAc,SAAS,WAAW,GAAG,WAAW,EAAE;AAC1E"}
|