@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","names":[],"sources":["../../../src/data_export/export/export.ts"],"sourcesContent":["import { Entity, EntityReference, EntityRelation, Properties, Property } from \"@rebasepro/types\";\nimport { type ArrayValuesCount, escapeCsvFormula, getArrayValuesCount, getValueInPath, unescapeCsvFormula } from \"@rebasepro/utils\";\n\ninterface Header {\n key: string;\n label: string;\n}\n\nexport interface DownloadEntitiesExportParams<M extends Record<string, unknown>> {\n data: Entity<M>[];\n additionalData: Record<string, unknown>[] | undefined;\n properties: Properties;\n propertiesOrder: string[] | undefined;\n name: string;\n flattenArrays: boolean;\n additionalHeaders: string[] | undefined;\n exportType: \"csv\" | \"json\";\n dateExportType: \"timestamp\" | \"string\";\n}\n\nexport function downloadEntitiesExport<M extends Record<string, unknown>>({\n data,\n additionalData,\n properties,\n propertiesOrder,\n name,\n flattenArrays,\n additionalHeaders,\n exportType,\n dateExportType\n}: DownloadEntitiesExportParams<M>\n) {\n\n console.debug(\"Downloading export\", {\n dataLength: data.length,\n properties,\n exportType,\n dateExportType\n });\n\n if (exportType === \"csv\") {\n const writer = createCsvExportWriter({\n properties,\n propertiesOrder,\n additionalHeaders,\n flattenArrays,\n dateExportType\n });\n writer.addPage(data, additionalData);\n downloadBlob(writer.finish(), `${name}.csv`, \"text/csv\");\n } else {\n const exportableData = getEntityJsonExportableData(data, additionalData, properties, dateExportType);\n const json = JSON.stringify(exportableData, null, 2);\n downloadBlob([json], `${name}.json`, \"application/json\");\n }\n}\n\nexport function getEntityCSVExportableData(data: Entity<Record<string, unknown>>[],\n additionalData: Record<string, unknown>[] | undefined,\n properties: Properties,\n headers: Header[],\n dateExportType: \"timestamp\" | \"string\"\n) {\n return mergeExportRows(data, additionalData, properties, \"csv\", dateExportType)\n .map((entry) => headers.map((header) => getValueInPath(entry, header.key)));\n}\n\nexport function getEntityJsonExportableData(data: Entity<Record<string, unknown>>[],\n additionalData: Record<string, unknown>[] | undefined,\n properties: Properties,\n dateExportType: \"timestamp\" | \"string\"\n) {\n return mergeExportRows(data, additionalData, properties, \"json\", dateExportType);\n}\n\n/**\n * Each entity as the record its export row is read from: `id`, the processed\n * values, then `additionalData[i]` over them. An `additionalData` longer than\n * `data` adds rows of its own.\n */\nfunction mergeExportRows(data: Entity<Record<string, unknown>>[],\n additionalData: Record<string, unknown>[] | undefined,\n properties: Properties,\n exportType: \"csv\" | \"json\",\n dateExportType: \"timestamp\" | \"string\"\n): Record<string, unknown>[] {\n\n const mergedData: Record<string, unknown>[] = data.map(e => ({\n id: e.id,\n ...processValuesForExport(e.values, properties, exportType, dateExportType)\n }));\n\n if (additionalData) {\n additionalData.forEach((additional, index) => {\n mergedData[index] = { ...mergedData[index],\n...additional };\n });\n }\n\n return mergedData;\n}\n\n/**\n * The columns of an export, in groups: the `id`, then one group per property\n * in `propertiesOrder`, then one per additional header. A property's group is\n * the one that becomes a column per array item (`tags[0]`, `tags[1]`, …) when\n * arrays are flattened and some row holds more than one.\n */\ninterface ExportHeaderGroup {\n /** The property's key, for a property's group. */\n key?: string;\n property?: Property;\n /** The group's columns while its array is not expanded. */\n headers: Header[];\n}\n\nfunction getExportHeaderGroups(properties: Properties,\n propertiesOrder: string[] | undefined,\n additionalHeaders: string[] | undefined): ExportHeaderGroup[] {\n\n const groups: ExportHeaderGroup[] = [{ headers: [{ label: \"id\", key: \"id\" }] }];\n for (const childKey of propertiesOrder ?? Object.keys(properties)) {\n // The first column already is the id. A collection that declares its\n // key as a property named `id` wrote it twice, and the import refuses\n // a file with a duplicate header.\n if (childKey === \"id\") continue;\n const property = properties[childKey];\n if (!property) {\n console.warn(\"Property not found\", childKey, properties);\n continue;\n }\n groups.push({ key: childKey, property: property as Property, headers: getHeaders(property as Property, childKey, \"\") });\n }\n if (additionalHeaders) {\n groups.push(...additionalHeaders.map(h => ({ headers: [{ label: h, key: h }] })));\n }\n return groups;\n}\n\n/** How many columns per item the group's array spreads into, or 0 when it does not. */\nfunction expandedItemCount(group: ExportHeaderGroup, arrayValuesCount: ArrayValuesCount): number {\n if (group.key === undefined) return 0;\n const count = arrayValuesCount[group.key];\n return count > 1 ? count : 0;\n}\n\n/** The group's columns for array item `index`. */\nfunction itemHeaders(group: ExportHeaderGroup, index: number): Header[] {\n return getHeaders(group.property as Property, `${group.key}[${index}]`, \"\");\n}\n\nfunction headersOf(groups: ExportHeaderGroup[], arrayValuesCount: ArrayValuesCount): Header[] {\n return groups.flatMap((group) => {\n const count = expandedItemCount(group, arrayValuesCount);\n return count > 0\n ? Array.from({ length: count }, (_, i) => itemHeaders(group, i)).flat()\n : group.headers;\n });\n}\n\nfunction rowCells(entry: Record<string, unknown>, headers: Header[]): string[] {\n return headers.map((header) => toCSVCell(getValueInPath(entry, header.key)));\n}\n\nexport interface CsvExportWriterParams {\n properties: Properties;\n propertiesOrder: string[] | undefined;\n additionalHeaders: string[] | undefined;\n flattenArrays: boolean;\n dateExportType: \"timestamp\" | \"string\";\n}\n\n/**\n * Writes a CSV export one page of entities at a time.\n *\n * An export used to hold every entity it read, then a copy of every row, then\n * an array of cells per row, then the row strings — about 211 MB at its peak\n * for 100,000 rows × 20 columns, for a 32 MB file. Each page is now turned\n * into its CSV text as it arrives and its entities are let go; what is held\n * is the text itself.\n *\n * The file is the one the in-memory export wrote, byte for byte. What makes\n * that work across pages is `flattenArrays`: the columns an array spreads into\n * (`tags[0]` … `tags[n-1]`) depend on the longest array in *any* row, which\n * an early page cannot know. So a page is written with the columns known when\n * it arrives, and a row also keeps the cells of any array items those columns\n * leave out. At the end, a page written with fewer columns than the file has\n * is re-cut: its cells copied, and an array's swapped for, or extended with,\n * the kept item cells (or empty ones). Usually the longest array is met in the\n * first page and nothing is re-cut. A property key with `.` or `[` in it\n * resolves through other properties when spread, so an export with one keeps\n * its rows' records and writes them at the end, as before.\n */\nexport interface CsvExportWriter {\n /** One page of entities, with their additional-column values index for index. */\n addPage(data: Entity<Record<string, unknown>>[], additionalData?: Record<string, unknown>[]): void;\n /** The whole file, header row first. Once: the pages are handed over. */\n finish(): BlobPart[];\n}\n\n/**\n * A row's cells for the items of one array that its page's columns leave out,\n * kept in case the file has columns for them. The cells of items `0…n-1` in\n * one string, for an array its page did not spread; otherwise one string per\n * item, a hole where an item is not kept or its cells are all empty.\n */\ntype RowItemCells = string | (string | undefined)[];\n\ninterface CsvExportPage {\n /** The rows, `\\r\\n` after each. */\n text: string;\n rows: number;\n /** Per group, the items its array was spread into on this page; 0 when not spread. */\n spread: number[];\n /** By `row * groups + group`, for the rows that hold items `spread` leaves out. */\n items?: (RowItemCells | undefined)[];\n /** The rows' records, when the export cannot be re-cut (see the writer). */\n entries?: Record<string, unknown>[];\n}\n\nexport function createCsvExportWriter({\n properties,\n propertiesOrder,\n additionalHeaders,\n flattenArrays,\n dateExportType\n}: CsvExportWriterParams): CsvExportWriter {\n\n const groups = getExportHeaderGroups(properties, propertiesOrder, additionalHeaders);\n // The columns of item `i` of each group, built once per item, not per row.\n const itemHeaderCache: Header[][][] = groups.map(() => []);\n const headersOfItem = (groupIndex: number, index: number): Header[] =>\n itemHeaderCache[groupIndex][index] ??= itemHeaders(groups[groupIndex], index);\n // Cells per item; a group with none (a map with no properties) spreads\n // into no columns at all.\n const itemWidths = groups.map((group, groupIndex) => group.key === undefined ? 0 : headersOfItem(groupIndex, 0).length);\n const arrayValuesCount: ArrayValuesCount = {};\n // A key the spread column's path would read through some other property.\n const keepEntries = flattenArrays && groups.some((group) => group.key !== undefined && /[.[\\]]/.test(group.key));\n const pages: CsvExportPage[] = [];\n\n return {\n addPage(data, additionalData) {\n if (flattenArrays) {\n // Merged by maximum, which is what one pass over every row\n // computes.\n for (const [key, count] of Object.entries(getArrayValuesCount(data.map(d => d.values)))) {\n arrayValuesCount[key] = Math.max(arrayValuesCount[key] || 0, count);\n }\n }\n const spread = groups.map((group) => expandedItemCount(group, arrayValuesCount));\n const entries = mergeExportRows(data, additionalData, properties, \"csv\", dateExportType);\n if (keepEntries) {\n pages.push({ text: \"\", rows: entries.length, spread, entries });\n return;\n }\n const headers = headersOf(groups, arrayValuesCount);\n const lines: string[] = [];\n let items: CsvExportPage[\"items\"];\n entries.forEach((entry, row) => {\n lines.push(rowCells(entry, headers).join(\",\") + \"\\r\\n\");\n if (!flattenArrays) return;\n const bracketed = bracketedKeyIndices(entry);\n groups.forEach((group, groupIndex) => {\n if (group.key === undefined || itemWidths[groupIndex] === 0) return;\n const written = spread[groupIndex];\n const indices = itemIndicesWithValues(entry, group.key, bracketed)\n .filter((index) => index >= written);\n if (indices.length === 0) return;\n const value = entry[group.key];\n let cells: RowItemCells;\n if (written === 0 && Array.isArray(value) && indices.length === value.length) {\n cells = value.map((_, index) => rowCells(entry, headersOfItem(groupIndex, index)).join(\",\")).join(\",\");\n } else {\n cells = [];\n for (const index of indices) {\n cells[index] = rowCells(entry, headersOfItem(groupIndex, index)).join(\",\");\n }\n }\n (items ??= [])[row * groups.length + groupIndex] = cells;\n });\n });\n pages.push({ text: lines.join(\"\"), rows: entries.length, spread, items });\n },\n\n finish() {\n const counts = flattenArrays ? arrayValuesCount : {};\n const headers = headersOf(groups, counts);\n const parts: BlobPart[] = [entryToCSVRow(headers.map(h => h.label))];\n const spread = groups.map((group) => expandedItemCount(group, counts));\n\n // Handed over a page at a time, so a re-cut page and the text it\n // was cut from are not both held for the whole file.\n for (let page = pages.shift(); page; page = pages.shift()) {\n if (page.entries) {\n parts.push(page.entries.map((entry) => rowCells(entry, headers).join(\",\") + \"\\r\\n\").join(\"\"));\n } else if (page.spread.every((count, groupIndex) => count === spread[groupIndex])) {\n parts.push(page.text);\n } else {\n parts.push(recutPage(page, groups, spread, itemWidths));\n }\n }\n return parts;\n }\n };\n}\n\n/**\n * The record's own keys spelled `key[i]…`, by `key`: `getValueInPath` reads\n * one of those for the cell `key[i]` before anything else. Almost never there.\n */\nfunction bracketedKeyIndices(entry: Record<string, unknown>): Map<string, number[]> | undefined {\n let found: Map<string, number[]> | undefined;\n for (const own of Object.keys(entry)) {\n if (!own.includes(\"[\")) continue;\n const match = /^(.*?)\\[(\\d+)\\]/.exec(own);\n if (!match) continue;\n found ??= new Map();\n const indices = found.get(match[1]) ?? [];\n indices.push(Number(match[2]));\n found.set(match[1], indices);\n }\n return found;\n}\n\nconst NO_INDICES: number[] = [];\n\n/**\n * The array items of `entry[key]` whose spread cells may not all be empty —\n * every other item's are, as `getValueInPath` reads `key[i]` and\n * `key[i].child`: an array's own items, an object's own integer-named keys\n * (read as `key[i]` too), and a key of the record spelled `key[i]…` itself.\n * Over-including is harmless; the cells are computed, not assumed.\n */\nfunction itemIndicesWithValues(entry: Record<string, unknown>,\n key: string,\n bracketed: Map<string, number[]> | undefined): number[] {\n const value = entry[key];\n const extra = bracketed?.get(key);\n if (!extra) {\n // The common cases, without building a set per cell.\n if (Array.isArray(value)) return value.map((_, i) => i);\n if (value === null || typeof value !== \"object\") return NO_INDICES;\n }\n const indices = new Set<number>();\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) indices.add(i);\n } else if (value !== null && typeof value === \"object\") {\n for (const own of Object.getOwnPropertyNames(value)) {\n const match = /^(\\d+)(?:$|[.[])/.exec(own);\n if (match) indices.add(Number(match[1]));\n }\n }\n extra?.forEach((index) => indices.add(index));\n return [...indices];\n}\n\n/**\n * A page written with fewer columns than the file has, cut back into cells\n * and written again: each array the file spreads further than the page did\n * gets its kept item cells, or empty ones.\n */\nfunction recutPage(page: CsvExportPage, groups: ExportHeaderGroup[], spread: number[], itemWidths: number[]): string {\n const text = page.text;\n const out: string[] = [];\n let pos = 0;\n for (let row = 0; row < page.rows; row++) {\n const cells: string[] = [];\n let first = true;\n groups.forEach((group, groupIndex) => {\n const written = page.spread[groupIndex];\n const itemWidth = itemWidths[groupIndex];\n const width = written > 0 ? written * itemWidth : group.headers.length;\n const groupCells: string[] = [];\n for (let c = 0; c < width; c++) {\n if (!first) pos++; // the comma before every cell but the row's first\n first = false;\n const end = csvCellEnd(text, pos);\n groupCells.push(text.slice(pos, end));\n pos = end;\n }\n const count = spread[groupIndex];\n if (count === written) {\n cells.push(...groupCells);\n return;\n }\n // Spread further than the page was: the items it wrote stay.\n if (written > 0) cells.push(...groupCells);\n const items = page.items?.[row * groups.length + groupIndex];\n const dense = typeof items === \"string\" ? splitCsvCells(items) : undefined;\n for (let i = written; i < count; i++) {\n const itemCells = dense\n ? dense.slice(i * itemWidth, (i + 1) * itemWidth)\n : (typeof items === \"object\" && items[i] !== undefined ? splitCsvCells(items[i] as string) : []);\n for (let c = 0; c < itemWidth; c++) cells.push(itemCells[c] ?? \"\");\n }\n });\n pos += 2; // \"\\r\\n\"\n out.push(cells.join(\",\") + \"\\r\\n\");\n }\n return out.join(\"\");\n}\n\n/** The cells of a run of them joined with commas, as `toCSVCell` wrote them. */\nfunction splitCsvCells(text: string): string[] {\n const cells: string[] = [];\n let pos = 0;\n for (; ;) {\n const end = csvCellEnd(text, pos);\n cells.push(text.slice(pos, end));\n if (end >= text.length) return cells;\n pos = end + 1;\n }\n}\n\n/**\n * Where the cell starting at `start` ends. Every cell `toCSVCell` writes is\n * either empty or quoted with its own quotes doubled, so the next lone quote\n * closes it.\n */\nfunction csvCellEnd(text: string, start: number): number {\n if (text.charCodeAt(start) !== 34 /* \" */) return start;\n let i = start + 1;\n for (; ;) {\n const quote = text.indexOf(\"\\\"\", i);\n if (quote < 0) return text.length;\n if (text.charCodeAt(quote + 1) === 34) {\n i = quote + 2;\n } else {\n return quote + 1;\n }\n }\n}\n\n/**\n * Get headers for property. There could be more than one header per property\n * @param property\n * @param propertyKey\n * @param prefix\n */\nfunction getHeaders(property: Property, propertyKey: string, prefix = \"\"): Header[] {\n const currentKey = prefix ? `${prefix}.${propertyKey}` : propertyKey;\n if (property.type === \"map\" && property.properties) {\n return Object.entries(property.properties)\n .map(([childKey, p]) => getHeaders(p, childKey, currentKey))\n .flat();\n } else {\n return [{\n label: currentKey,\n key: currentKey\n }];\n }\n}\n\n/**\n * Read whatever a `date` column actually arrived as into a `Date`.\n *\n * The driver/WebSocket path revives `{ __type: \"date\" }` into a `Date`; the REST\n * path — which is the one the admin is on — leaves an ISO string, and an epoch\n * number is what a re-imported export carries. Returns `undefined` for anything\n * that is not a date, so the caller can pass the raw value through.\n */\nfunction toExportableDate(inputValue: unknown): Date | undefined {\n if (inputValue instanceof Date) return Number.isNaN(inputValue.getTime()) ? undefined : inputValue;\n if (typeof inputValue === \"number\" && Number.isFinite(inputValue)) return new Date(inputValue);\n if (typeof inputValue === \"string\" && inputValue.trim() !== \"\") {\n const parsed = new Date(inputValue);\n return Number.isNaN(parsed.getTime()) ? undefined : parsed;\n }\n return undefined;\n}\n\n/**\n * The id a relation value points at, for a relation property's value — an\n * `EntityRelation`, or the same thing still in its `{ __type: \"relation\" }`\n * wire form. `undefined` for anything else, so a bare foreign key passes\n * through as the id it already is.\n */\nfunction relationIdForExport(value: unknown): string | number | undefined {\n if (value instanceof EntityRelation) return value.id;\n if (typeof value === \"object\" && value !== null\n && \"__type\" in value && value.__type === \"relation\"\n && \"id\" in value && (typeof value.id === \"string\" || typeof value.id === \"number\")) {\n return value.id;\n }\n return undefined;\n}\n\nfunction processValueForExport(inputValue: unknown,\n property: Property,\n exportType: \"csv\" | \"json\",\n dateExportType: \"timestamp\" | \"string\"\n): unknown {\n\n let value: unknown;\n if (property.type === \"relation\") {\n // A relation is exported as the id it points at — what the import\n // writes back — rather than the view-model object the admin holds,\n // which a CSV cell printed as `[object Object]`. To-many relations\n // are arrays of them.\n const toId = (item: unknown) => relationIdForExport(item) ?? item;\n value = Array.isArray(inputValue) ? inputValue.map(toId) : toId(inputValue);\n } else if (property.type === \"map\" && property.properties) {\n // A map with no value is exported as none: read through, a `null` map\n // came out as an object of `null` fields.\n value = inputValue !== null && typeof inputValue === \"object\" && !Array.isArray(inputValue)\n ? processValuesForExport(inputValue as Record<string, unknown>, property.properties as Properties, exportType, dateExportType)\n : inputValue;\n } else if (property.type === \"array\") {\n if (property.of && Array.isArray(inputValue)) {\n if (Array.isArray(property.of)) {\n value = property.of.map((p, i) => processValueForExport(inputValue[i], p, exportType, dateExportType));\n } else if (property.of.type === \"map\") {\n value = exportType === \"csv\"\n ? inputValue.map((e) => JSON.stringify(e))\n : inputValue.map((e) => processValueForExport(e, property.of as Property, exportType, dateExportType));\n ;\n } else {\n value = inputValue.map((e) => processValueForExport(e, property.of as Property, exportType, dateExportType));\n }\n } else {\n value = inputValue;\n }\n } else if (property.type === \"reference\" && inputValue && typeof inputValue === \"object\" && \"isEntityReference\" in inputValue && typeof (inputValue as EntityReference).isEntityReference === \"function\" && (inputValue as EntityReference).isEntityReference()) {\n const ref = inputValue ? inputValue as EntityReference : undefined;\n value = ref ? ref.fullPath : null;\n } else if (property.type === \"date\") {\n // Not `instanceof Date`: the admin reads over REST, and the REST row\n // pipeline hands dates back as the database wrote them — a string. That\n // made this branch dead on every live export, so both radio options\n // produced identical files. Normalise here, where the declared type says\n // the column is a date, and leave anything unparseable untouched rather\n // than exporting an invalid date as `null`.\n const date = toExportableDate(inputValue);\n value = date\n ? (dateExportType === \"timestamp\" ? date.getTime() : date.toISOString())\n : inputValue;\n } else {\n value = inputValue;\n }\n\n return value;\n}\n\nfunction processValuesForExport<M extends Record<string, unknown>>\n (inputValues: Record<string, unknown>,\n properties: Properties,\n exportType: \"csv\" | \"json\",\n dateExportType: \"timestamp\" | \"string\"\n ): Record<string, unknown> {\n // One accumulator. Merging `{ [key]: value }` objects pairwise copied the\n // whole row once per property — the square of the property count, per row.\n const result: Record<string, unknown> = { ...inputValues };\n for (const [key, property] of Object.entries(properties)) {\n const inputValue = inputValues && (inputValues)[key];\n const updatedValue = processValueForExport(inputValue, property as Property, exportType, dateExportType);\n if (updatedValue === undefined) continue;\n if (key === \"__proto__\") {\n // An own property, as the object spread made it, not the prototype.\n Object.defineProperty(result, key, { value: updatedValue, enumerable: true, writable: true, configurable: true });\n } else {\n result[key] = updatedValue;\n }\n }\n return result;\n}\n\n// One rule for every CSV the product writes — here, the SQL console's export\n// and the server's streamed download: `@rebasepro/utils`' csv helpers.\nexport { escapeCsvFormula, unescapeCsvFormula };\n\nfunction toCSVCell(v: unknown): string {\n if (v === null || v === undefined) return \"\";\n // An array or object (a geopoint, a value no property declares) is written\n // as its JSON: `String()` of an object is `[object Object]`. Date\n // properties are normalised before they get here.\n const s = Array.isArray(v) || (typeof v === \"object\" && !(v instanceof Date))\n ? JSON.stringify(v)\n : String(v);\n return \"\\\"\" + escapeCsvFormula(s).replaceAll(\"\\\"\", \"\\\"\\\"\") + \"\\\"\";\n}\n\nexport function entryToCSVRow(entry: unknown[]) {\n return entry\n .map(toCSVCell)\n .join(\",\") + \"\\r\\n\";\n}\n\nexport function downloadBlob(content: BlobPart[], filename: string, contentType: string) {\n const blob = new Blob(content, { type: contentType });\n const url = URL.createObjectURL(blob);\n const pom = document.createElement(\"a\");\n pom.href = url;\n pom.setAttribute(\"download\", filename);\n pom.click();\n // Unrevoked, the URL kept the whole file in memory until the tab closed —\n // one more copy per export. The download holds its own reference once it\n // has started; the delay covers browsers that start it a moment after\n // `click()` returns.\n setTimeout(() => URL.revokeObjectURL(url), BLOB_URL_LIFETIME_MS);\n}\n\n/** How long an export's object URL outlives the click that downloads it. */\nconst BLOB_URL_LIFETIME_MS = 10_000;\n\nexport function downloadDataAsCsv(data: object[], name: string) {\n if (data.length === 0) return;\n\n // Every key any row holds, in the order they are first met; the header\n // row is written through the same cell escaping as the values.\n const headers = [...new Set(data.flatMap(row => Object.keys(row)))];\n const csvContent = [\n headers.map(toCSVCell).join(\",\"),\n ...data.map(row => headers.map(header => toCSVCell((row as Record<string, unknown>)[header])).join(\",\"))\n ].join(\"\\r\\n\");\n\n downloadBlob([csvContent], `${name}.csv`, \"text/csv\");\n}\n"],"mappings":";;;AAoBA,SAAgB,uBAA0D,EACtE,MACA,gBACA,YACA,iBACA,MACA,eACA,mBACA,YACA,kBAEF;CAEE,QAAQ,MAAM,sBAAsB;EAChC,YAAY,KAAK;EACjB;EACA;EACA;CACJ,CAAC;CAED,IAAI,eAAe,OAAO;EACtB,MAAM,SAAS,sBAAsB;GACjC;GACA;GACA;GACA;GACA;EACJ,CAAC;EACD,OAAO,QAAQ,MAAM,cAAc;EACnC,aAAa,OAAO,OAAO,GAAG,GAAG,KAAK,OAAO,UAAU;CAC3D,OAAO;EACH,MAAM,iBAAiB,4BAA4B,MAAM,gBAAgB,YAAY,cAAc;EAEnG,aAAa,CADA,KAAK,UAAU,gBAAgB,MAAM,CACpC,CAAI,GAAG,GAAG,KAAK,QAAQ,kBAAkB;CAC3D;AACJ;AAEA,SAAgB,2BAA2B,MACvC,gBACA,YACA,SACA,gBACF;CACE,OAAO,gBAAgB,MA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C,WAAW,MAAM,MAAM,IAAI;AACjE;AAEA,SAAgB,cAAc,OAAkB;CAC5C,OAAO,MACF,IAAI,SAAS,CAAC,CACd,KAAK,GAAG,IAAI;AACrB;AAEA,SAAgB,aAAa,SAAqB,UAAkB,aAAqB;CACrF,MAAM,OAAO,IAAI,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;CACpD,MAAM,MAAM,IAAI,gBAAgB,IAAI;CACpC,MAAM,MAAM,SAAS,cAAc,GAAG;CACtC,IAAI,OAAO;CACX,IAAI,aAAa,YAAY,QAAQ;CACrC,IAAI,MAAM;CAKV,iBAAiB,IAAI,gBAAgB,GAAG,GAAG,oBAAoB;AACnE;;AAGA,IAAM,uBAAuB;AAE7B,SAAgB,kBAAkB,MAAgB,MAAc;CAC5D,IAAI,KAAK,WAAW,GAAG;CAIvB,MAAM,UAAU,CAAC,GAAG,IAAI,IAAI,KAAK,SAAQ,QAAO,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC;CAMlE,aAAa,CALM,CACf,QAAQ,IAAI,SAAS,CAAC,CAAC,KAAK,GAAG,GAC/B,GAAG,KAAK,KAAI,QAAO,QAAQ,KAAI,WAAU,UAAW,IAAgC,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAC3G,CAAC,CAAC,KAAK,MAEO,CAAU,GAAG,GAAG,KAAK,OAAO,UAAU;AACxD"}
|
|
1
|
+
{"version":3,"file":"export.js","names":[],"sources":["../../../src/data_export/export/export.ts"],"sourcesContent":["import { Properties, Property, EntityReference, EntityRelation, Entity } from \"@rebasepro/cms-types\";\nimport { type ArrayValuesCount, escapeCsvFormula, getArrayValuesCount, getValueInPath, unescapeCsvFormula } from \"@rebasepro/utils\";\n\ninterface Header {\n key: string;\n label: string;\n}\n\nexport interface DownloadEntitiesExportParams<M extends Record<string, unknown>> {\n data: Entity<M>[];\n additionalData: Record<string, unknown>[] | undefined;\n properties: Properties;\n propertiesOrder: string[] | undefined;\n name: string;\n flattenArrays: boolean;\n additionalHeaders: string[] | undefined;\n exportType: \"csv\" | \"json\";\n dateExportType: \"timestamp\" | \"string\";\n}\n\nexport function downloadEntitiesExport<M extends Record<string, unknown>>({\n data,\n additionalData,\n properties,\n propertiesOrder,\n name,\n flattenArrays,\n additionalHeaders,\n exportType,\n dateExportType\n}: DownloadEntitiesExportParams<M>\n) {\n\n console.debug(\"Downloading export\", {\n dataLength: data.length,\n properties,\n exportType,\n dateExportType\n });\n\n if (exportType === \"csv\") {\n const writer = createCsvExportWriter({\n properties,\n propertiesOrder,\n additionalHeaders,\n flattenArrays,\n dateExportType\n });\n writer.addPage(data, additionalData);\n downloadBlob(writer.finish(), `${name}.csv`, \"text/csv\");\n } else {\n const exportableData = getEntityJsonExportableData(data, additionalData, properties, dateExportType);\n const json = JSON.stringify(exportableData, null, 2);\n downloadBlob([json], `${name}.json`, \"application/json\");\n }\n}\n\nexport function getEntityCSVExportableData(data: Entity<Record<string, unknown>>[],\n additionalData: Record<string, unknown>[] | undefined,\n properties: Properties,\n headers: Header[],\n dateExportType: \"timestamp\" | \"string\"\n) {\n return mergeExportRows(data, additionalData, properties, \"csv\", dateExportType)\n .map((entry) => headers.map((header) => getValueInPath(entry, header.key)));\n}\n\nexport function getEntityJsonExportableData(data: Entity<Record<string, unknown>>[],\n additionalData: Record<string, unknown>[] | undefined,\n properties: Properties,\n dateExportType: \"timestamp\" | \"string\"\n) {\n return mergeExportRows(data, additionalData, properties, \"json\", dateExportType);\n}\n\n/**\n * Each entity as the record its export row is read from: `id`, the processed\n * values, then `additionalData[i]` over them. An `additionalData` longer than\n * `data` adds rows of its own.\n */\nfunction mergeExportRows(data: Entity<Record<string, unknown>>[],\n additionalData: Record<string, unknown>[] | undefined,\n properties: Properties,\n exportType: \"csv\" | \"json\",\n dateExportType: \"timestamp\" | \"string\"\n): Record<string, unknown>[] {\n\n const mergedData: Record<string, unknown>[] = data.map(e => ({\n id: e.id,\n ...processValuesForExport(e.values, properties, exportType, dateExportType)\n }));\n\n if (additionalData) {\n additionalData.forEach((additional, index) => {\n mergedData[index] = { ...mergedData[index],\n...additional };\n });\n }\n\n return mergedData;\n}\n\n/**\n * The columns of an export, in groups: the `id`, then one group per property\n * in `propertiesOrder`, then one per additional header. A property's group is\n * the one that becomes a column per array item (`tags[0]`, `tags[1]`, …) when\n * arrays are flattened and some row holds more than one.\n */\ninterface ExportHeaderGroup {\n /** The property's key, for a property's group. */\n key?: string;\n property?: Property;\n /** The group's columns while its array is not expanded. */\n headers: Header[];\n}\n\nfunction getExportHeaderGroups(properties: Properties,\n propertiesOrder: string[] | undefined,\n additionalHeaders: string[] | undefined): ExportHeaderGroup[] {\n\n const groups: ExportHeaderGroup[] = [{ headers: [{ label: \"id\", key: \"id\" }] }];\n for (const childKey of propertiesOrder ?? Object.keys(properties)) {\n // The first column already is the id. A collection that declares its\n // key as a property named `id` wrote it twice, and the import refuses\n // a file with a duplicate header.\n if (childKey === \"id\") continue;\n const property = properties[childKey];\n if (!property) {\n console.warn(\"Property not found\", childKey, properties);\n continue;\n }\n groups.push({ key: childKey, property: property as Property, headers: getHeaders(property as Property, childKey, \"\") });\n }\n if (additionalHeaders) {\n groups.push(...additionalHeaders.map(h => ({ headers: [{ label: h, key: h }] })));\n }\n return groups;\n}\n\n/** How many columns per item the group's array spreads into, or 0 when it does not. */\nfunction expandedItemCount(group: ExportHeaderGroup, arrayValuesCount: ArrayValuesCount): number {\n if (group.key === undefined) return 0;\n const count = arrayValuesCount[group.key];\n return count > 1 ? count : 0;\n}\n\n/** The group's columns for array item `index`. */\nfunction itemHeaders(group: ExportHeaderGroup, index: number): Header[] {\n return getHeaders(group.property as Property, `${group.key}[${index}]`, \"\");\n}\n\nfunction headersOf(groups: ExportHeaderGroup[], arrayValuesCount: ArrayValuesCount): Header[] {\n return groups.flatMap((group) => {\n const count = expandedItemCount(group, arrayValuesCount);\n return count > 0\n ? Array.from({ length: count }, (_, i) => itemHeaders(group, i)).flat()\n : group.headers;\n });\n}\n\nfunction rowCells(entry: Record<string, unknown>, headers: Header[]): string[] {\n return headers.map((header) => toCSVCell(getValueInPath(entry, header.key)));\n}\n\nexport interface CsvExportWriterParams {\n properties: Properties;\n propertiesOrder: string[] | undefined;\n additionalHeaders: string[] | undefined;\n flattenArrays: boolean;\n dateExportType: \"timestamp\" | \"string\";\n}\n\n/**\n * Writes a CSV export one page of entities at a time.\n *\n * An export used to hold every entity it read, then a copy of every row, then\n * an array of cells per row, then the row strings — about 211 MB at its peak\n * for 100,000 rows × 20 columns, for a 32 MB file. Each page is now turned\n * into its CSV text as it arrives and its entities are let go; what is held\n * is the text itself.\n *\n * The file is the one the in-memory export wrote, byte for byte. What makes\n * that work across pages is `flattenArrays`: the columns an array spreads into\n * (`tags[0]` … `tags[n-1]`) depend on the longest array in *any* row, which\n * an early page cannot know. So a page is written with the columns known when\n * it arrives, and a row also keeps the cells of any array items those columns\n * leave out. At the end, a page written with fewer columns than the file has\n * is re-cut: its cells copied, and an array's swapped for, or extended with,\n * the kept item cells (or empty ones). Usually the longest array is met in the\n * first page and nothing is re-cut. A property key with `.` or `[` in it\n * resolves through other properties when spread, so an export with one keeps\n * its rows' records and writes them at the end, as before.\n */\nexport interface CsvExportWriter {\n /** One page of entities, with their additional-column values index for index. */\n addPage(data: Entity<Record<string, unknown>>[], additionalData?: Record<string, unknown>[]): void;\n /** The whole file, header row first. Once: the pages are handed over. */\n finish(): BlobPart[];\n}\n\n/**\n * A row's cells for the items of one array that its page's columns leave out,\n * kept in case the file has columns for them. The cells of items `0…n-1` in\n * one string, for an array its page did not spread; otherwise one string per\n * item, a hole where an item is not kept or its cells are all empty.\n */\ntype RowItemCells = string | (string | undefined)[];\n\ninterface CsvExportPage {\n /** The rows, `\\r\\n` after each. */\n text: string;\n rows: number;\n /** Per group, the items its array was spread into on this page; 0 when not spread. */\n spread: number[];\n /** By `row * groups + group`, for the rows that hold items `spread` leaves out. */\n items?: (RowItemCells | undefined)[];\n /** The rows' records, when the export cannot be re-cut (see the writer). */\n entries?: Record<string, unknown>[];\n}\n\nexport function createCsvExportWriter({\n properties,\n propertiesOrder,\n additionalHeaders,\n flattenArrays,\n dateExportType\n}: CsvExportWriterParams): CsvExportWriter {\n\n const groups = getExportHeaderGroups(properties, propertiesOrder, additionalHeaders);\n // The columns of item `i` of each group, built once per item, not per row.\n const itemHeaderCache: Header[][][] = groups.map(() => []);\n const headersOfItem = (groupIndex: number, index: number): Header[] =>\n itemHeaderCache[groupIndex][index] ??= itemHeaders(groups[groupIndex], index);\n // Cells per item; a group with none (a map with no properties) spreads\n // into no columns at all.\n const itemWidths = groups.map((group, groupIndex) => group.key === undefined ? 0 : headersOfItem(groupIndex, 0).length);\n const arrayValuesCount: ArrayValuesCount = {};\n // A key the spread column's path would read through some other property.\n const keepEntries = flattenArrays && groups.some((group) => group.key !== undefined && /[.[\\]]/.test(group.key));\n const pages: CsvExportPage[] = [];\n\n return {\n addPage(data, additionalData) {\n if (flattenArrays) {\n // Merged by maximum, which is what one pass over every row\n // computes.\n for (const [key, count] of Object.entries(getArrayValuesCount(data.map(d => d.values)))) {\n arrayValuesCount[key] = Math.max(arrayValuesCount[key] || 0, count);\n }\n }\n const spread = groups.map((group) => expandedItemCount(group, arrayValuesCount));\n const entries = mergeExportRows(data, additionalData, properties, \"csv\", dateExportType);\n if (keepEntries) {\n pages.push({ text: \"\", rows: entries.length, spread, entries });\n return;\n }\n const headers = headersOf(groups, arrayValuesCount);\n const lines: string[] = [];\n let items: CsvExportPage[\"items\"];\n entries.forEach((entry, row) => {\n lines.push(rowCells(entry, headers).join(\",\") + \"\\r\\n\");\n if (!flattenArrays) return;\n const bracketed = bracketedKeyIndices(entry);\n groups.forEach((group, groupIndex) => {\n if (group.key === undefined || itemWidths[groupIndex] === 0) return;\n const written = spread[groupIndex];\n const indices = itemIndicesWithValues(entry, group.key, bracketed)\n .filter((index) => index >= written);\n if (indices.length === 0) return;\n const value = entry[group.key];\n let cells: RowItemCells;\n if (written === 0 && Array.isArray(value) && indices.length === value.length) {\n cells = value.map((_, index) => rowCells(entry, headersOfItem(groupIndex, index)).join(\",\")).join(\",\");\n } else {\n cells = [];\n for (const index of indices) {\n cells[index] = rowCells(entry, headersOfItem(groupIndex, index)).join(\",\");\n }\n }\n (items ??= [])[row * groups.length + groupIndex] = cells;\n });\n });\n pages.push({ text: lines.join(\"\"), rows: entries.length, spread, items });\n },\n\n finish() {\n const counts = flattenArrays ? arrayValuesCount : {};\n const headers = headersOf(groups, counts);\n const parts: BlobPart[] = [entryToCSVRow(headers.map(h => h.label))];\n const spread = groups.map((group) => expandedItemCount(group, counts));\n\n // Handed over a page at a time, so a re-cut page and the text it\n // was cut from are not both held for the whole file.\n for (let page = pages.shift(); page; page = pages.shift()) {\n if (page.entries) {\n parts.push(page.entries.map((entry) => rowCells(entry, headers).join(\",\") + \"\\r\\n\").join(\"\"));\n } else if (page.spread.every((count, groupIndex) => count === spread[groupIndex])) {\n parts.push(page.text);\n } else {\n parts.push(recutPage(page, groups, spread, itemWidths));\n }\n }\n return parts;\n }\n };\n}\n\n/**\n * The record's own keys spelled `key[i]…`, by `key`: `getValueInPath` reads\n * one of those for the cell `key[i]` before anything else. Almost never there.\n */\nfunction bracketedKeyIndices(entry: Record<string, unknown>): Map<string, number[]> | undefined {\n let found: Map<string, number[]> | undefined;\n for (const own of Object.keys(entry)) {\n if (!own.includes(\"[\")) continue;\n const match = /^(.*?)\\[(\\d+)\\]/.exec(own);\n if (!match) continue;\n found ??= new Map();\n const indices = found.get(match[1]) ?? [];\n indices.push(Number(match[2]));\n found.set(match[1], indices);\n }\n return found;\n}\n\nconst NO_INDICES: number[] = [];\n\n/**\n * The array items of `entry[key]` whose spread cells may not all be empty —\n * every other item's are, as `getValueInPath` reads `key[i]` and\n * `key[i].child`: an array's own items, an object's own integer-named keys\n * (read as `key[i]` too), and a key of the record spelled `key[i]…` itself.\n * Over-including is harmless; the cells are computed, not assumed.\n */\nfunction itemIndicesWithValues(entry: Record<string, unknown>,\n key: string,\n bracketed: Map<string, number[]> | undefined): number[] {\n const value = entry[key];\n const extra = bracketed?.get(key);\n if (!extra) {\n // The common cases, without building a set per cell.\n if (Array.isArray(value)) return value.map((_, i) => i);\n if (value === null || typeof value !== \"object\") return NO_INDICES;\n }\n const indices = new Set<number>();\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) indices.add(i);\n } else if (value !== null && typeof value === \"object\") {\n for (const own of Object.getOwnPropertyNames(value)) {\n const match = /^(\\d+)(?:$|[.[])/.exec(own);\n if (match) indices.add(Number(match[1]));\n }\n }\n extra?.forEach((index) => indices.add(index));\n return [...indices];\n}\n\n/**\n * A page written with fewer columns than the file has, cut back into cells\n * and written again: each array the file spreads further than the page did\n * gets its kept item cells, or empty ones.\n */\nfunction recutPage(page: CsvExportPage, groups: ExportHeaderGroup[], spread: number[], itemWidths: number[]): string {\n const text = page.text;\n const out: string[] = [];\n let pos = 0;\n for (let row = 0; row < page.rows; row++) {\n const cells: string[] = [];\n let first = true;\n groups.forEach((group, groupIndex) => {\n const written = page.spread[groupIndex];\n const itemWidth = itemWidths[groupIndex];\n const width = written > 0 ? written * itemWidth : group.headers.length;\n const groupCells: string[] = [];\n for (let c = 0; c < width; c++) {\n if (!first) pos++; // the comma before every cell but the row's first\n first = false;\n const end = csvCellEnd(text, pos);\n groupCells.push(text.slice(pos, end));\n pos = end;\n }\n const count = spread[groupIndex];\n if (count === written) {\n cells.push(...groupCells);\n return;\n }\n // Spread further than the page was: the items it wrote stay.\n if (written > 0) cells.push(...groupCells);\n const items = page.items?.[row * groups.length + groupIndex];\n const dense = typeof items === \"string\" ? splitCsvCells(items) : undefined;\n for (let i = written; i < count; i++) {\n const itemCells = dense\n ? dense.slice(i * itemWidth, (i + 1) * itemWidth)\n : (typeof items === \"object\" && items[i] !== undefined ? splitCsvCells(items[i] as string) : []);\n for (let c = 0; c < itemWidth; c++) cells.push(itemCells[c] ?? \"\");\n }\n });\n pos += 2; // \"\\r\\n\"\n out.push(cells.join(\",\") + \"\\r\\n\");\n }\n return out.join(\"\");\n}\n\n/** The cells of a run of them joined with commas, as `toCSVCell` wrote them. */\nfunction splitCsvCells(text: string): string[] {\n const cells: string[] = [];\n let pos = 0;\n for (; ;) {\n const end = csvCellEnd(text, pos);\n cells.push(text.slice(pos, end));\n if (end >= text.length) return cells;\n pos = end + 1;\n }\n}\n\n/**\n * Where the cell starting at `start` ends. Every cell `toCSVCell` writes is\n * either empty or quoted with its own quotes doubled, so the next lone quote\n * closes it.\n */\nfunction csvCellEnd(text: string, start: number): number {\n if (text.charCodeAt(start) !== 34 /* \" */) return start;\n let i = start + 1;\n for (; ;) {\n const quote = text.indexOf(\"\\\"\", i);\n if (quote < 0) return text.length;\n if (text.charCodeAt(quote + 1) === 34) {\n i = quote + 2;\n } else {\n return quote + 1;\n }\n }\n}\n\n/**\n * Get headers for property. There could be more than one header per property\n * @param property\n * @param propertyKey\n * @param prefix\n */\nfunction getHeaders(property: Property, propertyKey: string, prefix = \"\"): Header[] {\n const currentKey = prefix ? `${prefix}.${propertyKey}` : propertyKey;\n if (property.type === \"map\" && property.properties) {\n return Object.entries(property.properties)\n .map(([childKey, p]) => getHeaders(p, childKey, currentKey))\n .flat();\n } else {\n return [{\n label: currentKey,\n key: currentKey\n }];\n }\n}\n\n/**\n * Read whatever a `date` column actually arrived as into a `Date`.\n *\n * The driver/WebSocket path revives `{ __type: \"date\" }` into a `Date`; the REST\n * path — which is the one the admin is on — leaves an ISO string, and an epoch\n * number is what a re-imported export carries. Returns `undefined` for anything\n * that is not a date, so the caller can pass the raw value through.\n */\nfunction toExportableDate(inputValue: unknown): Date | undefined {\n if (inputValue instanceof Date) return Number.isNaN(inputValue.getTime()) ? undefined : inputValue;\n if (typeof inputValue === \"number\" && Number.isFinite(inputValue)) return new Date(inputValue);\n if (typeof inputValue === \"string\" && inputValue.trim() !== \"\") {\n const parsed = new Date(inputValue);\n return Number.isNaN(parsed.getTime()) ? undefined : parsed;\n }\n return undefined;\n}\n\n/**\n * The id a relation value points at, for a relation property's value — an\n * `EntityRelation`, or the same thing still in its `{ __type: \"relation\" }`\n * wire form. `undefined` for anything else, so a bare foreign key passes\n * through as the id it already is.\n */\nfunction relationIdForExport(value: unknown): string | number | undefined {\n if (value instanceof EntityRelation) return value.id;\n if (typeof value === \"object\" && value !== null\n && \"__type\" in value && value.__type === \"relation\"\n && \"id\" in value && (typeof value.id === \"string\" || typeof value.id === \"number\")) {\n return value.id;\n }\n return undefined;\n}\n\nfunction processValueForExport(inputValue: unknown,\n property: Property,\n exportType: \"csv\" | \"json\",\n dateExportType: \"timestamp\" | \"string\"\n): unknown {\n\n let value: unknown;\n if (property.type === \"relation\") {\n // A relation is exported as the id it points at — what the import\n // writes back — rather than the view-model object the admin holds,\n // which a CSV cell printed as `[object Object]`. To-many relations\n // are arrays of them.\n const toId = (item: unknown) => relationIdForExport(item) ?? item;\n value = Array.isArray(inputValue) ? inputValue.map(toId) : toId(inputValue);\n } else if (property.type === \"map\" && property.properties) {\n // A map with no value is exported as none: read through, a `null` map\n // came out as an object of `null` fields.\n value = inputValue !== null && typeof inputValue === \"object\" && !Array.isArray(inputValue)\n ? processValuesForExport(inputValue as Record<string, unknown>, property.properties as Properties, exportType, dateExportType)\n : inputValue;\n } else if (property.type === \"array\") {\n if (property.of && Array.isArray(inputValue)) {\n if (Array.isArray(property.of)) {\n value = property.of.map((p, i) => processValueForExport(inputValue[i], p, exportType, dateExportType));\n } else if (property.of.type === \"map\") {\n value = exportType === \"csv\"\n ? inputValue.map((e) => JSON.stringify(e))\n : inputValue.map((e) => processValueForExport(e, property.of as Property, exportType, dateExportType));\n ;\n } else {\n value = inputValue.map((e) => processValueForExport(e, property.of as Property, exportType, dateExportType));\n }\n } else {\n value = inputValue;\n }\n } else if (property.type === \"reference\" && inputValue && typeof inputValue === \"object\" && \"isEntityReference\" in inputValue && typeof (inputValue as EntityReference).isEntityReference === \"function\" && (inputValue as EntityReference).isEntityReference()) {\n const ref = inputValue ? inputValue as EntityReference : undefined;\n value = ref ? ref.fullPath : null;\n } else if (property.type === \"date\") {\n // Not `instanceof Date`: the admin reads over REST, and the REST row\n // pipeline hands dates back as the database wrote them — a string. That\n // made this branch dead on every live export, so both radio options\n // produced identical files. Normalise here, where the declared type says\n // the column is a date, and leave anything unparseable untouched rather\n // than exporting an invalid date as `null`.\n const date = toExportableDate(inputValue);\n value = date\n ? (dateExportType === \"timestamp\" ? date.getTime() : date.toISOString())\n : inputValue;\n } else {\n value = inputValue;\n }\n\n return value;\n}\n\nfunction processValuesForExport<M extends Record<string, unknown>>\n (inputValues: Record<string, unknown>,\n properties: Properties,\n exportType: \"csv\" | \"json\",\n dateExportType: \"timestamp\" | \"string\"\n ): Record<string, unknown> {\n // One accumulator. Merging `{ [key]: value }` objects pairwise copied the\n // whole row once per property — the square of the property count, per row.\n const result: Record<string, unknown> = { ...inputValues };\n for (const [key, property] of Object.entries(properties)) {\n const inputValue = inputValues && (inputValues)[key];\n const updatedValue = processValueForExport(inputValue, property as Property, exportType, dateExportType);\n if (updatedValue === undefined) continue;\n if (key === \"__proto__\") {\n // An own property, as the object spread made it, not the prototype.\n Object.defineProperty(result, key, { value: updatedValue, enumerable: true, writable: true, configurable: true });\n } else {\n result[key] = updatedValue;\n }\n }\n return result;\n}\n\n// One rule for every CSV the product writes — here, the SQL console's export\n// and the server's streamed download: `@rebasepro/utils`' csv helpers.\nexport { escapeCsvFormula, unescapeCsvFormula };\n\nfunction toCSVCell(v: unknown): string {\n if (v === null || v === undefined) return \"\";\n // An array or object (a geopoint, a value no property declares) is written\n // as its JSON: `String()` of an object is `[object Object]`. Date\n // properties are normalised before they get here.\n const s = Array.isArray(v) || (typeof v === \"object\" && !(v instanceof Date))\n ? JSON.stringify(v)\n : String(v);\n return \"\\\"\" + escapeCsvFormula(s).replaceAll(\"\\\"\", \"\\\"\\\"\") + \"\\\"\";\n}\n\nexport function entryToCSVRow(entry: unknown[]) {\n return entry\n .map(toCSVCell)\n .join(\",\") + \"\\r\\n\";\n}\n\nexport function downloadBlob(content: BlobPart[], filename: string, contentType: string) {\n const blob = new Blob(content, { type: contentType });\n const url = URL.createObjectURL(blob);\n const pom = document.createElement(\"a\");\n pom.href = url;\n pom.setAttribute(\"download\", filename);\n pom.click();\n // Unrevoked, the URL kept the whole file in memory until the tab closed —\n // one more copy per export. The download holds its own reference once it\n // has started; the delay covers browsers that start it a moment after\n // `click()` returns.\n setTimeout(() => URL.revokeObjectURL(url), BLOB_URL_LIFETIME_MS);\n}\n\n/** How long an export's object URL outlives the click that downloads it. */\nconst BLOB_URL_LIFETIME_MS = 10_000;\n\nexport function downloadDataAsCsv(data: object[], name: string) {\n if (data.length === 0) return;\n\n // Every key any row holds, in the order they are first met; the header\n // row is written through the same cell escaping as the values.\n const headers = [...new Set(data.flatMap(row => Object.keys(row)))];\n const csvContent = [\n headers.map(toCSVCell).join(\",\"),\n ...data.map(row => headers.map(header => toCSVCell((row as Record<string, unknown>)[header])).join(\",\"))\n ].join(\"\\r\\n\");\n\n downloadBlob([csvContent], `${name}.csv`, \"text/csv\");\n}\n"],"mappings":";;;AAoBA,SAAgB,uBAA0D,EACtE,MACA,gBACA,YACA,iBACA,MACA,eACA,mBACA,YACA,kBAEF;CAEE,QAAQ,MAAM,sBAAsB;EAChC,YAAY,KAAK;EACjB;EACA;EACA;CACJ,CAAC;CAED,IAAI,eAAe,OAAO;EACtB,MAAM,SAAS,sBAAsB;GACjC;GACA;GACA;GACA;GACA;EACJ,CAAC;EACD,OAAO,QAAQ,MAAM,cAAc;EACnC,aAAa,OAAO,OAAO,GAAG,GAAG,KAAK,OAAO,UAAU;CAC3D,OAAO;EACH,MAAM,iBAAiB,4BAA4B,MAAM,gBAAgB,YAAY,cAAc;EAEnG,aAAa,CADA,KAAK,UAAU,gBAAgB,MAAM,CACpC,CAAI,GAAG,GAAG,KAAK,QAAQ,kBAAkB;CAC3D;AACJ;AAEA,SAAgB,2BAA2B,MACvC,gBACA,YACA,SACA,gBACF;CACE,OAAO,gBAAgB,MAAM,gBAAgB,YA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MAAM,IAAI;AACjE;AAEA,SAAgB,cAAc,OAAkB;CAC5C,OAAO,MACF,IAAI,SAAS,CAAC,CACd,KAAK,GAAG,IAAI;AACrB;AAEA,SAAgB,aAAa,SAAqB,UAAkB,aAAqB;CACrF,MAAM,OAAO,IAAI,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;CACpD,MAAM,MAAM,IAAI,gBAAgB,IAAI;CACpC,MAAM,MAAM,SAAS,cAAc,GAAG;CACtC,IAAI,OAAO;CACX,IAAI,aAAa,YAAY,QAAQ;CACrC,IAAI,MAAM;CAKV,iBAAiB,IAAI,gBAAgB,GAAG,GAAG,oBAAoB;AACnE;;AAGA,IAAM,uBAAuB;AAE7B,SAAgB,kBAAkB,MAAgB,MAAc;CAC5D,IAAI,KAAK,WAAW,GAAG;CAIvB,MAAM,UAAU,CAAC,GAAG,IAAI,IAAI,KAAK,SAAQ,QAAO,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC;CAMlE,aAAa,CALM,CACf,QAAQ,IAAI,SAAS,CAAC,CAAC,KAAK,GAAG,GAC/B,GAAG,KAAK,KAAI,QAAO,QAAQ,KAAI,WAAU,UAAW,IAAgC,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAC3G,CAAC,CAAC,KAAK,MAEO,CAAU,GAAG,GAAG,KAAK,OAAO,UAAU;AACxD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FindParams } from "@rebasepro/types";
|
|
2
|
+
import { Entity } from "@rebasepro/cms-types";
|
|
2
3
|
import { EntityPageAccessor } from "../../util/entity_pages.js";
|
|
3
4
|
/**
|
|
4
5
|
* Rows asked for per request: the server's `MAX_LIST_LIMIT`, the largest page a
|
|
@@ -18,7 +19,7 @@ export declare const EXPORT_PAGE_SIZE = 1000;
|
|
|
18
19
|
*/
|
|
19
20
|
export declare const MAX_EXPORT_ROWS = 100000;
|
|
20
21
|
export interface FetchAllForExportParams<M extends Record<string, unknown>> {
|
|
21
|
-
/** The collection accessor to read through — `dataClient.
|
|
22
|
+
/** The collection accessor to read through — `dataClient.table(path)`. */
|
|
22
23
|
accessor: EntityPageAccessor<M>;
|
|
23
24
|
/** Query to export. The window (`limit` / `offset` / `page`) is owned by the walk. */
|
|
24
25
|
params?: Omit<FindParams<M>, "limit" | "offset" | "page">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch_export_data.js","names":[],"sources":["../../../src/data_export/export/fetch_export_data.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"fetch_export_data.js","names":[],"sources":["../../../src/data_export/export/fetch_export_data.ts"],"sourcesContent":["import { FindParams, MAX_LIST_LIMIT } from \"@rebasepro/types\";\nimport { Entity } from \"@rebasepro/cms-types\";\nimport { EntityPageAccessor, forEachEntityPage, walkEntityPages } from \"../../util/entity_pages\";\n\n/**\n * Rows asked for per request: the server's `MAX_LIST_LIMIT`, the largest page a\n * read will serve — it *refuses* anything larger. (It used to clamp silently,\n * and asking for 100 000 while receiving 1 000 looked exactly like a collection\n * with 1 000 rows in it.) The walk still never trusts the page size it asked\n * for: it advances by the rows it was actually handed. It was 500, which made a\n * 100 000-row export 200 sequential requests, each with its own count.\n */\nexport const EXPORT_PAGE_SIZE = MAX_LIST_LIMIT;\n\n/**\n * Most rows one browser-side export will materialise.\n *\n * Everything here is built in memory and handed to a Blob, so there is a\n * ceiling whether or not it is named. Naming it means going over it **throws**\n * instead of writing a short file that reads like the whole collection.\n */\nexport const MAX_EXPORT_ROWS = 100_000;\n\nexport interface FetchAllForExportParams<M extends Record<string, unknown>> {\n /** The collection accessor to read through — `dataClient.table(path)`. */\n accessor: EntityPageAccessor<M>;\n /** Query to export. The window (`limit` / `offset` / `page`) is owned by the walk. */\n params?: Omit<FindParams<M>, \"limit\" | \"offset\" | \"page\">;\n pageSize?: number;\n maxRows?: number;\n /** Called after every page with the rows so far, and the total when the server reports one. */\n onProgress?: (loaded: number, total: number | undefined) => void;\n}\n\n/**\n * Read **every** row matching a query, for an export file.\n *\n * The export used to hand back the 50 rows an unwindowed `find({})` resolves to\n * as `<collection>.csv`, with nothing saying it was a sample, next to a dialog\n * warning that the collection had 100 000 documents. The walk is in\n * {@link walkEntityPages}; what belongs to export is the ceiling — an export is\n * built in memory and handed to a Blob — and what to say on hitting it.\n *\n * @throws When more than `maxRows` rows match.\n */\nexport async function fetchAllEntitiesForExport<M extends Record<string, unknown>>({\n accessor,\n params,\n pageSize = EXPORT_PAGE_SIZE,\n maxRows = MAX_EXPORT_ROWS,\n onProgress\n}: FetchAllForExportParams<M>): Promise<Entity<M>[]> {\n return walkEntityPages<M>({\n accessor,\n params,\n pageSize,\n maxRows,\n onProgress,\n onCeiling: exportCeilingMessage\n });\n}\n\n/**\n * {@link fetchAllEntitiesForExport}, handing each page to `onPage` as it is\n * read instead of collecting every row: for an export that writes its file as\n * it goes (CSV), so that what it holds is the file and one page, not every\n * entity in it.\n *\n * @throws When more than `maxRows` rows match.\n */\nexport async function forEachEntityPageForExport<M extends Record<string, unknown>>({\n accessor,\n params,\n pageSize = EXPORT_PAGE_SIZE,\n maxRows = MAX_EXPORT_ROWS,\n onProgress,\n onPage\n}: FetchAllForExportParams<M> & {\n onPage: (page: Entity<M>[]) => void | Promise<void>;\n}): Promise<void> {\n return forEachEntityPage<M>({\n accessor,\n params,\n pageSize,\n maxRows,\n onProgress,\n onPage,\n onCeiling: exportCeilingMessage\n });\n}\n\nfunction exportCeilingMessage(max: number): string {\n return `This export would contain more than ${max.toLocaleString()} rows, which is more than the ` +\n \"browser can build in one file. Filter the collection down, or export it from the server.\";\n}\n"],"mappings":";;;;;;;;;;;AAYA,IAAa,mBAAmB;;;;;;;;AAShC,IAAa,kBAAkB;;;;;;;;;;;;AAwB/B,eAAsB,0BAA6D,EAC/E,UACA,QACA,WAAW,kBACX,UAAU,iBACV,cACiD;CACjD,OAAO,gBAAmB;EACtB;EACA;EACA;EACA;EACA;EACA,WAAW;CACf,CAAC;AACL;;;;;;;;;AAUA,eAAsB,2BAA8D,EAChF,UACA,QACA,WAAW,kBACX,UAAU,iBACV,YACA,UAGc;CACd,OAAO,kBAAqB;EACxB;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;CACf,CAAC;AACL;AAEA,SAAS,qBAAqB,KAAqB;CAC/C,OAAO,uCAAuC,IAAI,eAAe,EAAE;AAEvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataNewPropertiesMapping.js","names":[],"sources":["../../../src/data_import/components/DataNewPropertiesMapping.tsx"],"sourcesContent":["\nimport { getPropertyInPath } from \"../../util\";\nimport { Properties, Property } from \"@rebasepro/types\";\nimport {\n BooleanSwitchWithLabel,\n ChevronRightIcon,\n DateTimeField,\n ExpandablePanel,\n Select,\n SelectItem,\n Table,\n TableBody,\n TableCell,\n TableHeader,\n TableRow,\n TextField,\n Typography\n} from \"@rebasepro/ui\";\nimport { getIn, setIn } from \"@rebasepro/forms\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport { ImportConfig } from \"../types\";\n\nexport interface DataPropertyMappingProps {\n importConfig: ImportConfig;\n destinationProperties: Record<string, Property>;\n buildPropertyView?: (props: {\n isIdColumn: boolean,\n property: Property | null,\n propertyKey: string | null,\n importKey: string\n }) => any;\n}\n\nexport function DataNewPropertiesMapping({\n importConfig,\n destinationProperties,\n buildPropertyView\n}: DataPropertyMappingProps) {\n\n const { t } = useTranslation();\n const headersMapping = importConfig.headersMapping;\n const headingsOrder = importConfig.headingsOrder;\n const idColumn = importConfig.idColumn;\n const originProperties = importConfig.originProperties;\n\n return (\n <>\n\n <IdSelectField idColumn={idColumn}\n headersMapping={headersMapping}\n onChange={(value) => importConfig.setIdColumn(value ?? undefined)}/>\n\n <div className={\"h-4\"}/>\n\n <Table style={{\n tableLayout: \"fixed\"\n }}>\n <TableHeader>\n <TableCell header={true} style={{ width: \"20%\" }}>\n Column in file\n </TableCell>\n <TableCell header={true}>\n </TableCell>\n <TableCell header={true} style={{ width: \"75%\" }}>\n Map to Property\n </TableCell>\n </TableHeader>\n <TableBody>\n {destinationProperties &&\n headingsOrder.map((importKey) => {\n const mappedKey = headersMapping[importKey];\n const propertyKey = headersMapping[importKey];\n const property = mappedKey ? getPropertyInPath(destinationProperties, mappedKey) as Property : null;\n\n const originProperty = getPropertyInPath(originProperties, importKey) as Property | undefined;\n const origintype = originProperty\n ? (originProperty.type === \"array\" && typeof originProperty.of === \"object\"\n ? `${originProperty.type} - ${(originProperty.of as Property).type}`\n : originProperty.type)\n : undefined;\n return <TableRow key={importKey} style={{ height: \"90px\" }}>\n <TableCell style={{ width: \"20%\" }}>\n <Typography variant={\"body2\"}>{importKey}</Typography>\n {originProperty && <Typography\n variant={\"caption\"}\n color={\"secondary\"}\n >{origintype}</Typography>}\n </TableCell>\n <TableCell>\n <ChevronRightIcon/>\n </TableCell>\n <TableCell className={importKey === idColumn ? \"text-center\" : undefined}\n style={{ width: \"75%\" }}>\n {buildPropertyView?.({\n isIdColumn: importKey === idColumn,\n property,\n propertyKey,\n importKey\n })}\n </TableCell>\n </TableRow>;\n }\n )}\n </TableBody>\n </Table>\n\n <ExpandablePanel title=\"Default values\" initiallyExpanded={false} innerClassName={\"p-4 mt-4\"}>\n\n <div className={\"text-sm text-surface-accent-500 dark:text-surface-accent-300 font-medium ml-3.5 mb-1\"}>\n You can select a default value for unmapped columns and empty values:\n </div>\n <Table style={{\n tableLayout: \"fixed\"\n }}>\n <TableHeader>\n <TableCell header={true} style={{ width: \"30%\" }}>\n Property\n </TableCell>\n <TableCell header={true}>\n </TableCell>\n <TableCell header={true} style={{ width: \"65%\" }}>\n {t(\"default_value\")}\n </TableCell>\n </TableHeader>\n <TableBody>\n {destinationProperties &&\n getAllPropertyKeys(destinationProperties).map((key) => {\n const property = getPropertyInPath(destinationProperties, key);\n if (typeof property !== \"object\" || property === null) {\n return null;\n }\n if (![\"number\", \"string\", \"boolean\", \"map\"].includes(property.type)) {\n return null;\n }\n return <TableRow key={key} style={{ height: \"70px\" }}>\n <TableCell style={{ width: \"20%\" }}>\n <Typography variant={\"body2\"}>{key}</Typography>\n </TableCell>\n <TableCell>\n <ChevronRightIcon/>\n </TableCell>\n <TableCell className={key === idColumn ? \"text-center\" : undefined}\n style={{ width: \"75%\" }}>\n <DefaultValuesField property={property}\n defaultValue={getIn(importConfig.defaultValues, key)}\n onValueChange={(value) => {\n const newValues = setIn(importConfig.defaultValues, key, value);\n importConfig.setDefaultValues(newValues as Record<string, any>);\n }}/>\n </TableCell>\n </TableRow>;\n }\n )}\n </TableBody>\n </Table>\n </ExpandablePanel>\n </>\n );\n}\n\nfunction getAllPropertyKeys(properties: Properties, currentKey?: string): string[] {\n return Object.entries(properties).reduce((acc, [key, property]) => {\n const accumulatedKey = currentKey ? `${currentKey}.${key}` : key;\n if (typeof property !== \"function\" && property.type === \"map\" && property.properties) {\n const childProperties = getAllPropertyKeys(property.properties, accumulatedKey);\n return [...acc, ...childProperties];\n }\n return [...acc, accumulatedKey];\n }, [] as string[]);\n}\n\nfunction IdSelectField({\n idColumn,\n headersMapping,\n onChange\n}: {\n idColumn?: string,\n headersMapping: Record<string, string | null>;\n onChange: (value: string | null) => void\n}) {\n return <div>\n <Select\n size={\"medium\"}\n value={idColumn ?? \"\"}\n fullWidth={true}\n onChange={(event) => {\n const value = event.target.value;\n onChange(value === \"__none__\" ? null : value);\n }}\n placeholder={\"Autogenerate ID\"}\n renderValue={(value) => {\n return <Typography variant={\"body2\"}>\n {value !== \"__none__\" ? value : \"Autogenerate ID\"}\n </Typography>;\n }}\n label={\"Column that will be used as ID for each document\"}>\n <SelectItem value={\"__none__\"}>Autogenerate ID</SelectItem>\n {Object.entries(headersMapping).map(([key, value]) => {\n return <SelectItem key={key} value={key}>{key}</SelectItem>;\n })}\n </Select>\n </div>;\n}\n\nfunction DefaultValuesField({\n property,\n onValueChange,\n defaultValue\n}: { property: Property, onValueChange: (value: any) => void, defaultValue?: any }) {\n const { t } = useTranslation();\n const defaultValueLabel = t(\"default_value\");\n // Named fields stay distinguishable from each other — several of these sit\n // in one table, and an aria-label repeated verbatim tells a screen reader\n // nothing about which row it is on.\n //\n // Composed with a separator rather than a phrase: there is no key for the\n // possessive form, and `t` returns the key itself for one that does not\n // exist, so inventing `default_value_for` here would read out the literal\n // string \"default_value_for\" in every locale, English included.\n const ariaLabel = property.name\n ? `${defaultValueLabel}: ${property.name}`\n : defaultValueLabel;\n if (property.type === \"string\") {\n return <TextField size={\"medium\"}\n aria-label={ariaLabel}\n placeholder={defaultValueLabel}\n value={defaultValue ?? \"\"}\n onChange={(event) => onValueChange(event.target.value)}/>;\n } else if (property.type === \"number\") {\n return <TextField size={\"medium\"}\n type={\"number\"}\n aria-label={ariaLabel}\n value={defaultValue ?? \"\"}\n placeholder={defaultValueLabel}\n onChange={(event) => onValueChange(event.target.value)}/>;\n } else if (property.type === \"boolean\") {\n return <BooleanSwitchWithLabel\n value={defaultValue ?? null}\n allowIndeterminate={true}\n size={\"small\"}\n onValueChange={(v: boolean | null) => onValueChange(v === null ? undefined : v)}\n label={defaultValue === undefined\n ? \"Do not set value\"\n : defaultValue === true\n ? \"Set value to true\"\n : \"Set value to false\"}\n />\n } else if (property.type === \"date\") {\n return <DateTimeField\n mode={property.mode ?? \"date\"}\n size={\"medium\"}\n value={defaultValue ?? undefined}\n onChange={(dateValue: Date | null) => {\n onValueChange(dateValue);\n }}\n clearable={true}\n />\n }\n\n return null;\n}\n"],"mappings":";;;;;;AAiCA,SAAgB,yBAAyB,EACrC,cACA,uBACA,qBACyB;CAEzB,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,iBAAiB,aAAa;CACpC,MAAM,gBAAgB,aAAa;CACnC,MAAM,WAAW,aAAa;CAC9B,MAAM,mBAAmB,aAAa;CAEtC,OACI,qBAAA,UAAA,EAAA,UAAA;EAEI,oBAAC,eAAD;GAAyB;GACL;GAChB,WAAW,UAAU,aAAa,YAAY,SAAS,KAAA,CAAS;EAAG,CAAA;EAEvE,oBAAC,OAAD,EAAK,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gB;EACvB,WAAW,UAAU,cAAc,MAAM,OAAO,KAAK;CAAG,CAAA;MACzD,IAAI,SAAS,SAAS,UACzB,OAAO,oBAAC,WAAD;EAAW,MAAM;EACpB,MAAM;EACN,cAAY;EACZ,OAAO,gBAAgB;EACvB,aAAa;EACb,WAAW,UAAU,cAAc,MAAM,OAAO,KAAK;CAAG,CAAA;MACzD,IAAI,SAAS,SAAS,WACzB,OAAO,oBAAC,wBAAD;EACH,OAAO,gBAAgB;EACvB,oBAAoB;EACpB,MAAM;EACN,gBAAgB,MAAsB,cAAc,MAAM,OAAO,KAAA,IAAY,CAAC;EAC9E,OAAO,iBAAiB,KAAA,IAClB,qBACA,iBAAiB,OACb,sBACA;CACb,CAAA;MACE,IAAI,SAAS,SAAS,QACzB,OAAO,oBAAC,eAAD;EACH,MAAM,SAAS,QAAQ;EACvB,MAAM;EACN,OAAO,gBAAgB,KAAA;EACvB,WAAW,cAA2B;GAClC,cAAc,SAAS;EAC3B;EACA,WAAW;CACd,CAAA;CAGL,OAAO;AACX"}
|
|
1
|
+
{"version":3,"file":"DataNewPropertiesMapping.js","names":[],"sources":["../../../src/data_import/components/DataNewPropertiesMapping.tsx"],"sourcesContent":["\nimport { getPropertyInPath } from \"../../util\";\nimport { Properties, Property } from \"@rebasepro/cms-types\";\nimport {\n BooleanSwitchWithLabel,\n ChevronRightIcon,\n DateTimeField,\n ExpandablePanel,\n Select,\n SelectItem,\n Table,\n TableBody,\n TableCell,\n TableHeader,\n TableRow,\n TextField,\n Typography\n} from \"@rebasepro/ui\";\nimport { getIn, setIn } from \"@rebasepro/forms\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport { ImportConfig } from \"../types\";\n\nexport interface DataPropertyMappingProps {\n importConfig: ImportConfig;\n destinationProperties: Record<string, Property>;\n buildPropertyView?: (props: {\n isIdColumn: boolean,\n property: Property | null,\n propertyKey: string | null,\n importKey: string\n }) => any;\n}\n\nexport function DataNewPropertiesMapping({\n importConfig,\n destinationProperties,\n buildPropertyView\n}: DataPropertyMappingProps) {\n\n const { t } = useTranslation();\n const headersMapping = importConfig.headersMapping;\n const headingsOrder = importConfig.headingsOrder;\n const idColumn = importConfig.idColumn;\n const originProperties = importConfig.originProperties;\n\n return (\n <>\n\n <IdSelectField idColumn={idColumn}\n headersMapping={headersMapping}\n onChange={(value) => importConfig.setIdColumn(value ?? undefined)}/>\n\n <div className={\"h-4\"}/>\n\n <Table style={{\n tableLayout: \"fixed\"\n }}>\n <TableHeader>\n <TableCell header={true} style={{ width: \"20%\" }}>\n Column in file\n </TableCell>\n <TableCell header={true}>\n </TableCell>\n <TableCell header={true} style={{ width: \"75%\" }}>\n Map to Property\n </TableCell>\n </TableHeader>\n <TableBody>\n {destinationProperties &&\n headingsOrder.map((importKey) => {\n const mappedKey = headersMapping[importKey];\n const propertyKey = headersMapping[importKey];\n const property = mappedKey ? getPropertyInPath(destinationProperties, mappedKey) as Property : null;\n\n const originProperty = getPropertyInPath(originProperties, importKey) as Property | undefined;\n const origintype = originProperty\n ? (originProperty.type === \"array\" && typeof originProperty.of === \"object\"\n ? `${originProperty.type} - ${(originProperty.of as Property).type}`\n : originProperty.type)\n : undefined;\n return <TableRow key={importKey} style={{ height: \"90px\" }}>\n <TableCell style={{ width: \"20%\" }}>\n <Typography variant={\"body2\"}>{importKey}</Typography>\n {originProperty && <Typography\n variant={\"caption\"}\n color={\"secondary\"}\n >{origintype}</Typography>}\n </TableCell>\n <TableCell>\n <ChevronRightIcon/>\n </TableCell>\n <TableCell className={importKey === idColumn ? \"text-center\" : undefined}\n style={{ width: \"75%\" }}>\n {buildPropertyView?.({\n isIdColumn: importKey === idColumn,\n property,\n propertyKey,\n importKey\n })}\n </TableCell>\n </TableRow>;\n }\n )}\n </TableBody>\n </Table>\n\n <ExpandablePanel title=\"Default values\" initiallyExpanded={false} innerClassName={\"p-4 mt-4\"}>\n\n <div className={\"text-sm text-surface-accent-500 dark:text-surface-accent-300 font-medium ml-3.5 mb-1\"}>\n You can select a default value for unmapped columns and empty values:\n </div>\n <Table style={{\n tableLayout: \"fixed\"\n }}>\n <TableHeader>\n <TableCell header={true} style={{ width: \"30%\" }}>\n Property\n </TableCell>\n <TableCell header={true}>\n </TableCell>\n <TableCell header={true} style={{ width: \"65%\" }}>\n {t(\"default_value\")}\n </TableCell>\n </TableHeader>\n <TableBody>\n {destinationProperties &&\n getAllPropertyKeys(destinationProperties).map((key) => {\n const property = getPropertyInPath(destinationProperties, key);\n if (typeof property !== \"object\" || property === null) {\n return null;\n }\n if (![\"number\", \"string\", \"boolean\", \"map\"].includes(property.type)) {\n return null;\n }\n return <TableRow key={key} style={{ height: \"70px\" }}>\n <TableCell style={{ width: \"20%\" }}>\n <Typography variant={\"body2\"}>{key}</Typography>\n </TableCell>\n <TableCell>\n <ChevronRightIcon/>\n </TableCell>\n <TableCell className={key === idColumn ? \"text-center\" : undefined}\n style={{ width: \"75%\" }}>\n <DefaultValuesField property={property}\n defaultValue={getIn(importConfig.defaultValues, key)}\n onValueChange={(value) => {\n const newValues = setIn(importConfig.defaultValues, key, value);\n importConfig.setDefaultValues(newValues as Record<string, any>);\n }}/>\n </TableCell>\n </TableRow>;\n }\n )}\n </TableBody>\n </Table>\n </ExpandablePanel>\n </>\n );\n}\n\nfunction getAllPropertyKeys(properties: Properties, currentKey?: string): string[] {\n return Object.entries(properties).reduce((acc, [key, property]) => {\n const accumulatedKey = currentKey ? `${currentKey}.${key}` : key;\n if (typeof property !== \"function\" && property.type === \"map\" && property.properties) {\n const childProperties = getAllPropertyKeys(property.properties, accumulatedKey);\n return [...acc, ...childProperties];\n }\n return [...acc, accumulatedKey];\n }, [] as string[]);\n}\n\nfunction IdSelectField({\n idColumn,\n headersMapping,\n onChange\n}: {\n idColumn?: string,\n headersMapping: Record<string, string | null>;\n onChange: (value: string | null) => void\n}) {\n return <div>\n <Select\n size={\"medium\"}\n value={idColumn ?? \"\"}\n fullWidth={true}\n onChange={(event) => {\n const value = event.target.value;\n onChange(value === \"__none__\" ? null : value);\n }}\n placeholder={\"Autogenerate ID\"}\n renderValue={(value) => {\n return <Typography variant={\"body2\"}>\n {value !== \"__none__\" ? value : \"Autogenerate ID\"}\n </Typography>;\n }}\n label={\"Column that will be used as ID for each document\"}>\n <SelectItem value={\"__none__\"}>Autogenerate ID</SelectItem>\n {Object.entries(headersMapping).map(([key, value]) => {\n return <SelectItem key={key} value={key}>{key}</SelectItem>;\n })}\n </Select>\n </div>;\n}\n\nfunction DefaultValuesField({\n property,\n onValueChange,\n defaultValue\n}: { property: Property, onValueChange: (value: any) => void, defaultValue?: any }) {\n const { t } = useTranslation();\n const defaultValueLabel = t(\"default_value\");\n // Named fields stay distinguishable from each other — several of these sit\n // in one table, and an aria-label repeated verbatim tells a screen reader\n // nothing about which row it is on.\n //\n // Composed with a separator rather than a phrase: there is no key for the\n // possessive form, and `t` returns the key itself for one that does not\n // exist, so inventing `default_value_for` here would read out the literal\n // string \"default_value_for\" in every locale, English included.\n const ariaLabel = property.name\n ? `${defaultValueLabel}: ${property.name}`\n : defaultValueLabel;\n if (property.type === \"string\") {\n return <TextField size={\"medium\"}\n aria-label={ariaLabel}\n placeholder={defaultValueLabel}\n value={defaultValue ?? \"\"}\n onChange={(event) => onValueChange(event.target.value)}/>;\n } else if (property.type === \"number\") {\n return <TextField size={\"medium\"}\n type={\"number\"}\n aria-label={ariaLabel}\n value={defaultValue ?? \"\"}\n placeholder={defaultValueLabel}\n onChange={(event) => onValueChange(event.target.value)}/>;\n } else if (property.type === \"boolean\") {\n return <BooleanSwitchWithLabel\n value={defaultValue ?? null}\n allowIndeterminate={true}\n size={\"small\"}\n onValueChange={(v: boolean | null) => onValueChange(v === null ? undefined : v)}\n label={defaultValue === undefined\n ? \"Do not set value\"\n : defaultValue === true\n ? \"Set value to true\"\n : \"Set value to false\"}\n />\n } else if (property.type === \"date\") {\n return <DateTimeField\n mode={property.mode ?? \"date\"}\n size={\"medium\"}\n value={defaultValue ?? undefined}\n onChange={(dateValue: Date | null) => {\n onValueChange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AC,KAAK,CAAC,KAAK,WAAW;GAClD,OAAO,oBAAC,YAAD;IAAsB,OAAO;cAAM;GAAgB,GAAlC,GAAkC;EAC9D,CAAC,CACG;IACP,CAAA;AACT;AAEA,SAAS,mBAAmB,EACxB,UACA,eACA,gBACgF;CAChF,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,oBAAoB,EAAE,eAAe;CAS3C,MAAM,YAAY,SAAS,OACrB,GAAG,kBAAkB,IAAI,SAAS,SAClC;CACN,IAAI,SAAS,SAAS,UAClB,OAAO,oBAAC,WAAD;EAAW,MAAM;EACpB,cAAY;EACZ,aAAa;EACb,OAAO,gBAAgB;EACvB,WAAW,UAAU,cAAc,MAAM,OAAO,KAAK;CAAG,CAAA;MACzD,IAAI,SAAS,SAAS,UACzB,OAAO,oBAAC,WAAD;EAAW,MAAM;EACpB,MAAM;EACN,cAAY;EACZ,OAAO,gBAAgB;EACvB,aAAa;EACb,WAAW,UAAU,cAAc,MAAM,OAAO,KAAK;CAAG,CAAA;MACzD,IAAI,SAAS,SAAS,WACzB,OAAO,oBAAC,wBAAD;EACH,OAAO,gBAAgB;EACvB,oBAAoB;EACpB,MAAM;EACN,gBAAgB,MAAsB,cAAc,MAAM,OAAO,KAAA,IAAY,CAAC;EAC9E,OAAO,iBAAiB,KAAA,IAClB,qBACA,iBAAiB,OACb,sBACA;CACb,CAAA;MACE,IAAI,SAAS,SAAS,QACzB,OAAO,oBAAC,eAAD;EACH,MAAM,SAAS,QAAQ;EACvB,MAAM;EACN,OAAO,gBAAgB,KAAA;EACvB,WAAW,cAA2B;GAClC,cAAc,SAAS;EAC3B;EACA,WAAW;CACd,CAAA;CAGL,OAAO;AACX"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Property } from "@rebasepro/types";
|
|
2
|
+
import { Property } from "@rebasepro/cms-types";
|
|
3
3
|
export declare function ImportNewPropertyFieldPreview({ propertyKey, property, onEditClick, includeName, onPropertyNameChanged, propertyTypeView }: {
|
|
4
4
|
propertyKey: string | null;
|
|
5
5
|
property: Property | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportNewPropertyFieldPreview.js","names":[],"sources":["../../../src/data_import/components/ImportNewPropertyFieldPreview.tsx"],"sourcesContent":["import React from \"react\";\nimport { useCustomizationController, useTranslation } from \"@rebasepro/app\";\nimport { Property } from \"@rebasepro/types\";\nimport { getFieldConfig } from \"../../components/field_configs\";\nimport { PropertyConfigBadge } from \"../../components/PropertyConfigBadge\";\nimport { ErrorBoundary, IconButton, PencilIcon, TextField } from \"@rebasepro/ui\";\n\nexport function ImportNewPropertyFieldPreview({\n propertyKey,\n property,\n onEditClick,\n includeName = true,\n onPropertyNameChanged,\n propertyTypeView\n}: {\n propertyKey: string | null,\n property: Property | null\n includeName?: boolean,\n onEditClick?: () => void,\n onPropertyNameChanged?: (propertyKey: string, value: string) => void,\n propertyTypeView?: any\n}) {\n const { t } = useTranslation();\n\n const { propertyConfigs } = useCustomizationController();\n const widget = property ? getFieldConfig(property, propertyConfigs) : null;\n\n return <ErrorBoundary>\n <div\n className=\"flex flex-row w-full items-center\">\n\n <div className={\"mx-4\"}>\n {propertyTypeView ?? <PropertyConfigBadge propertyConfig={widget ?? undefined}/>}\n </div>\n\n <div className=\"w-full flex flex-col grow\">\n\n <div className={\"flex flex-row items-center gap-2\"}>\n {includeName &&\n <TextField\n size={\"medium\"}\n aria-label={propertyKey ? `Name of property ${propertyKey}` : \"Property name\"}\n className={\"text-base grow\"}\n value={property?.name ?? \"\"}\n onChange={(e) => {\n if (onPropertyNameChanged && propertyKey)\n onPropertyNameChanged(propertyKey, e.target.value);\n }}/>}\n\n <IconButton aria-label={t(\"edit\")} onClick={onEditClick} size={\"small\"}>\n <PencilIcon/>\n </IconButton>\n </div>\n\n </div>\n\n </div>\n </ErrorBoundary>\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,8BAA8B,EAC1C,aACA,UACA,aACA,cAAc,MACd,uBACA,oBAQD;CACC,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,EAAE,oBAAoB,2BAA2B;CACvD,MAAM,SAAS,WAAW,eAAe,UAAU,eAAe,IAAI;CAEtE,OAAO,oBAAC,eAAD,EAAA,UACH,qBAAC,OAAD;EACI,WAAU;YADd,CAGI,oBAAC,OAAD;GAAK,WAAW;aACX,oBAAoB,oBAAC,qBAAD,EAAqB,gBAAgB,UAAU,KAAA,EAAW,CAAA;EAC9E,CAAA,GAEL,oBAAC,OAAD;GAAK,WAAU;aAEX,qBAAC,OAAD;IAAK,WAAW;cAAhB,CACK,eACG,oBAAC,WAAD;KACI,MAAM;KACN,cAAY,cAAc,oBAAoB,gBAAgB;KAC9D,WAAW;KACX,OAAO,UAAU,QAAQ;KACzB,WAAW,MAAM;MACb,IAAI,yBAAyB,aACzB,sBAAsB,aAAa,EAAE,OAAO,KAAK;KACzD;IAAG,CAAA,GAEX,oBAAC,YAAD;KAAY,cAAY,EAAE,MAAM;KAAG,SAAS;KAAa,MAAM;eAC3D,oBAAC,YAAD,CAAY,CAAA;IACJ,CAAA,CACX;;EAEJ,CAAA,CAEJ;IACM,CAAA;AACnB"}
|
|
1
|
+
{"version":3,"file":"ImportNewPropertyFieldPreview.js","names":[],"sources":["../../../src/data_import/components/ImportNewPropertyFieldPreview.tsx"],"sourcesContent":["import React from \"react\";\nimport { useCustomizationController, useTranslation } from \"@rebasepro/app\";\nimport { Property } from \"@rebasepro/cms-types\";\nimport { getFieldConfig } from \"../../components/field_configs\";\nimport { PropertyConfigBadge } from \"../../components/PropertyConfigBadge\";\nimport { ErrorBoundary, IconButton, PencilIcon, TextField } from \"@rebasepro/ui\";\n\nexport function ImportNewPropertyFieldPreview({\n propertyKey,\n property,\n onEditClick,\n includeName = true,\n onPropertyNameChanged,\n propertyTypeView\n}: {\n propertyKey: string | null,\n property: Property | null\n includeName?: boolean,\n onEditClick?: () => void,\n onPropertyNameChanged?: (propertyKey: string, value: string) => void,\n propertyTypeView?: any\n}) {\n const { t } = useTranslation();\n\n const { propertyConfigs } = useCustomizationController();\n const widget = property ? getFieldConfig(property, propertyConfigs) : null;\n\n return <ErrorBoundary>\n <div\n className=\"flex flex-row w-full items-center\">\n\n <div className={\"mx-4\"}>\n {propertyTypeView ?? <PropertyConfigBadge propertyConfig={widget ?? undefined}/>}\n </div>\n\n <div className=\"w-full flex flex-col grow\">\n\n <div className={\"flex flex-row items-center gap-2\"}>\n {includeName &&\n <TextField\n size={\"medium\"}\n aria-label={propertyKey ? `Name of property ${propertyKey}` : \"Property name\"}\n className={\"text-base grow\"}\n value={property?.name ?? \"\"}\n onChange={(e) => {\n if (onPropertyNameChanged && propertyKey)\n onPropertyNameChanged(propertyKey, e.target.value);\n }}/>}\n\n <IconButton aria-label={t(\"edit\")} onClick={onEditClick} size={\"small\"}>\n <PencilIcon/>\n </IconButton>\n </div>\n\n </div>\n\n </div>\n </ErrorBoundary>\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,8BAA8B,EAC1C,aACA,UACA,aACA,cAAc,MACd,uBACA,oBAQD;CACC,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,EAAE,oBAAoB,2BAA2B;CACvD,MAAM,SAAS,WAAW,eAAe,UAAU,eAAe,IAAI;CAEtE,OAAO,oBAAC,eAAD,EAAA,UACH,qBAAC,OAAD;EACI,WAAU;YADd,CAGI,oBAAC,OAAD;GAAK,WAAW;aACX,oBAAoB,oBAAC,qBAAD,EAAqB,gBAAgB,UAAU,KAAA,EAAW,CAAA;EAC9E,CAAA,GAEL,oBAAC,OAAD;GAAK,WAAU;aAEX,qBAAC,OAAD;IAAK,WAAW;cAAhB,CACK,eACG,oBAAC,WAAD;KACI,MAAM;KACN,cAAY,cAAc,oBAAoB,gBAAgB;KAC9D,WAAW;KACX,OAAO,UAAU,QAAQ;KACzB,WAAW,MAAM;MACb,IAAI,yBAAyB,aACzB,sBAAsB,aAAa,EAAE,OAAO,KAAK;KACzD;IAAG,CAAA,GAEX,oBAAC,YAAD;KAAY,cAAY,EAAE,MAAM;KAAG,SAAS;KAAa,MAAM;eAC3D,oBAAC,YAAD,CAAY,CAAA;IACJ,CAAA,CACX;;EAEJ,CAAA,CAEJ;IACM,CAAA;AACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useImportConfig.js","names":[],"sources":["../../../src/data_import/hooks/useImportConfig.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"useImportConfig.js","names":[],"sources":["../../../src/data_import/hooks/useImportConfig.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { Property, Entity } from \"@rebasepro/cms-types\";\nimport { ImportConfig } from \"../types\";\n\nexport const useImportConfig = (): ImportConfig => {\n\n const [inUse, setInUse] = useState<boolean>(false);\n const [defaultValues, setDefaultValues] = useState<Record<string, any>>({});\n const [idColumn, setIdColumn] = useState<string | undefined>();\n const [importData, setImportData] = useState<object[]>([]);\n const [entities, setEntities] = useState<Entity<any>[]>([]);\n const [headersMapping, setHeadersMapping] = useState<Record<string, string | null>>({});\n const [headingsOrder, setHeadingsOrder] = useState<string[]>([]);\n const [originProperties, setOriginProperties] = useState<Record<string, Property>>({});\n\n return {\n inUse,\n setInUse,\n idColumn,\n setIdColumn,\n entities,\n setEntities,\n importData,\n setImportData,\n headingsOrder: (headingsOrder ?? []).length > 0 ? headingsOrder : Object.keys(headersMapping),\n setHeadingsOrder,\n headersMapping,\n setHeadersMapping,\n originProperties,\n setOriginProperties,\n defaultValues,\n setDefaultValues\n };\n};\n"],"mappings":";;AAIA,IAAa,wBAAsC;CAE/C,MAAM,CAAC,OAAO,YAAY,SAAkB,KAAK;CACjD,MAAM,CAAC,eAAe,oBAAoB,SAA8B,CAAC,CAAC;CAC1E,MAAM,CAAC,UAAU,eAAe,SAA6B;CAC7D,MAAM,CAAC,YAAY,iBAAiB,SAAmB,CAAC,CAAC;CACzD,MAAM,CAAC,UAAU,eAAe,SAAwB,CAAC,CAAC;CAC1D,MAAM,CAAC,gBAAgB,qBAAqB,SAAwC,CAAC,CAAC;CACtF,MAAM,CAAC,eAAe,oBAAoB,SAAmB,CAAC,CAAC;CAC/D,MAAM,CAAC,kBAAkB,uBAAuB,SAAmC,CAAC,CAAC;CAErF,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,gBAAgB,iBAAiB,CAAC,EAAA,CAAG,SAAS,IAAI,gBAAgB,OAAO,KAAK,cAAc;EAC5F;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;AACJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { CollectionActionsProps } from "@rebasepro/cms-types";
|
|
2
|
+
import { User } from "@rebasepro/types";
|
|
3
|
+
import { CollectionActionsProps, Properties, Property } from "@rebasepro/cms-types";
|
|
4
4
|
import { ImportConfig } from "../types/index.js";
|
|
5
5
|
export declare function ImportCollectionAction<M extends Record<string, unknown>, USER extends User>({ collection, path, onAnalyticsEvent }: CollectionActionsProps<M, USER> & {
|
|
6
6
|
onAnalyticsEvent?: (event: string, params?: any) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportCollectionAction.js","names":[],"sources":["../../../src/data_import/import/ImportCollectionAction.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo } from \"react\";\nimport {\n useAuthController,\n useCustomizationController,\n useSnackbarController\n} from \"@rebasepro/app\";\nimport { getPropertiesWithPropertiesOrder, getPropertyInPath } from \"../../util\";\nimport { Properties, Property, User } from \"@rebasepro/types\";\nimport { CollectionActionsProps, AdminCollection } from \"@rebasepro/cms-types\";\nimport { getFieldConfig } from \"../../components/field_configs\";\nimport { PropertyConfigBadge } from \"../../components/PropertyConfigBadge\";\nimport { useEntitySelectionController } from \"../../components/CollectionViewBinding/useSelectionController\";\nimport { CollectionTableBinding } from \"../../components/CollectionTableBinding/CollectionTableBinding\";\nimport { useCollectionRegistryController } from \"../../hooks\";\nimport {\n Button,\n cls,\n defaultBorderMixin,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n IconButton,\n iconSize,\n Select,\n SelectItem,\n Tooltip,\n Typography,\n UploadIcon\n} from \"@rebasepro/ui\";\nimport { buildEntityPropertiesFromData } from \"@rebasepro/inference\";\nimport { useImportConfig } from \"../hooks\";\nimport { convertImportData, getInferenceType, ImportConversionProblem } from \"../utils\";\nimport { guessIdColumn, remapImportColumn } from \"../utils/id_column\";\nimport { buildHeadersMappingFromData, takesObjectWhole } from \"../utils/import_columns\";\nimport { DataNewPropertiesMapping } from \"../components/DataNewPropertiesMapping\";\nimport { ImportFileUpload } from \"../components/ImportFileUpload\";\nimport { ImportSaveInProgress } from \"../components/ImportSaveInProgress\";\nimport { ImportConversionProblems } from \"../components/ImportConversionProblems\";\nimport { ImportConfig } from \"../types\";\n\ntype ImportState = \"initial\" | \"mapping\" | \"preview\" | \"import_data_saving\";\n\nexport function ImportCollectionAction<M extends Record<string, unknown>, USER extends User>({\n collection,\n path,\n onAnalyticsEvent\n}: CollectionActionsProps<M, USER> & {\n onAnalyticsEvent?: (event: string, params?: any) => void;\n}\n) {\n\n const snackbarController = useSnackbarController();\n\n const [open, setOpen] = React.useState(false);\n\n const [step, setStep] = React.useState<ImportState>(\"initial\");\n\n const importConfig = useImportConfig();\n\n const handleClickOpen = useCallback(() => {\n setOpen(true);\n onAnalyticsEvent?.(\"import_open\");\n setStep(\"initial\");\n }, [onAnalyticsEvent]);\n\n const handleClose = useCallback(() => {\n setOpen(false);\n }, [setOpen]);\n\n const onMappingComplete = useCallback(() => {\n onAnalyticsEvent?.(\"import_mapping_complete\");\n setStep(\"preview\");\n }, [onAnalyticsEvent]);\n\n const onPreviewComplete = useCallback(() => {\n onAnalyticsEvent?.(\"import_data_save\");\n setStep(\"import_data_saving\");\n }, [onAnalyticsEvent]);\n\n const onDataAdded = async (data: object[]) => {\n importConfig.setImportData(data);\n\n if (data.length > 0) {\n const originProperties = await buildEntityPropertiesFromData(data, getInferenceType);\n importConfig.setOriginProperties(originProperties as Properties);\n\n const headersMapping = buildHeadersMappingFromData(data, collection?.properties);\n importConfig.setHeadersMapping(headersMapping);\n importConfig.setIdColumn(guessIdColumn(Object.keys(headersMapping), headersMapping, collection?.properties));\n }\n setTimeout(() => {\n onAnalyticsEvent?.(\"import_data_added\");\n setStep(\"mapping\");\n }, 100);\n };\n\n // Built once per collection: every column's picker lists these, and a\n // list built afresh on each render redrew every picker on every remap.\n const properties = useMemo(\n () => getPropertiesWithPropertiesOrder(collection.properties, collection.propertiesOrder as Extract<keyof M, string>[]),\n [collection.properties, collection.propertiesOrder]\n );\n\n const propertiesAndLevel = useMemo(() => Object.entries(properties)\n .flatMap(([key, property]) => getPropertiesAndLevel(key, property, 0)), [properties]);\n const propertiesOrder = (collection.propertiesOrder ?? Object.keys(collection.properties)) as Extract<keyof M, string>[];\n\n return <>\n\n <Tooltip title={\"Import\"}\n asChild={true}>\n <IconButton aria-label={\"Import\"}\n size={\"small\"}\n onClick={handleClickOpen}>\n <UploadIcon size={iconSize.small}/>\n </IconButton>\n </Tooltip>\n\n <Dialog open={open}\n fullWidth={step !== \"initial\"}\n fullHeight={step !== \"initial\"}\n maxWidth={step === \"initial\" ? \"lg\" : \"7xl\"}>\n\n <DialogTitle variant={\"h6\"} hidden={step === \"preview\"}>Import data</DialogTitle>\n\n <DialogContent className={\"h-full flex flex-col gap-4 my-4\"} fullHeight={step === \"preview\"}>\n\n {step === \"initial\" && <>\n <Typography variant={\"body2\"}>Upload a CSV, Excel or JSON file and map it to your existing\n schema</Typography>\n <ImportFileUpload onDataAdded={onDataAdded}/>\n </>}\n\n {step === \"mapping\" && <>\n <DataNewPropertiesMapping importConfig={importConfig}\n destinationProperties={properties}\n buildPropertyView={({\n isIdColumn,\n property,\n propertyKey,\n importKey\n }) => {\n return <PropertyTreeSelect\n selectedPropertyKey={propertyKey ?? \"\"}\n properties={properties}\n propertiesAndLevel={propertiesAndLevel}\n isIdColumn={isIdColumn}\n onIdSelected={() => {\n importConfig.setIdColumn(importKey);\n }}\n onPropertySelected={(newPropertyKey) => {\n\n onAnalyticsEvent?.(\"import_mapping_field_updated\");\n const remapped = remapImportColumn({\n headersMapping: importConfig.headersMapping,\n idColumn: importConfig.idColumn,\n column: importKey,\n targetKey: newPropertyKey\n });\n importConfig.setHeadersMapping(remapped.headersMapping);\n importConfig.setIdColumn(remapped.idColumn);\n\n }}\n />;\n }}/>\n </>}\n\n {step === \"preview\" && <ImportDataPreview importConfig={importConfig}\n properties={properties}\n propertiesOrder={propertiesOrder}/>}\n\n {step === \"import_data_saving\" && importConfig &&\n <ImportSaveInProgress importConfig={importConfig}\n collection={collection as AdminCollection}\n path={path}\n onImportSuccess={(importedCollection) => {\n handleClose();\n snackbarController.open({\n type: \"info\",\n message: \"Data imported successfully\"\n });\n }}\n />}\n\n </DialogContent>\n <DialogActions>\n\n {step === \"mapping\" && <Button\n onClick={() => setStep(\"initial\")}\n variant={\"text\"}>\n Back\n </Button>}\n\n {step === \"preview\" && <Button\n onClick={() => setStep(\"mapping\")}\n variant={\"text\"}>\n Back\n </Button>}\n\n <Button onClick={handleClose}\n variant={\"text\"}>\n Cancel\n </Button>\n\n {step === \"mapping\" && <Button variant=\"filled\"\n color={\"primary\"}\n onClick={onMappingComplete}>\n Next\n </Button>}\n\n {step === \"preview\" && <Button variant=\"filled\"\n color={\"primary\"}\n onClick={onPreviewComplete}>\n Save data\n </Button>}\n\n </DialogActions>\n </Dialog>\n\n </>;\n}\n\nconst internalIDValue = \"__internal_id__\";\n\nfunction PropertyTreeSelect({\n selectedPropertyKey,\n properties,\n onPropertySelected,\n onIdSelected,\n propertiesAndLevel,\n isIdColumn\n}: {\n selectedPropertyKey: string | null;\n properties: Record<string, Property>;\n onPropertySelected: (propertyKey: string | null) => void;\n onIdSelected: () => void;\n propertiesAndLevel: PropertyAndLevel[];\n isIdColumn?: boolean;\n}) {\n\n const selectedProperty = selectedPropertyKey ? getPropertyInPath(properties, selectedPropertyKey) : null;\n\n const renderValue = useCallback((selectedPropertyKey: string) => {\n\n if (selectedPropertyKey === internalIDValue) {\n return <Typography variant={\"body2\"} className={\"p-4\"}>Use this column as ID</Typography>;\n }\n\n if (!selectedPropertyKey || !selectedProperty) {\n return <Typography variant={\"body2\"} color=\"disabled\" className={\"p-4\"}>Do not import this\n property</Typography>;\n }\n\n return <PropertySelectEntry propertyKey={selectedPropertyKey}\n property={selectedProperty as Property}/>;\n }, [selectedProperty]);\n\n const onSelectValueChange = (value: string) => {\n if (value === internalIDValue) {\n // The column's property is let go first, which also lets go of\n // whichever column was the id; then this one becomes it.\n onPropertySelected(null);\n onIdSelected();\n } else if (value === \"__do_not_import\") {\n onPropertySelected(null);\n } else {\n onPropertySelected(value);\n }\n };\n\n // The same elements on every render: a remap re-renders every picker, and\n // fresh elements made each of them redraw its whole list.\n const propertyItems = useMemo(() => propertiesAndLevel.map(({\n property,\n level,\n propertyKey\n }) => {\n // A map with fields is filled from a column per field; a\n // key-value map, like a geopoint, takes a column whole.\n return <SelectItem value={propertyKey}\n key={propertyKey}\n textValue={property.name || propertyKey}\n disabled={property.type === \"map\" && !takesObjectWhole(property)}>\n <PropertySelectEntry propertyKey={propertyKey}\n property={property}\n level={level}/>\n </SelectItem>;\n }), [propertiesAndLevel]);\n\n return <Select value={isIdColumn ? internalIDValue : (selectedPropertyKey ?? undefined)}\n fullWidth={true}\n onValueChange={onSelectValueChange}\n renderValue={renderValue}>\n {DO_NOT_IMPORT_ITEM}\n {USE_AS_ID_ITEM}\n {propertyItems}\n </Select>;\n}\n\nconst DO_NOT_IMPORT_ITEM = <SelectItem value={\"__do_not_import\"}>\n <Typography variant={\"body2\"} color={\"disabled\"} className={\"p-4\"}>Do not import this property</Typography>\n</SelectItem>;\n\nconst USE_AS_ID_ITEM = <SelectItem value={internalIDValue}>\n <Typography variant={\"body2\"} className={\"p-4\"}>Use this column as ID</Typography>\n</SelectItem>;\n\ntype PropertyAndLevel = {\n property: Property,\n level: number,\n propertyKey: string\n};\n\nfunction getPropertiesAndLevel(key: string, property: Property, level: number): PropertyAndLevel[] {\n const properties: PropertyAndLevel[] = [];\n properties.push({\n property,\n level,\n propertyKey: key\n });\n if (property.type === \"map\" && property.properties) {\n Object.entries(property.properties).forEach(([childKey, value]) => {\n properties.push(...getPropertiesAndLevel(`${key}.${childKey}`, value as Property, level + 1));\n });\n }\n return properties;\n}\n\nexport function PropertySelectEntry({\n propertyKey,\n property,\n level = 0\n}: {\n propertyKey: string;\n property: Property;\n level?: number;\n}) {\n\n const { propertyConfigs } = useCustomizationController();\n const widget = getFieldConfig(property, propertyConfigs);\n\n return <div\n className=\"flex flex-row w-full text-start items-center h-full\">\n\n {new Array(level).fill(0).map((_, index) =>\n <div className={cls(defaultBorderMixin, \"ml-8 border-l h-12\")} key={index}/>)}\n\n <div className={\"m-4\"}>\n <Tooltip title={widget?.name}>\n <PropertyConfigBadge propertyConfig={widget}/>\n </Tooltip>\n </div>\n\n <div className={\"flex flex-col grow p-2 pl-2\"}>\n <Typography variant=\"body1\"\n component=\"span\"\n className=\"grow pr-2\">\n {property.name\n ? property.name\n : \"\\u00a0\"\n }\n </Typography>\n\n <Typography className=\" pr-2\"\n variant={\"body2\"}\n component=\"span\"\n color=\"secondary\">\n {propertyKey}\n </Typography>\n </div>\n\n </div>;\n\n}\n\nexport function ImportDataPreview<M extends Record<string, unknown>>({\n importConfig,\n properties,\n propertiesOrder\n}: {\n importConfig: ImportConfig,\n properties: Properties,\n propertiesOrder: Extract<keyof M, string>[],\n}) {\n const authController = useAuthController();\n const collectionRegistry = useCollectionRegistryController();\n const [problems, setProblems] = React.useState<ImportConversionProblem[]>([]);\n useEffect(() => {\n const converted = convertImportData(\n authController,\n collectionRegistry,\n importConfig.importData,\n importConfig.idColumn,\n importConfig.headersMapping,\n properties,\n \"TEMP_PATH\",\n importConfig.defaultValues\n );\n importConfig.setEntities(converted.entities);\n setProblems(converted.problems);\n }, []);\n\n const selectionController = useEntitySelectionController();\n\n return <div className={\"flex flex-col h-full w-full\"}>\n <ImportConversionProblems problems={problems}/>\n <div className={\"flex-1 min-h-0\"}>\n <CollectionTableBinding\n title={<div>\n <Typography variant={\"subtitle2\"}>Imported data preview</Typography>\n {/* Conditional because it is only true when a column was chosen as\n the id: without one, every row is created and nothing can be\n overwritten. With one, the import asks for an upsert — which it\n did not, back when this sentence was unconditional and false. */}\n <Typography variant={\"caption\"}>\n {importConfig.idColumn\n ? \"Entities with the same id will be overwritten\"\n : \"All rows will be imported as new entities\"}\n </Typography>\n </div>}\n tableController={{\n data: importConfig.entities,\n dataLoading: false,\n noMoreToLoad: false\n }}\n enablePopupIcon={false}\n endAdornment={<div className={\"h-12\"}/>}\n filterable={false}\n sortable={false}\n openEntityMode={\"full_screen\"}\n selectionController={selectionController}\n properties={properties}/>\n </div>\n </div>;\n\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,uBAA6E,EACzF,YACA,MACA,oBAIF;CAEE,MAAM,qBAAqB,sBAAsB;CAEjD,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS,KAAK;CAE5C,MAAM,CAAC,MAAM,WAAW,MAAM,SAAsB,SAAS;CAE7D,MAAM,eAAe,gBAAgB;CAErC,MAAM,kBAAkB,kBAAkB;EACtC,QAAQ,IAAI;EACZ,mBAAmB,aAAa;EAChC,QAAQ,SAAS;CACrB,GAAG,CAAC,gBAAgB,CAAC;CAErB,MAAM,cAAc,kBAAkB;EAClC,QAAQ,KAAK;CACjB,GAAG,CAAC,OAAO,CAAC;CAEZ,MAAM,oBAAoB,kBAAkB;EACxC,mBAAmB,yBAAyB;EAC5C,QAAQ,SAAS;CACrB,GAAG,CAAC,gBAAgB,CAAC;CAErB,MAAM,oBAAoB,kBAAkB;EACxC,mBAAmB,kBAAkB;EACrC,QAAQ,oBAAoB;CAChC,GAAG,CAAC,gBAAgB,CAAC;CAErB,MAAM,cAAc,OAAO,SAAmB;EAC1C,aAAa,cAAc,IAAI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5E,gBAAgB;EACZ,MAAM,YAAY,kBACd,gBACA,oBACA,aAAa,YACb,aAAa,UACb,aAAa,gBACb,YACA,aACA,aAAa,aACjB;EACA,aAAa,YAAY,UAAU,QAAQ;EAC3C,YAAY,UAAU,QAAQ;CAClC,GAAG,CAAC,CAAC;CAEL,MAAM,sBAAsB,6BAA6B;CAEzD,OAAO,qBAAC,OAAD;EAAK,WAAW;YAAhB,CACH,oBAAC,0BAAD,EAAoC,SAAU,CAAA,GAC9C,oBAAC,OAAD;GAAK,WAAW;aACZ,oBAAC,wBAAD;IACI,OAAO,qBAAC,OAAD,EAAA,UAAA,CACH,oBAAC,YAAD;KAAY,SAAS;eAAa;IAAiC,CAAA,GAKnE,oBAAC,YAAD;KAAY,SAAS;eAChB,aAAa,WACR,kDACA;IACE,CAAA,CACX,EAAA,CAAA;IACL,iBAAiB;KACb,MAAM,aAAa;KACnB,aAAa;KACb,cAAc;IAClB;IACA,iBAAiB;IACjB,cAAc,oBAAC,OAAD,EAAK,WAAW,OAAQ,CAAA;IACtC,YAAY;IACZ,UAAU;IACV,gBAAgB;IACK;IACT;GAAY,CAAA;EAC3B,CAAA,CACJ;;AAET"}
|
|
1
|
+
{"version":3,"file":"ImportCollectionAction.js","names":[],"sources":["../../../src/data_import/import/ImportCollectionAction.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo } from \"react\";\nimport {\n useAuthController,\n useCustomizationController,\n useSnackbarController\n} from \"@rebasepro/app\";\nimport { getPropertiesWithPropertiesOrder, getPropertyInPath } from \"../../util\";\nimport { User } from \"@rebasepro/types\";\nimport { CollectionActionsProps, AdminCollection, Properties, Property } from \"@rebasepro/cms-types\";\nimport { getFieldConfig } from \"../../components/field_configs\";\nimport { PropertyConfigBadge } from \"../../components/PropertyConfigBadge\";\nimport { useEntitySelectionController } from \"../../components/CollectionViewBinding/useSelectionController\";\nimport { CollectionTableBinding } from \"../../components/CollectionTableBinding/CollectionTableBinding\";\nimport { useCollectionRegistryController } from \"../../hooks\";\nimport {\n Button,\n cls,\n defaultBorderMixin,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n IconButton,\n iconSize,\n Select,\n SelectItem,\n Tooltip,\n Typography,\n UploadIcon\n} from \"@rebasepro/ui\";\nimport { buildEntityPropertiesFromData } from \"@rebasepro/inference\";\nimport { useImportConfig } from \"../hooks\";\nimport { convertImportData, getInferenceType, ImportConversionProblem } from \"../utils\";\nimport { guessIdColumn, remapImportColumn } from \"../utils/id_column\";\nimport { buildHeadersMappingFromData, takesObjectWhole } from \"../utils/import_columns\";\nimport { DataNewPropertiesMapping } from \"../components/DataNewPropertiesMapping\";\nimport { ImportFileUpload } from \"../components/ImportFileUpload\";\nimport { ImportSaveInProgress } from \"../components/ImportSaveInProgress\";\nimport { ImportConversionProblems } from \"../components/ImportConversionProblems\";\nimport { ImportConfig } from \"../types\";\n\ntype ImportState = \"initial\" | \"mapping\" | \"preview\" | \"import_data_saving\";\n\nexport function ImportCollectionAction<M extends Record<string, unknown>, USER extends User>({\n collection,\n path,\n onAnalyticsEvent\n}: CollectionActionsProps<M, USER> & {\n onAnalyticsEvent?: (event: string, params?: any) => void;\n}\n) {\n\n const snackbarController = useSnackbarController();\n\n const [open, setOpen] = React.useState(false);\n\n const [step, setStep] = React.useState<ImportState>(\"initial\");\n\n const importConfig = useImportConfig();\n\n const handleClickOpen = useCallback(() => {\n setOpen(true);\n onAnalyticsEvent?.(\"import_open\");\n setStep(\"initial\");\n }, [onAnalyticsEvent]);\n\n const handleClose = useCallback(() => {\n setOpen(false);\n }, [setOpen]);\n\n const onMappingComplete = useCallback(() => {\n onAnalyticsEvent?.(\"import_mapping_complete\");\n setStep(\"preview\");\n }, [onAnalyticsEvent]);\n\n const onPreviewComplete = useCallback(() => {\n onAnalyticsEvent?.(\"import_data_save\");\n setStep(\"import_data_saving\");\n }, [onAnalyticsEvent]);\n\n const onDataAdded = async (data: object[]) => {\n importConfig.setImportData(data);\n\n if (data.length > 0) {\n const originProperties = await buildEntityPropertiesFromData(data, getInferenceType);\n importConfig.setOriginProperties(originProperties as Properties);\n\n const headersMapping = buildHeadersMappingFromData(data, collection?.properties);\n importConfig.setHeadersMapping(headersMapping);\n importConfig.setIdColumn(guessIdColumn(Object.keys(headersMapping), headersMapping, collection?.properties));\n }\n setTimeout(() => {\n onAnalyticsEvent?.(\"import_data_added\");\n setStep(\"mapping\");\n }, 100);\n };\n\n // Built once per collection: every column's picker lists these, and a\n // list built afresh on each render redrew every picker on every remap.\n const properties = useMemo(\n () => getPropertiesWithPropertiesOrder(collection.properties, collection.propertiesOrder as Extract<keyof M, string>[]),\n [collection.properties, collection.propertiesOrder]\n );\n\n const propertiesAndLevel = useMemo(() => Object.entries(properties)\n .flatMap(([key, property]) => getPropertiesAndLevel(key, property, 0)), [properties]);\n const propertiesOrder = (collection.propertiesOrder ?? Object.keys(collection.properties)) as Extract<keyof M, string>[];\n\n return <>\n\n <Tooltip title={\"Import\"}\n asChild={true}>\n <IconButton aria-label={\"Import\"}\n size={\"small\"}\n onClick={handleClickOpen}>\n <UploadIcon size={iconSize.small}/>\n </IconButton>\n </Tooltip>\n\n <Dialog open={open}\n fullWidth={step !== \"initial\"}\n fullHeight={step !== \"initial\"}\n maxWidth={step === \"initial\" ? \"lg\" : \"7xl\"}>\n\n <DialogTitle variant={\"h6\"} hidden={step === \"preview\"}>Import data</DialogTitle>\n\n <DialogContent className={\"h-full flex flex-col gap-4 my-4\"} fullHeight={step === \"preview\"}>\n\n {step === \"initial\" && <>\n <Typography variant={\"body2\"}>Upload a CSV, Excel or JSON file and map it to your existing\n schema</Typography>\n <ImportFileUpload onDataAdded={onDataAdded}/>\n </>}\n\n {step === \"mapping\" && <>\n <DataNewPropertiesMapping importConfig={importConfig}\n destinationProperties={properties}\n buildPropertyView={({\n isIdColumn,\n property,\n propertyKey,\n importKey\n }) => {\n return <PropertyTreeSelect\n selectedPropertyKey={propertyKey ?? \"\"}\n properties={properties}\n propertiesAndLevel={propertiesAndLevel}\n isIdColumn={isIdColumn}\n onIdSelected={() => {\n importConfig.setIdColumn(importKey);\n }}\n onPropertySelected={(newPropertyKey) => {\n\n onAnalyticsEvent?.(\"import_mapping_field_updated\");\n const remapped = remapImportColumn({\n headersMapping: importConfig.headersMapping,\n idColumn: importConfig.idColumn,\n column: importKey,\n targetKey: newPropertyKey\n });\n importConfig.setHeadersMapping(remapped.headersMapping);\n importConfig.setIdColumn(remapped.idColumn);\n\n }}\n />;\n }}/>\n </>}\n\n {step === \"preview\" && <ImportDataPreview importConfig={importConfig}\n properties={properties}\n propertiesOrder={propertiesOrder}/>}\n\n {step === \"import_data_saving\" && importConfig &&\n <ImportSaveInProgress importConfig={importConfig}\n collection={collection as AdminCollection}\n path={path}\n onImportSuccess={(importedCollection) => {\n handleClose();\n snackbarController.open({\n type: \"info\",\n message: \"Data imported successfully\"\n });\n }}\n />}\n\n </DialogContent>\n <DialogActions>\n\n {step === \"mapping\" && <Button\n onClick={() => setStep(\"initial\")}\n variant={\"text\"}>\n Back\n </Button>}\n\n {step === \"preview\" && <Button\n onClick={() => setStep(\"mapping\")}\n variant={\"text\"}>\n Back\n </Button>}\n\n <Button onClick={handleClose}\n variant={\"text\"}>\n Cancel\n </Button>\n\n {step === \"mapping\" && <Button variant=\"filled\"\n color={\"primary\"}\n onClick={onMappingComplete}>\n Next\n </Button>}\n\n {step === \"preview\" && <Button variant=\"filled\"\n color={\"primary\"}\n onClick={onPreviewComplete}>\n Save data\n </Button>}\n\n </DialogActions>\n </Dialog>\n\n </>;\n}\n\nconst internalIDValue = \"__internal_id__\";\n\nfunction PropertyTreeSelect({\n selectedPropertyKey,\n properties,\n onPropertySelected,\n onIdSelected,\n propertiesAndLevel,\n isIdColumn\n}: {\n selectedPropertyKey: string | null;\n properties: Record<string, Property>;\n onPropertySelected: (propertyKey: string | null) => void;\n onIdSelected: () => void;\n propertiesAndLevel: PropertyAndLevel[];\n isIdColumn?: boolean;\n}) {\n\n const selectedProperty = selectedPropertyKey ? getPropertyInPath(properties, selectedPropertyKey) : null;\n\n const renderValue = useCallback((selectedPropertyKey: string) => {\n\n if (selectedPropertyKey === internalIDValue) {\n return <Typography variant={\"body2\"} className={\"p-4\"}>Use this column as ID</Typography>;\n }\n\n if (!selectedPropertyKey || !selectedProperty) {\n return <Typography variant={\"body2\"} color=\"disabled\" className={\"p-4\"}>Do not import this\n property</Typography>;\n }\n\n return <PropertySelectEntry propertyKey={selectedPropertyKey}\n property={selectedProperty as Property}/>;\n }, [selectedProperty]);\n\n const onSelectValueChange = (value: string) => {\n if (value === internalIDValue) {\n // The column's property is let go first, which also lets go of\n // whichever column was the id; then this one becomes it.\n onPropertySelected(null);\n onIdSelected();\n } else if (value === \"__do_not_import\") {\n onPropertySelected(null);\n } else {\n onPropertySelected(value);\n }\n };\n\n // The same elements on every render: a remap re-renders every picker, and\n // fresh elements made each of them redraw its whole list.\n const propertyItems = useMemo(() => propertiesAndLevel.map(({\n property,\n level,\n propertyKey\n }) => {\n // A map with fields is filled from a column per field; a\n // key-value map, like a geopoint, takes a column whole.\n return <SelectItem value={propertyKey}\n key={propertyKey}\n textValue={property.name || propertyKey}\n disabled={property.type === \"map\" && !takesObjectWhole(property)}>\n <PropertySelectEntry propertyKey={propertyKey}\n property={property}\n level={level}/>\n </SelectItem>;\n }), [propertiesAndLevel]);\n\n return <Select value={isIdColumn ? internalIDValue : (selectedPropertyKey ?? undefined)}\n fullWidth={true}\n onValueChange={onSelectValueChange}\n renderValue={renderValue}>\n {DO_NOT_IMPORT_ITEM}\n {USE_AS_ID_ITEM}\n {propertyItems}\n </Select>;\n}\n\nconst DO_NOT_IMPORT_ITEM = <SelectItem value={\"__do_not_import\"}>\n <Typography variant={\"body2\"} color={\"disabled\"} className={\"p-4\"}>Do not import this property</Typography>\n</SelectItem>;\n\nconst USE_AS_ID_ITEM = <SelectItem value={internalIDValue}>\n <Typography variant={\"body2\"} className={\"p-4\"}>Use this column as ID</Typography>\n</SelectItem>;\n\ntype PropertyAndLevel = {\n property: Property,\n level: number,\n propertyKey: string\n};\n\nfunction getPropertiesAndLevel(key: string, property: Property, level: number): PropertyAndLevel[] {\n const properties: PropertyAndLevel[] = [];\n properties.push({\n property,\n level,\n propertyKey: key\n });\n if (property.type === \"map\" && property.properties) {\n Object.entries(property.properties).forEach(([childKey, value]) => {\n properties.push(...getPropertiesAndLevel(`${key}.${childKey}`, value as Property, level + 1));\n });\n }\n return properties;\n}\n\nexport function PropertySelectEntry({\n propertyKey,\n property,\n level = 0\n}: {\n propertyKey: string;\n property: Property;\n level?: number;\n}) {\n\n const { propertyConfigs } = useCustomizationController();\n const widget = getFieldConfig(property, propertyConfigs);\n\n return <div\n className=\"flex flex-row w-full text-start items-center h-full\">\n\n {new Array(level).fill(0).map((_, index) =>\n <div className={cls(defaultBorderMixin, \"ml-8 border-l h-12\")} key={index}/>)}\n\n <div className={\"m-4\"}>\n <Tooltip title={widget?.name}>\n <PropertyConfigBadge propertyConfig={widget}/>\n </Tooltip>\n </div>\n\n <div className={\"flex flex-col grow p-2 pl-2\"}>\n <Typography variant=\"body1\"\n component=\"span\"\n className=\"grow pr-2\">\n {property.name\n ? property.name\n : \"\\u00a0\"\n }\n </Typography>\n\n <Typography className=\" pr-2\"\n variant={\"body2\"}\n component=\"span\"\n color=\"secondary\">\n {propertyKey}\n </Typography>\n </div>\n\n </div>;\n\n}\n\nexport function ImportDataPreview<M extends Record<string, unknown>>({\n importConfig,\n properties,\n propertiesOrder\n}: {\n importConfig: ImportConfig,\n properties: Properties,\n propertiesOrder: Extract<keyof M, string>[],\n}) {\n const authController = useAuthController();\n const collectionRegistry = useCollectionRegistryController();\n const [problems, setProblems] = React.useState<ImportConversionProblem[]>([]);\n useEffect(() => {\n const converted = convertImportData(\n authController,\n collectionRegistry,\n importConfig.importData,\n importConfig.idColumn,\n importConfig.headersMapping,\n properties,\n \"TEMP_PATH\",\n importConfig.defaultValues\n );\n importConfig.setEntities(converted.entities);\n setProblems(converted.problems);\n }, []);\n\n const selectionController = useEntitySelectionController();\n\n return <div className={\"flex flex-col h-full w-full\"}>\n <ImportConversionProblems problems={problems}/>\n <div className={\"flex-1 min-h-0\"}>\n <CollectionTableBinding\n title={<div>\n <Typography variant={\"subtitle2\"}>Imported data preview</Typography>\n {/* Conditional because it is only true when a column was chosen as\n the id: without one, every row is created and nothing can be\n overwritten. With one, the import asks for an upsert — which it\n did not, back when this sentence was unconditional and false. */}\n <Typography variant={\"caption\"}>\n {importConfig.idColumn\n ? \"Entities with the same id will be overwritten\"\n : \"All rows will be imported as new entities\"}\n </Typography>\n </div>}\n tableController={{\n data: importConfig.entities,\n dataLoading: false,\n noMoreToLoad: false\n }}\n enablePopupIcon={false}\n endAdornment={<div className={\"h-12\"}/>}\n filterable={false}\n sortable={false}\n openEntityMode={\"full_screen\"}\n selectionController={selectionController}\n properties={properties}/>\n </div>\n </div>;\n\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,uBAA6E,EACzF,YACA,MACA,oBAIF;CAEE,MAAM,qBAAqB,sBAAsB;CAEjD,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS,KAAK;CAE5C,MAAM,CAAC,MAAM,WAAW,MAAM,SAAsB,SAAS;CAE7D,MAAM,eAAe,gBAAgB;CAErC,MAAM,kBAAkB,kBAAkB;EACtC,QAAQ,IAAI;EACZ,mBAAmB,aAAa;EAChC,QAAQ,SAAS;CACrB,GAAG,CAAC,gBAAgB,CAAC;CAErB,MAAM,cAAc,kBAAkB;EAClC,QAAQ,KAAK;CACjB,GAAG,CAAC,OAAO,CAAC;CAEZ,MAAM,oBAAoB,kBAAkB;EACxC,mBAAmB,yBAAyB;EAC5C,QAAQ,SAAS;CACrB,GAAG,CAAC,gBAAgB,CAAC;CAErB,MAAM,oBAAoB,kBAAkB;EACxC,mBAAmB,kBAAkB;EACrC,QAAQ,oBAAoB;CAChC,GAAG,CAAC,gBAAgB,CAAC;CAErB,MAAM,cAAc,OAAO,SAAmB;EAC1C,aAAa,cAAc,IAA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C5E,gBAAgB;EACZ,MAAM,YAAY,kBACd,gBACA,oBACA,aAAa,YACb,aAAa,UACb,aAAa,gBACb,YACA,aACA,aAAa,aACjB;EACA,aAAa,YAAY,UAAU,QAAQ;EAC3C,YAAY,UAAU,QAAQ;CAClC,GAAG,CAAC,CAAC;CAEL,MAAM,sBAAsB,6BAA6B;CAEzD,OAAO,qBAAC,OAAD;EAAK,WAAW;YAAhB,CACH,oBAAC,0BAAD,EAAoC,SAAU,CAAA,GAC9C,oBAAC,OAAD;GAAK,WAAW;aACZ,oBAAC,wBAAD;IACI,OAAO,qBAAC,OAAD,EAAA,UAAA,CACH,oBAAC,YAAD;KAAY,SAAS;eAAa;IAAiC,CAAA,GAKnE,oBAAC,YAAD;KAAY,SAAS;eAChB,aAAa,WACR,kDACA;IACE,CAAA,CACX,EAAA,CAAA;IACL,iBAAiB;KACb,MAAM,aAAa;KACnB,aAAa;KACb,cAAc;IAClB;IACA,iBAAiB;IACjB,cAAc,oBAAC,OAAD,EAAK,WAAW,OAAQ,CAAA;IACtC,YAAY;IACZ,UAAU;IACV,gBAAgB;IACK;IACT;GAAY,CAAA;EAC3B,CAAA,CACJ;;AAET"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AuthController } from "@rebasepro/cms-types";
|
|
1
|
+
import { AuthController, CollectionRegistryController, DataType, Properties, Property, Entity } from "@rebasepro/cms-types";
|
|
3
2
|
import { ColumnTarget } from "./import_columns.js";
|
|
4
3
|
/** What the conversion asks of the collection registry: the collection a reference points into. */
|
|
5
4
|
export type ImportCollectionLookup = Pick<CollectionRegistryController, "getCollection">;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { getPropertyInPath } from "../../util/property_utils.js";
|
|
2
2
|
import { unflattenObject } from "./transforms.js";
|
|
3
3
|
import { importColumns } from "./import_columns.js";
|
|
4
|
-
import { isPropertyBuilder } from "@rebasepro/
|
|
5
|
-
import { EntityReference, GeoPoint, Vector } from "@rebasepro/types";
|
|
4
|
+
import { EntityReference, GeoPoint, Vector, isPropertyBuilder } from "@rebasepro/cms-types";
|
|
6
5
|
import { mergeDeep } from "@rebasepro/utils";
|
|
7
6
|
import { inferTypeFromValue, readNumberExactly } from "@rebasepro/inference";
|
|
8
7
|
//#region src/data_import/utils/data.ts
|