@rebasepro/cms 0.23.0 → 0.24.1-canary.g56af4a4
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/dist/collection_editor/CollectionEditorDialogsContext.js +10 -0
- package/dist/collection_editor/CollectionEditorDialogsContext.js.map +1 -0
- package/dist/collection_editor/ConfigControllerProvider.js +274 -0
- package/dist/collection_editor/ConfigControllerProvider.js.map +1 -0
- package/dist/collection_editor/_cms_internals.d.ts +2 -1
- package/dist/collection_editor/api/generateCollectionApi.js +64 -0
- package/dist/collection_editor/api/generateCollectionApi.js.map +1 -0
- package/dist/collection_editor/collection_wire.d.ts +13 -0
- package/dist/collection_editor/collection_wire.js +49 -0
- package/dist/collection_editor/collection_wire.js.map +1 -0
- package/dist/collection_editor/liveSchemaClient.d.ts +38 -18
- package/dist/collection_editor/liveSchemaClient.js +130 -0
- package/dist/collection_editor/liveSchemaClient.js.map +1 -0
- package/dist/collection_editor/relation_kinds.js +74 -0
- package/dist/collection_editor/relation_kinds.js.map +1 -0
- package/dist/collection_editor/serializable_types.d.ts +6 -1
- package/dist/collection_editor/serializable_utils.js +504 -0
- package/dist/collection_editor/serializable_utils.js.map +1 -0
- package/dist/collection_editor/types/config_controller.d.ts +11 -0
- package/dist/collection_editor/ui/EditorCollectionAction.js +37 -0
- package/dist/collection_editor/ui/EditorCollectionAction.js.map +1 -0
- package/dist/collection_editor/ui/MissingReferenceWidget.js +39 -0
- package/dist/collection_editor/ui/MissingReferenceWidget.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js +160 -0
- package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/AIModifiedPathsContext.js +61 -0
- package/dist/collection_editor/ui/collection_editor/AIModifiedPathsContext.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js +731 -0
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionEditorWelcomeView.js +220 -0
- package/dist/collection_editor/ui/collection_editor/CollectionEditorWelcomeView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionJsonImportDialog.js +160 -0
- package/dist/collection_editor/ui/collection_editor/CollectionJsonImportDialog.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js +394 -0
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js +616 -0
- package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionStudioView.js +68 -0
- package/dist/collection_editor/ui/collection_editor/CollectionStudioView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionYupValidation.js +11 -0
- package/dist/collection_editor/ui/collection_editor/CollectionYupValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.js +148 -0
- package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js +244 -0
- package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/EnumForm.js +222 -0
- package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js +204 -0
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/GetCodeDialog.js +108 -0
- package/dist/collection_editor/ui/collection_editor/GetCodeDialog.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js +163 -0
- package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/LayoutModeSwitch.js +59 -0
- package/dist/collection_editor/ui/collection_editor/LayoutModeSwitch.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.js +640 -0
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js +141 -0
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/PropertyTree.js +210 -0
- package/dist/collection_editor/ui/collection_editor/PropertyTree.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/RouterCollectionStudioView.js +31 -0
- package/dist/collection_editor/ui/collection_editor/RouterCollectionStudioView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/RouterCollectionsStudioView.js +25 -0
- package/dist/collection_editor/ui/collection_editor/RouterCollectionsStudioView.js.map +1 -0
- package/dist/{SchemaChangeDialog-BeP0A4MJ.js → collection_editor/ui/collection_editor/SchemaChangeDialog.js} +73 -69
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/SwitchControl.js +24 -0
- package/dist/collection_editor/ui/collection_editor/SwitchControl.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/ViewModeSwitch.js +66 -0
- package/dist/collection_editor/ui/collection_editor/ViewModeSwitch.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js +61 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js +188 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.d.ts +12 -0
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js +74 -0
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js +100 -0
- package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/BooleanPropertyField.js +34 -0
- package/dist/collection_editor/ui/collection_editor/properties/BooleanPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/CommonPropertyFields.js +75 -0
- package/dist/collection_editor/ui/collection_editor/properties/CommonPropertyFields.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js +338 -0
- package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +83 -0
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/KeyValuePropertyField.js +15 -0
- package/dist/collection_editor/ui/collection_editor/properties/KeyValuePropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js +121 -0
- package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js +127 -0
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js +151 -0
- package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js +77 -0
- package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js +254 -0
- package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js +71 -0
- package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js +356 -0
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js +173 -0
- package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/UrlPropertyField.js +79 -0
- package/dist/collection_editor/ui/collection_editor/properties/UrlPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/VectorPropertyField.js +34 -0
- package/dist/collection_editor/ui/collection_editor/properties/VectorPropertyField.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.js +47 -0
- package/dist/collection_editor/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/ArrayPropertyValidation.js +47 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/ArrayPropertyValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/GeneralPropertyValidation.js +62 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/GeneralPropertyValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/NumberPropertyValidation.js +119 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/NumberPropertyValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.d.ts +10 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.js +178 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/StringPropertyValidation.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/ValidationPanel.js +23 -0
- package/dist/collection_editor/ui/collection_editor/properties/validation/ValidationPanel.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/templates/blog_template.js +116 -0
- package/dist/collection_editor/ui/collection_editor/templates/blog_template.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/templates/pages_template.js +182 -0
- package/dist/collection_editor/ui/collection_editor/templates/pages_template.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/templates/products_template.js +87 -0
- package/dist/collection_editor/ui/collection_editor/templates/products_template.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/templates/users_template.js +46 -0
- package/dist/collection_editor/ui/collection_editor/templates/users_template.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/util.js +20 -0
- package/dist/collection_editor/ui/collection_editor/util.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/utils/strings.js +2 -0
- package/dist/collection_editor/ui/collection_editor/utils/supported_fields.js +37 -0
- package/dist/collection_editor/ui/collection_editor/utils/supported_fields.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js +192 -0
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js.map +1 -0
- package/dist/collection_editor/useCollectionEditorController.js +12 -0
- package/dist/collection_editor/useCollectionEditorController.js.map +1 -0
- package/dist/collection_editor/useCollectionsConfigController.js +12 -0
- package/dist/collection_editor/useCollectionsConfigController.js.map +1 -0
- package/dist/collection_editor/useJsonCollectionsConfigController.js +191 -0
- package/dist/collection_editor/useJsonCollectionsConfigController.js.map +1 -0
- package/dist/collection_editor/useLiveSchemaEditing.d.ts +5 -5
- package/dist/collection_editor/useLiveSchemaEditing.js +214 -0
- package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -0
- package/dist/collection_editor/useLocalCollectionsConfigController.d.ts +7 -0
- package/dist/collection_editor/useLocalCollectionsConfigController.js +228 -0
- package/dist/collection_editor/useLocalCollectionsConfigController.js.map +1 -0
- package/dist/collection_editor/useSafeSnackbarController.js +13 -0
- package/dist/collection_editor/useSafeSnackbarController.js.map +1 -0
- package/dist/collection_editor/validateCollectionJson.js +289 -0
- package/dist/collection_editor/validateCollectionJson.js.map +1 -0
- package/dist/collection_editor_ui.js +7 -33
- package/dist/components/AdditionalFieldValue.js +60 -0
- package/dist/components/AdditionalFieldValue.js.map +1 -0
- package/dist/components/AdminModeSyncer.js +41 -0
- package/dist/components/AdminModeSyncer.js.map +1 -0
- package/dist/components/ArrayContainer.d.ts +8 -2
- package/dist/components/ArrayContainer.js +363 -0
- package/dist/components/ArrayContainer.js.map +1 -0
- package/dist/components/ClearFilterSortButton.d.ts +7 -1
- package/dist/components/ClearFilterSortButton.js +33 -0
- package/dist/components/ClearFilterSortButton.js.map +1 -0
- package/dist/components/CollectionEditorDialogs.js +49 -0
- package/dist/components/CollectionEditorDialogs.js.map +1 -0
- package/dist/components/CollectionPanel.js +95 -0
- package/dist/components/CollectionPanel.js.map +1 -0
- package/dist/components/CollectionTableBinding/CollectionRowActions.js +165 -0
- package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -0
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js +329 -0
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -0
- package/dist/components/CollectionTableBinding/PropertyTableCell.js +311 -0
- package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -0
- package/dist/components/CollectionTableBinding/column_utils.js +85 -0
- package/dist/components/CollectionTableBinding/column_utils.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/CompactEntityCellField.js +45 -0
- package/dist/components/CollectionTableBinding/fields/CompactEntityCellField.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +66 -0
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +86 -0
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js +93 -0
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js +33 -0
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js +171 -0
- package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js +91 -0
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js.map +1 -0
- package/dist/components/CollectionTableBinding/fields/VirtualTableUserSelect.js +36 -0
- package/dist/components/CollectionTableBinding/fields/VirtualTableUserSelect.js.map +1 -0
- package/dist/components/CollectionTableBinding/index.js +6 -0
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js +50 -0
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/EntityTableCell.d.ts +2 -0
- package/dist/components/CollectionTableBinding/internal/EntityTableCell.js +223 -0
- package/dist/components/CollectionTableBinding/internal/EntityTableCell.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/EntityTableCellActions.js +58 -0
- package/dist/components/CollectionTableBinding/internal/EntityTableCellActions.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/TableCellOpener.js +53 -0
- package/dist/components/CollectionTableBinding/internal/TableCellOpener.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/common.js +40 -0
- package/dist/components/CollectionTableBinding/internal/common.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +270 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/useDraggable.js +68 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/useDraggable.js.map +1 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/useWindowSize.js +24 -0
- package/dist/components/CollectionTableBinding/internal/popup_field/useWindowSize.js.map +1 -0
- package/dist/components/CollectionTableBinding/table_bindings.js +306 -0
- package/dist/components/CollectionTableBinding/table_bindings.js.map +1 -0
- package/dist/components/CollectionViewBinding/BoardCardBinding.js +160 -0
- package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +471 -0
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js +108 -0
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +988 -0
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewActions.d.ts +6 -1
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +146 -0
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +5 -2
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js +1209 -0
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js +133 -0
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntityCardBinding.js +133 -0
- package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -0
- package/dist/components/CollectionViewBinding/FilterPresetsButton.js +203 -0
- package/dist/components/CollectionViewBinding/FilterPresetsButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/FiltersDialog.d.ts +5 -0
- package/dist/components/CollectionViewBinding/FiltersDialog.js +148 -0
- package/dist/components/CollectionViewBinding/FiltersDialog.js.map +1 -0
- package/dist/components/CollectionViewBinding/SearchExplanation.js +86 -0
- package/dist/components/CollectionViewBinding/SearchExplanation.js.map +1 -0
- package/dist/components/CollectionViewBinding/SearchHighlight.js +262 -0
- package/dist/components/CollectionViewBinding/SearchHighlight.js.map +1 -0
- package/dist/components/CollectionViewBinding/SlotValue.js +117 -0
- package/dist/components/CollectionViewBinding/SlotValue.js.map +1 -0
- package/dist/components/CollectionViewBinding/SortButton.js +214 -0
- package/dist/components/CollectionViewBinding/SortButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitListCloseButton.js +41 -0
- package/dist/components/CollectionViewBinding/SplitListCloseButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitListShowButton.js +29 -0
- package/dist/components/CollectionViewBinding/SplitListShowButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitListView.js +311 -0
- package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitViewContext.js +21 -0
- package/dist/components/CollectionViewBinding/SplitViewContext.js.map +1 -0
- package/dist/components/CollectionViewBinding/ViewModeToggle.js +150 -0
- package/dist/components/CollectionViewBinding/ViewModeToggle.js.map +1 -0
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js +49 -0
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js.map +1 -0
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js +122 -0
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js.map +1 -0
- package/dist/components/CollectionViewBinding/useBoardDataController.js +530 -0
- package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +4 -1
- package/dist/components/CollectionViewBinding/usePreviewSlots.js +384 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -0
- package/dist/components/CollectionViewBinding/useSelectionController.js +104 -0
- package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -0
- package/dist/components/CollectionViewBinding/utils.js +21 -0
- package/dist/components/CollectionViewBinding/utils.js.map +1 -0
- package/dist/components/DefaultAppBar.js +179 -0
- package/dist/components/DefaultAppBar.js.map +1 -0
- package/dist/components/DefaultDrawer.js +364 -0
- package/dist/components/DefaultDrawer.js.map +1 -0
- package/dist/components/DeleteEntityDialog.js +256 -0
- package/dist/components/DeleteEntityDialog.js.map +1 -0
- package/dist/components/DetailViewBinding.js +504 -0
- package/dist/components/DetailViewBinding.js.map +1 -0
- package/dist/components/DrawerNavigationGroup.js +74 -0
- package/dist/components/DrawerNavigationGroup.js.map +1 -0
- package/dist/components/DrawerNavigationItem.d.ts +8 -0
- package/dist/components/DrawerNavigationItem.js +45 -0
- package/dist/components/DrawerNavigationItem.js.map +1 -0
- package/dist/components/EditFormActions.js +210 -0
- package/dist/components/EditFormActions.js.map +1 -0
- package/dist/components/EditViewBinding.d.ts +7 -1
- package/dist/components/EditViewBinding.js +802 -0
- package/dist/components/EditViewBinding.js.map +1 -0
- package/dist/components/EntityDisplayHeader.js +139 -0
- package/dist/components/EntityDisplayHeader.js.map +1 -0
- package/dist/components/EntityIdentityBar.d.ts +29 -4
- package/dist/components/EntityIdentityBar.js +364 -0
- package/dist/components/EntityIdentityBar.js.map +1 -0
- package/dist/components/EntityInspector.js +96 -0
- package/dist/components/EntityInspector.js.map +1 -0
- package/dist/components/EntityPreviewBinding.js +282 -0
- package/dist/components/EntityPreviewBinding.js.map +1 -0
- package/dist/components/EntityPreviewNesting.js +53 -0
- package/dist/components/EntityPreviewNesting.js.map +1 -0
- package/dist/components/EntityViewBinding.js +246 -0
- package/dist/components/EntityViewBinding.js.map +1 -0
- package/dist/components/FieldCaption.js +17 -0
- package/dist/components/FieldCaption.js.map +1 -0
- package/dist/components/HomePage/ContentHomePage.js +326 -0
- package/dist/components/HomePage/ContentHomePage.js.map +1 -0
- package/dist/components/HomePage/FavouritesView.js +44 -0
- package/dist/components/HomePage/FavouritesView.js.map +1 -0
- package/dist/components/HomePage/HomePageDnD.js +436 -0
- package/dist/components/HomePage/HomePageDnD.js.map +1 -0
- package/dist/components/HomePage/NavigationCard.js +59 -0
- package/dist/components/HomePage/NavigationCard.js.map +1 -0
- package/dist/components/HomePage/NavigationCardBinding.js +70 -0
- package/dist/components/HomePage/NavigationCardBinding.js.map +1 -0
- package/dist/components/HomePage/NavigationGroup.js +98 -0
- package/dist/components/HomePage/NavigationGroup.js.map +1 -0
- package/dist/components/HomePage/RenameGroupDialog.js +89 -0
- package/dist/components/HomePage/RenameGroupDialog.js.map +1 -0
- package/dist/components/InlineEntityPreview.js +116 -0
- package/dist/components/InlineEntityPreview.js.map +1 -0
- package/dist/{JsonPreviewBinding-v0w3H0fp.js → components/JsonPreviewBinding.js} +2 -2
- package/dist/components/JsonPreviewBinding.js.map +1 -0
- package/dist/components/NavigationLoadingErrorView.d.ts +16 -0
- package/dist/components/NavigationLoadingErrorView.js +27 -0
- package/dist/components/NavigationLoadingErrorView.js.map +1 -0
- package/dist/components/PickerTrigger.js +27 -0
- package/dist/components/PickerTrigger.js.map +1 -0
- package/dist/components/PropertyCollectionView.js +215 -0
- package/dist/components/PropertyCollectionView.js.map +1 -0
- package/dist/components/PropertyConfigBadge.js +19 -0
- package/dist/components/PropertyConfigBadge.js.map +1 -0
- package/dist/components/PropertyKeyHint.js +58 -0
- package/dist/components/PropertyKeyHint.js.map +1 -0
- package/dist/components/RebaseAuthGate.js +35 -0
- package/dist/components/RebaseAuthGate.js.map +1 -0
- package/dist/components/RebaseCMS.js +44 -0
- package/dist/components/RebaseCMS.js.map +1 -0
- package/dist/components/RebaseLayout.js +59 -0
- package/dist/components/RebaseLayout.js.map +1 -0
- package/dist/components/RebaseNavigation.js +211 -0
- package/dist/components/RebaseNavigation.js.map +1 -0
- package/dist/components/RebaseRouteDefs.js +96 -0
- package/dist/components/RebaseRouteDefs.js.map +1 -0
- package/dist/components/RebaseShell.js +50 -0
- package/dist/components/RebaseShell.js.map +1 -0
- package/dist/components/ReferenceTable/SelectionTableBinding.js +224 -0
- package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -0
- package/dist/components/ReferenceWidget.js +100 -0
- package/dist/components/ReferenceWidget.js.map +1 -0
- package/dist/components/RelationSelector.js +625 -0
- package/dist/components/RelationSelector.js.map +1 -0
- package/dist/components/SearchIconsView.js +52 -0
- package/dist/components/SearchIconsView.js.map +1 -0
- package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
- package/dist/components/SelectableTable/SelectableTable.js +158 -0
- package/dist/components/SelectableTable/SelectableTable.js.map +1 -0
- package/dist/components/SelectableTable/SelectableTableContext.js +8 -0
- package/dist/components/SelectableTable/SelectableTableContext.js.map +1 -0
- package/dist/components/SelectableTable/SelectionStore.js +29 -0
- package/dist/components/SelectableTable/SelectionStore.js.map +1 -0
- package/dist/components/SelectableTable/filters/BooleanFilterField.js +28 -0
- package/dist/components/SelectableTable/filters/BooleanFilterField.js.map +1 -0
- package/dist/components/SelectableTable/filters/DateTimeFilterField.d.ts +2 -1
- package/dist/components/SelectableTable/filters/DateTimeFilterField.js +93 -0
- package/dist/components/SelectableTable/filters/DateTimeFilterField.js.map +1 -0
- package/dist/components/SelectableTable/filters/FilterFieldBinding.js +132 -0
- package/dist/components/SelectableTable/filters/FilterFieldBinding.js.map +1 -0
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js +157 -0
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -0
- package/dist/components/SelectableTable/filters/RelationFilterField.js +169 -0
- package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -0
- package/dist/components/SelectableTable/filters/StringNumberFilterField.js +181 -0
- package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -0
- package/dist/components/SelectableTable/filters/null_filter.js +36 -0
- package/dist/components/SelectableTable/filters/null_filter.js.map +1 -0
- package/dist/components/SideDialogs.js +149 -0
- package/dist/components/SideDialogs.js.map +1 -0
- package/dist/components/SidePanelBinding.js +287 -0
- package/dist/components/SidePanelBinding.js.map +1 -0
- package/dist/components/SidePanelProvider.js +69 -0
- package/dist/components/SidePanelProvider.js.map +1 -0
- package/dist/components/UserSelector.d.ts +2 -0
- package/dist/components/UserSelector.js +418 -0
- package/dist/components/UserSelector.js.map +1 -0
- package/dist/components/admin/CreationResultDialog.js +118 -0
- package/dist/components/admin/CreationResultDialog.js.map +1 -0
- package/dist/components/app/AppBar.js +14 -0
- package/dist/components/app/AppBar.js.map +1 -0
- package/dist/components/app/Drawer.js +26 -0
- package/dist/components/app/Drawer.js.map +1 -0
- package/dist/components/app/Scaffold.js +229 -0
- package/dist/components/app/Scaffold.js.map +1 -0
- package/dist/components/app/useApp.js +24 -0
- package/dist/components/app/useApp.js.map +1 -0
- package/dist/components/common/ActionMenuLabel.d.ts +15 -0
- package/dist/components/common/ActionMenuLabel.js +30 -0
- package/dist/components/common/ActionMenuLabel.js.map +1 -0
- package/dist/components/common/default_entity_actions.d.ts +37 -0
- package/dist/components/common/default_entity_actions.js +590 -0
- package/dist/components/common/default_entity_actions.js.map +1 -0
- package/dist/components/drawer_expansion.d.ts +25 -0
- package/dist/components/drawer_expansion.js +44 -0
- package/dist/components/drawer_expansion.js.map +1 -0
- package/dist/components/field_configs.d.ts +2 -2
- package/dist/components/field_configs.js +431 -0
- package/dist/components/field_configs.js.map +1 -0
- package/dist/components/field_ids.d.ts +11 -0
- package/dist/components/field_ids.js +58 -0
- package/dist/components/field_ids.js.map +1 -0
- package/dist/components/history/EntityHistoryEntry.js +151 -0
- package/dist/components/history/EntityHistoryEntry.js.map +1 -0
- package/dist/components/history/EntityHistoryView.js +157 -0
- package/dist/components/history/EntityHistoryView.js.map +1 -0
- package/dist/components/history/UserChip.js +21 -0
- package/dist/components/history/UserChip.js.map +1 -0
- package/dist/components/history/index.js +4 -0
- package/dist/components/lazy_record_views.d.ts +10 -0
- package/dist/components/lazy_record_views.js +57 -0
- package/dist/components/lazy_record_views.js.map +1 -0
- package/dist/contexts/BreacrumbsContext.js +28 -0
- package/dist/contexts/BreacrumbsContext.js.map +1 -0
- package/dist/contexts/EditorAIControllerContext.d.ts +18 -0
- package/dist/contexts/EditorAIControllerContext.js +29 -0
- package/dist/contexts/EditorAIControllerContext.js.map +1 -0
- package/dist/contexts/SideDialogsControllerContext.js +7 -0
- package/dist/contexts/SideDialogsControllerContext.js.map +1 -0
- package/dist/data_export/export/BasicExportAction.js +151 -0
- package/dist/data_export/export/BasicExportAction.js.map +1 -0
- package/dist/data_export/export/ExportCollectionAction.js +297 -0
- package/dist/data_export/export/ExportCollectionAction.js.map +1 -0
- package/dist/data_export/export/additional_fields.js +40 -0
- package/dist/data_export/export/additional_fields.js.map +1 -0
- package/dist/data_export/export/export.d.ts +35 -0
- package/dist/data_export/export/export.js +400 -0
- package/dist/data_export/export/export.js.map +1 -0
- package/dist/data_export/export/fetch_export_data.d.ts +17 -7
- package/dist/data_export/export/fetch_export_data.js +67 -0
- package/dist/data_export/export/fetch_export_data.js.map +1 -0
- package/dist/data_export/export/index.d.ts +4 -2
- package/dist/data_export/export/index.js +5 -0
- package/dist/data_import/components/DataNewPropertiesMapping.js +207 -0
- package/dist/data_import/components/DataNewPropertiesMapping.js.map +1 -0
- package/dist/data_import/components/ImportConversionProblems.d.ts +11 -0
- package/dist/data_import/components/ImportConversionProblems.js +89 -0
- package/dist/data_import/components/ImportConversionProblems.js.map +1 -0
- package/dist/data_import/components/ImportFileUpload.js +43 -0
- package/dist/data_import/components/ImportFileUpload.js.map +1 -0
- package/dist/data_import/components/ImportNewPropertyFieldPreview.js +42 -0
- package/dist/data_import/components/ImportNewPropertyFieldPreview.js.map +1 -0
- package/dist/data_import/components/ImportSaveInProgress.js +105 -0
- package/dist/data_import/components/ImportSaveInProgress.js.map +1 -0
- package/dist/data_import/components/index.d.ts +1 -0
- package/dist/data_import/hooks/useImportConfig.js +34 -0
- package/dist/data_import/hooks/useImportConfig.js.map +1 -0
- package/dist/{import-TCgkTVlS.js → data_import/import/ImportCollectionAction.js} +84 -92
- package/dist/data_import/import/ImportCollectionAction.js.map +1 -0
- package/dist/data_import/import/index.js +2 -0
- package/dist/data_import/utils/csv.js +146 -0
- package/dist/data_import/utils/csv.js.map +1 -0
- package/dist/data_import/utils/data.d.ts +81 -4
- package/dist/data_import/utils/data.js +366 -0
- package/dist/data_import/utils/data.js.map +1 -0
- package/dist/data_import/utils/file_headers.js +32 -0
- package/dist/data_import/utils/file_headers.js.map +1 -0
- package/dist/data_import/utils/file_to_json.js +149 -0
- package/dist/data_import/utils/file_to_json.js.map +1 -0
- package/dist/data_import/utils/get_import_inference_type.js +14 -0
- package/dist/data_import/utils/get_import_inference_type.js.map +1 -0
- package/dist/data_import/utils/id_column.js +27 -0
- package/dist/data_import/utils/id_column.js.map +1 -0
- package/dist/data_import/utils/import_columns.d.ts +48 -0
- package/dist/data_import/utils/import_columns.js +92 -0
- package/dist/data_import/utils/import_columns.js.map +1 -0
- package/dist/data_import/utils/save_entities.d.ts +33 -4
- package/dist/data_import/utils/save_entities.js +244 -0
- package/dist/data_import/utils/save_entities.js.map +1 -0
- package/dist/data_import/utils/transforms.js +83 -0
- package/dist/data_import/utils/transforms.js.map +1 -0
- package/dist/editor/components/SlashCommandMenu.js +497 -0
- package/dist/editor/components/SlashCommandMenu.js.map +1 -0
- package/dist/editor/components/editor-bubble-item.js +24 -0
- package/dist/editor/components/editor-bubble-item.js.map +1 -0
- package/dist/editor/components/editor-bubble.js +97 -0
- package/dist/editor/components/editor-bubble.js.map +1 -0
- package/dist/editor/components/image-bubble.js +148 -0
- package/dist/editor/components/image-bubble.js.map +1 -0
- package/dist/editor/components/table-bubble.js +406 -0
- package/dist/editor/components/table-bubble.js.map +1 -0
- package/dist/editor/editor.d.ts +7 -1
- package/dist/editor/editor.js +423 -0
- package/dist/editor/editor.js.map +1 -0
- package/dist/editor/extensions/HighlightDecorationExtension.js +74 -0
- package/dist/editor/extensions/HighlightDecorationExtension.js.map +1 -0
- package/dist/editor/extensions/Image.d.ts +28 -1
- package/dist/editor/extensions/Image.js +160 -0
- package/dist/editor/extensions/Image.js.map +1 -0
- package/dist/editor/extensions/TextLoadingDecorationExtension.js +82 -0
- package/dist/editor/extensions/TextLoadingDecorationExtension.js.map +1 -0
- package/dist/editor/extensions/clipboard.js +63 -0
- package/dist/editor/extensions/clipboard.js.map +1 -0
- package/dist/editor/extensions/drag-and-drop.js +354 -0
- package/dist/editor/extensions/drag-and-drop.js.map +1 -0
- package/dist/editor/hooks/useProseMirror.d.ts +4 -1
- package/dist/editor/hooks/useProseMirror.js +101 -0
- package/dist/editor/hooks/useProseMirror.js.map +1 -0
- package/dist/editor/hooks/useProseMirrorContext.js +11 -0
- package/dist/editor/hooks/useProseMirrorContext.js.map +1 -0
- package/dist/editor/markdown.js +154 -0
- package/dist/editor/markdown.js.map +1 -0
- package/dist/editor/nodeViews/ImageComponent.js +35 -0
- package/dist/editor/nodeViews/ImageComponent.js.map +1 -0
- package/dist/editor/nodeViews/ReactNodeView.js +57 -0
- package/dist/editor/nodeViews/ReactNodeView.js.map +1 -0
- package/dist/editor/nodeViews/TaskItemComponent.js +29 -0
- package/dist/editor/nodeViews/TaskItemComponent.js.map +1 -0
- package/dist/editor/nodeViews/index.js +21 -0
- package/dist/editor/nodeViews/index.js.map +1 -0
- package/dist/editor/plugins/index.js +54 -0
- package/dist/editor/plugins/index.js.map +1 -0
- package/dist/editor/plugins/inputrules.js +54 -0
- package/dist/editor/plugins/inputrules.js.map +1 -0
- package/dist/editor/plugins/placeholderPlugin.js +38 -0
- package/dist/editor/plugins/placeholderPlugin.js.map +1 -0
- package/dist/editor/plugins/slashCommandPlugin.js +40 -0
- package/dist/editor/plugins/slashCommandPlugin.js.map +1 -0
- package/dist/editor/sanitize-html.js +190 -0
- package/dist/editor/sanitize-html.js.map +1 -0
- package/dist/{markdown-CCqp8ibf.js → editor/schema.js} +2 -159
- package/dist/editor/schema.js.map +1 -0
- package/dist/editor/selectors/link-selector.js +118 -0
- package/dist/editor/selectors/link-selector.js.map +1 -0
- package/dist/editor/selectors/node-selector.js +118 -0
- package/dist/editor/selectors/node-selector.js.map +1 -0
- package/dist/editor/selectors/text-buttons.js +71 -0
- package/dist/editor/selectors/text-buttons.js.map +1 -0
- package/dist/editor/utils/prosemirror-utils.js +92 -0
- package/dist/editor/utils/prosemirror-utils.js.map +1 -0
- package/dist/editor/utils/remove_classes.js +16 -0
- package/dist/editor/utils/remove_classes.js.map +1 -0
- package/dist/editor.js +1 -3085
- package/dist/form/EntityForm.js +734 -0
- package/dist/form/EntityForm.js.map +1 -0
- package/dist/form/EntityFormActions.js +101 -0
- package/dist/form/EntityFormActions.js.map +1 -0
- package/dist/form/EntityFormBinding.js +257 -0
- package/dist/form/EntityFormBinding.js.map +1 -0
- package/dist/form/PropertyFieldBinding.js +298 -0
- package/dist/form/PropertyFieldBinding.js.map +1 -0
- package/dist/form/components/ErrorFocus.js +33 -0
- package/dist/form/components/ErrorFocus.js.map +1 -0
- package/dist/form/components/FieldBlock.js +118 -0
- package/dist/form/components/FieldBlock.js.map +1 -0
- package/dist/form/components/FieldHelperText.js +56 -0
- package/dist/form/components/FieldHelperText.js.map +1 -0
- package/dist/form/components/FormRail.js +118 -0
- package/dist/form/components/FormRail.js.map +1 -0
- package/dist/form/components/FormSections.js +63 -0
- package/dist/form/components/FormSections.js.map +1 -0
- package/dist/form/components/LabelWithIcon.js +29 -0
- package/dist/form/components/LabelWithIcon.js.map +1 -0
- package/dist/form/components/LocalChangesMenu.js +127 -0
- package/dist/form/components/LocalChangesMenu.js.map +1 -0
- package/dist/form/components/StorageItemPreview.js +46 -0
- package/dist/form/components/StorageItemPreview.js.map +1 -0
- package/dist/form/components/StorageUploadProgress.js +84 -0
- package/dist/form/components/StorageUploadProgress.js.map +1 -0
- package/dist/form/components/useRailVisible.js +43 -0
- package/dist/form/components/useRailVisible.js.map +1 -0
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js +84 -0
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +125 -0
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/BinaryFieldBinding.js +135 -0
- package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/BlockFieldBinding.js +164 -0
- package/dist/form/field_bindings/BlockFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/DateTimeFieldBinding.js +47 -0
- package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/GeopointFieldBinding.js +148 -0
- package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/KeyValueFieldBinding.js +450 -0
- package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/MapFieldBinding.js +77 -0
- package/dist/form/field_bindings/MapFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +215 -0
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/MultiSelectFieldBinding.js +88 -0
- package/dist/form/field_bindings/MultiSelectFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js +118 -0
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js +52 -0
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/ReferenceFieldBinding.js +99 -0
- package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/RelationFieldBinding.js +135 -0
- package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/RepeatFieldBinding.js +103 -0
- package/dist/form/field_bindings/RepeatFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/SelectFieldBinding.js +80 -0
- package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/StorageUploadFieldBinding.js +266 -0
- package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/SwitchFieldBinding.js +41 -0
- package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/TextFieldBinding.js +114 -0
- package/dist/form/field_bindings/TextFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/UserSelectFieldBinding.js +48 -0
- package/dist/form/field_bindings/UserSelectFieldBinding.js.map +1 -0
- package/dist/form/field_bindings/VectorFieldBinding.js +147 -0
- package/dist/form/field_bindings/VectorFieldBinding.js.map +1 -0
- package/dist/form/form_keyboard_scope.d.ts +26 -0
- package/dist/form/form_keyboard_scope.js +39 -0
- package/dist/form/form_keyboard_scope.js.map +1 -0
- package/dist/form/form_uploads.d.ts +24 -0
- package/dist/form/form_uploads.js +31 -0
- package/dist/form/form_uploads.js.map +1 -0
- package/dist/form/form_utils.d.ts +48 -0
- package/dist/form/form_utils.js +280 -0
- package/dist/form/form_utils.js.map +1 -0
- package/dist/form/resolve_cell_property.d.ts +32 -0
- package/dist/form/resolve_cell_property.js +80 -0
- package/dist/form/resolve_cell_property.js.map +1 -0
- package/dist/form/resolve_form_properties.d.ts +27 -0
- package/dist/form/resolve_form_properties.js +78 -0
- package/dist/form/resolve_form_properties.js.map +1 -0
- package/dist/form/useClearRestoreValue.js +27 -0
- package/dist/form/useClearRestoreValue.js.map +1 -0
- package/dist/form/useUndoableDiscard.js +36 -0
- package/dist/form/useUndoableDiscard.js.map +1 -0
- package/dist/form/validation.d.ts +20 -0
- package/dist/form/validation.js +416 -0
- package/dist/form/validation.js.map +1 -0
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.js +22 -0
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.js.map +1 -0
- package/dist/hooks/navigation/contexts/NavigationStateContext.js +15 -0
- package/dist/hooks/navigation/contexts/NavigationStateContext.js.map +1 -0
- package/dist/hooks/navigation/contexts/UrlContext.js +22 -0
- package/dist/hooks/navigation/contexts/UrlContext.js.map +1 -0
- package/dist/hooks/navigation/useAsyncResolver.js +68 -0
- package/dist/hooks/navigation/useAsyncResolver.js.map +1 -0
- package/dist/hooks/navigation/useBuildCollectionRegistryController.js +141 -0
- package/dist/hooks/navigation/useBuildCollectionRegistryController.js.map +1 -0
- package/dist/hooks/navigation/useBuildNavigationStateController.js +77 -0
- package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -0
- package/dist/hooks/navigation/useBuildUrlController.js +57 -0
- package/dist/hooks/navigation/useBuildUrlController.js.map +1 -0
- package/dist/hooks/navigation/useNavigationResolution.js +177 -0
- package/dist/hooks/navigation/useNavigationResolution.js.map +1 -0
- package/dist/hooks/navigation/useResolvedCollections.js +56 -0
- package/dist/hooks/navigation/useResolvedCollections.js.map +1 -0
- package/dist/hooks/navigation/useResolvedViews.js +94 -0
- package/dist/hooks/navigation/useResolvedViews.js.map +1 -0
- package/dist/hooks/navigation/useTopLevelNavigation.js +162 -0
- package/dist/hooks/navigation/useTopLevelNavigation.js.map +1 -0
- package/dist/hooks/navigation/utils.js +125 -0
- package/dist/hooks/navigation/utils.js.map +1 -0
- package/dist/hooks/useAdminContext.js +45 -0
- package/dist/hooks/useAdminContext.js.map +1 -0
- package/dist/hooks/useBreadcrumbsController.js +17 -0
- package/dist/hooks/useBreadcrumbsController.js.map +1 -0
- package/dist/hooks/useBuildSideDialogsController.js +96 -0
- package/dist/hooks/useBuildSideDialogsController.js.map +1 -0
- package/dist/hooks/useBuildSidePanel.js +208 -0
- package/dist/hooks/useBuildSidePanel.js.map +1 -0
- package/dist/hooks/useChildViewSource.js +41 -0
- package/dist/hooks/useChildViewSource.js.map +1 -0
- package/dist/hooks/useEntityDisplay.js +136 -0
- package/dist/hooks/useEntityDisplay.js.map +1 -0
- package/dist/hooks/useEntityDisplayTitle.js +34 -0
- package/dist/hooks/useEntityDisplayTitle.js.map +1 -0
- package/dist/hooks/useHistory.js +137 -0
- package/dist/hooks/useHistory.js.map +1 -0
- package/dist/hooks/useRecordActions.d.ts +28 -6
- package/dist/hooks/useRecordActions.js +108 -0
- package/dist/hooks/useRecordActions.js.map +1 -0
- package/dist/hooks/useReferencePaths.d.ts +21 -0
- package/dist/hooks/useReferencePaths.js +32 -0
- package/dist/hooks/useReferencePaths.js.map +1 -0
- package/dist/hooks/useResolvedNavigationFrom.js +83 -0
- package/dist/hooks/useResolvedNavigationFrom.js.map +1 -0
- package/dist/hooks/useResolvedUsers.js +109 -0
- package/dist/hooks/useResolvedUsers.js.map +1 -0
- package/dist/hooks/useSelectionDialog.js +53 -0
- package/dist/hooks/useSelectionDialog.js.map +1 -0
- package/dist/hooks/useSideDialogsController.js +8 -0
- package/dist/hooks/useSideDialogsController.js.map +1 -0
- package/dist/hooks/useSidePanel.js +15 -0
- package/dist/hooks/useSidePanel.js.map +1 -0
- package/dist/hooks/useStorageReferenceResolver.d.ts +25 -0
- package/dist/hooks/useStorageReferenceResolver.js +49 -0
- package/dist/hooks/useStorageReferenceResolver.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +149 -3793
- package/dist/preview/PropertyPreview.js +260 -0
- package/dist/preview/PropertyPreview.js.map +1 -0
- package/dist/preview/compact_text.js +52 -0
- package/dist/preview/compact_text.js.map +1 -0
- package/dist/preview/components/ArrayEnumPreview.js +24 -0
- package/dist/preview/components/ArrayEnumPreview.js.map +1 -0
- package/dist/preview/components/BooleanPreview.js +25 -0
- package/dist/preview/components/BooleanPreview.js.map +1 -0
- package/dist/preview/components/DatePreview.d.ts +3 -2
- package/dist/preview/components/DatePreview.js +87 -0
- package/dist/preview/components/DatePreview.js.map +1 -0
- package/dist/preview/components/EmptyValue.js +13 -0
- package/dist/preview/components/EmptyValue.js.map +1 -0
- package/dist/preview/components/EnumValuesChip.js +26 -0
- package/dist/preview/components/EnumValuesChip.js.map +1 -0
- package/dist/preview/components/ImagePreview.d.ts +7 -1
- package/dist/preview/components/ImagePreview.js +112 -0
- package/dist/preview/components/ImagePreview.js.map +1 -0
- package/dist/preview/components/InlineEntityListPreview.js +31 -0
- package/dist/preview/components/InlineEntityListPreview.js.map +1 -0
- package/dist/preview/components/ReferencePreview.js +162 -0
- package/dist/preview/components/ReferencePreview.js.map +1 -0
- package/dist/preview/components/RelationPreview.js +196 -0
- package/dist/preview/components/RelationPreview.js.map +1 -0
- package/dist/preview/components/StorageMarkdown.d.ts +11 -0
- package/dist/preview/components/StorageMarkdown.js +49 -0
- package/dist/preview/components/StorageMarkdown.js.map +1 -0
- package/dist/preview/components/StorageThumbnail.js +183 -0
- package/dist/preview/components/StorageThumbnail.js.map +1 -0
- package/dist/preview/components/UrlComponentPreview.d.ts +3 -1
- package/dist/preview/components/UrlComponentPreview.js +88 -0
- package/dist/preview/components/UrlComponentPreview.js.map +1 -0
- package/dist/preview/components/UserPreview.js +30 -0
- package/dist/preview/components/UserPreview.js.map +1 -0
- package/dist/preview/components/date_fns_locales.js +124 -0
- package/dist/preview/components/date_fns_locales.js.map +1 -0
- package/dist/preview/components/storageRenditions.d.ts +10 -0
- package/dist/preview/components/storageRenditions.js +93 -0
- package/dist/preview/components/storageRenditions.js.map +1 -0
- package/dist/preview/property_previews/ArrayOfMapsPreview.js +44 -0
- package/dist/preview/property_previews/ArrayOfMapsPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayOfReferencesPreview.js +48 -0
- package/dist/preview/property_previews/ArrayOfReferencesPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayOfRelationsPreview.js +50 -0
- package/dist/preview/property_previews/ArrayOfRelationsPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js +30 -0
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayOfStringsPreview.js +42 -0
- package/dist/preview/property_previews/ArrayOfStringsPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayOneOfPreview.js +47 -0
- package/dist/preview/property_previews/ArrayOneOfPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.js +25 -0
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.js.map +1 -0
- package/dist/preview/property_previews/ArrayPropertyPreview.js +48 -0
- package/dist/preview/property_previews/ArrayPropertyPreview.js.map +1 -0
- package/dist/preview/property_previews/MapPropertyPreview.js +137 -0
- package/dist/preview/property_previews/MapPropertyPreview.js.map +1 -0
- package/dist/preview/property_previews/NumberPropertyPreview.js +34 -0
- package/dist/preview/property_previews/NumberPropertyPreview.js.map +1 -0
- package/dist/preview/property_previews/SkeletonPropertyComponent.js +151 -0
- package/dist/preview/property_previews/SkeletonPropertyComponent.js.map +1 -0
- package/dist/preview/property_previews/StringPropertyPreview.js +49 -0
- package/dist/preview/property_previews/StringPropertyPreview.js.map +1 -0
- package/dist/preview/util.d.ts +8 -3
- package/dist/{util-CC0ozHoD.js → preview/util.js} +13 -6
- package/dist/preview/util.js.map +1 -0
- package/dist/routes/CustomViewRoute.js +26 -0
- package/dist/routes/CustomViewRoute.js.map +1 -0
- package/dist/routes/RebaseRoute.js +311 -0
- package/dist/routes/RebaseRoute.js.map +1 -0
- package/dist/selection/SelectionMenu.js +90 -0
- package/dist/selection/SelectionMenu.js.map +1 -0
- package/dist/selection/resolve_selection.js +79 -0
- package/dist/selection/resolve_selection.js.map +1 -0
- package/dist/util/caller_scopes.d.ts +15 -0
- package/dist/util/caller_scopes.js +25 -0
- package/dist/util/caller_scopes.js.map +1 -0
- package/dist/util/collection_open_mode.d.ts +20 -0
- package/dist/util/collection_open_mode.js +32 -0
- package/dist/util/collection_open_mode.js.map +1 -0
- package/dist/util/dataControllerAdapter.js +65 -0
- package/dist/util/dataControllerAdapter.js.map +1 -0
- package/dist/util/entity_actions.d.ts +42 -1
- package/dist/util/entity_actions.js +77 -0
- package/dist/util/entity_actions.js.map +1 -0
- package/dist/util/entity_pages.d.ts +37 -3
- package/dist/util/entity_pages.js +71 -0
- package/dist/util/entity_pages.js.map +1 -0
- package/dist/util/find_entities_by_ids.d.ts +23 -0
- package/dist/util/find_entities_by_ids.js +55 -0
- package/dist/util/find_entities_by_ids.js.map +1 -0
- package/dist/util/fit_inline_actions.d.ts +20 -0
- package/dist/util/fit_inline_actions.js +40 -0
- package/dist/util/fit_inline_actions.js.map +1 -0
- package/dist/util/format_collection_date.d.ts +29 -0
- package/dist/util/format_collection_date.js +60 -0
- package/dist/util/format_collection_date.js.map +1 -0
- package/dist/util/map_with_concurrency.js +46 -0
- package/dist/util/map_with_concurrency.js.map +1 -0
- package/dist/util/navigation_utils.js +44 -0
- package/dist/util/navigation_utils.js.map +1 -0
- package/dist/util/number_format.js +33 -0
- package/dist/util/number_format.js.map +1 -0
- package/dist/util/previews.js +71 -0
- package/dist/util/previews.js.map +1 -0
- package/dist/util/propertyConfigMapper.js +83 -0
- package/dist/util/propertyConfigMapper.js.map +1 -0
- package/dist/util/property_utils.js +141 -0
- package/dist/util/property_utils.js.map +1 -0
- package/dist/util/resolutions.js +55 -0
- package/dist/util/resolutions.js.map +1 -0
- package/dist/util/view_constants.js +35 -0
- package/dist/util/view_constants.js.map +1 -0
- package/dist/util/view_mode.js +112 -0
- package/dist/util/view_mode.js.map +1 -0
- package/package.json +13 -9
- package/dist/CollectionEditorDialog-DLHCka00.js +0 -3630
- package/dist/CollectionEditorDialog-DLHCka00.js.map +0 -1
- package/dist/JsonPreviewBinding-v0w3H0fp.js.map +0 -1
- package/dist/PropertyEditView-_pu5hzZn.js +0 -3837
- package/dist/PropertyEditView-_pu5hzZn.js.map +0 -1
- package/dist/RouterCollectionsStudioView-ChPNl_uU.js +0 -212
- package/dist/RouterCollectionsStudioView-ChPNl_uU.js.map +0 -1
- package/dist/SchemaChangeDialog-BeP0A4MJ.js.map +0 -1
- package/dist/collection_editor/ui/CollectionViewHeaderAction.d.ts +0 -13
- package/dist/collection_editor/ui/PropertyAddColumnComponent.d.ts +0 -8
- package/dist/collection_editor_ui.js.map +0 -1
- package/dist/editor.js.map +0 -1
- package/dist/export-4bJWdlDK.js +0 -520
- package/dist/export-4bJWdlDK.js.map +0 -1
- package/dist/history-BElrZ5Rw.js +0 -313
- package/dist/history-BElrZ5Rw.js.map +0 -1
- package/dist/import-TCgkTVlS.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/markdown-CCqp8ibf.js.map +0 -1
- package/dist/rolldown-runtime-D7D4PA-g.js +0 -13
- package/dist/util-CC0ozHoD.js.map +0 -1
- package/dist/util-DybQBkug.js +0 -26390
- package/dist/util-DybQBkug.js.map +0 -1
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { getPropertyInPath } from "../../util/property_utils.js";
|
|
2
|
+
import { unflattenObject } from "./transforms.js";
|
|
3
|
+
import { importColumns } from "./import_columns.js";
|
|
4
|
+
import { isPropertyBuilder } from "@rebasepro/common";
|
|
5
|
+
import { EntityReference, GeoPoint, Vector } from "@rebasepro/types";
|
|
6
|
+
import { mergeDeep } from "@rebasepro/utils";
|
|
7
|
+
import { inferTypeFromValue, readNumberExactly } from "@rebasepro/inference";
|
|
8
|
+
//#region src/data_import/utils/data.ts
|
|
9
|
+
/**
|
|
10
|
+
* Convert every row of an imported file, and list each cell that did not
|
|
11
|
+
* convert. The previews call this, so the list is in front of the person
|
|
12
|
+
* importing before the first row is written.
|
|
13
|
+
*/
|
|
14
|
+
function convertImportData(authController, navigation, data, idColumn, headersMapping, properties, path, defaultValues) {
|
|
15
|
+
const problems = [];
|
|
16
|
+
const dateOrders = slashDateOrdersByColumn(data, properties, mappedColumnTarget(headersMapping));
|
|
17
|
+
return {
|
|
18
|
+
entities: data.map((row, index) => convertDataToEntity(authController, navigation, row, idColumn, headersMapping, properties, path, defaultValues, (problem) => problems.push({
|
|
19
|
+
row: index,
|
|
20
|
+
...problem
|
|
21
|
+
}), dateOrders)),
|
|
22
|
+
problems
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function convertDataToEntity(authController, navigation, data, idColumn, headersMapping, properties, path, defaultValues, onProblem, dateOrders) {
|
|
26
|
+
const flatObject = flattenEntry(data, properties, mappedColumnTarget(headersMapping));
|
|
27
|
+
if (idColumn) delete flatObject[idColumn];
|
|
28
|
+
const mappedKeysObject = Object.create(null);
|
|
29
|
+
for (const [key, value] of Object.entries(flatObject)) {
|
|
30
|
+
const mappedKey = Object.prototype.hasOwnProperty.call(headersMapping, key) ? headersMapping[key] : key;
|
|
31
|
+
if (mappedKey === null) continue;
|
|
32
|
+
if (value === "") continue;
|
|
33
|
+
const mappedProperty = getPropertyInPath(properties, mappedKey);
|
|
34
|
+
if (!mappedProperty || typeof mappedProperty !== "object") continue;
|
|
35
|
+
let reason;
|
|
36
|
+
const processedValue = processValueMapping(authController, value, navigation, mappedProperty, (problem) => {
|
|
37
|
+
reason ??= problem.reason;
|
|
38
|
+
}, dateOrders && Object.hasOwn(dateOrders, key) ? dateOrders[key] : void 0);
|
|
39
|
+
if (reason !== void 0) {
|
|
40
|
+
onProblem?.({
|
|
41
|
+
column: key,
|
|
42
|
+
property: mappedKey,
|
|
43
|
+
expected: mappedProperty.type,
|
|
44
|
+
value,
|
|
45
|
+
reason
|
|
46
|
+
});
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
mappedKeysObject[mappedKey] = processedValue;
|
|
50
|
+
}
|
|
51
|
+
const values = mergeDeep(defaultValues ?? {}, unflattenObject(mappedKeysObject));
|
|
52
|
+
let id = idColumn ? data[idColumn] : void 0;
|
|
53
|
+
if (typeof id === "string") id = id.trim();
|
|
54
|
+
else if (typeof id === "number") id = id.toString();
|
|
55
|
+
else if (typeof id === "boolean") id = id.toString();
|
|
56
|
+
else if (id instanceof Date) id = id.toISOString();
|
|
57
|
+
else if (id && "toString" in id) id = id.toString();
|
|
58
|
+
return {
|
|
59
|
+
id,
|
|
60
|
+
values,
|
|
61
|
+
path
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Where a column lands under the import's mapping: the property the mapping
|
|
66
|
+
* names for it, `null` for "Do not import this property", and the property
|
|
67
|
+
* with the column's own name when the mapping does not mention the column.
|
|
68
|
+
*/
|
|
69
|
+
function mappedColumnTarget(headersMapping) {
|
|
70
|
+
return (column) => Object.hasOwn(headersMapping, column) ? headersMapping[column] : column;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The cells of one imported row by column name (`address.street`): each
|
|
74
|
+
* value that is not split into columns of its own (see `importColumns`).
|
|
75
|
+
* Without `properties`, every object is split.
|
|
76
|
+
*/
|
|
77
|
+
function flattenEntry(obj, properties, targetOf = (column) => column) {
|
|
78
|
+
const cells = {};
|
|
79
|
+
for (const { column, value, split } of importColumns(obj, properties, targetOf)) if (!split) cells[column] = value;
|
|
80
|
+
return cells;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Convert one cell to the type of the property it lands in.
|
|
84
|
+
*
|
|
85
|
+
* A cell is converted only when the property's type can hold what it says:
|
|
86
|
+
* text becomes a number when it spells one exactly (`readNumberExactly`, the
|
|
87
|
+
* same answer the inference uses), a boolean when it says yes or no, a date
|
|
88
|
+
* when it names a day. Anything else is reported to `onProblem`, and the
|
|
89
|
+
* result is `null` — the caller leaves such a cell out rather than writing
|
|
90
|
+
* that `null`, a `0` or a `false` in its place.
|
|
91
|
+
*
|
|
92
|
+
* @param dateOrder how the cell's column writes day/month dates, when it
|
|
93
|
+
* writes them with numbers only (see `slashDateOrdersByColumn`).
|
|
94
|
+
*/
|
|
95
|
+
function processValueMapping(authController, value, navigation, property, onProblem, dateOrder) {
|
|
96
|
+
if (value === null) return null;
|
|
97
|
+
if (property === void 0) return value;
|
|
98
|
+
const usedProperty = property;
|
|
99
|
+
if (usedProperty === null) return value;
|
|
100
|
+
const from = inferTypeFromValue(value);
|
|
101
|
+
const to = usedProperty.type;
|
|
102
|
+
const refuse = (reason) => {
|
|
103
|
+
onProblem?.({ reason });
|
|
104
|
+
return null;
|
|
105
|
+
};
|
|
106
|
+
if (to === "vector") {
|
|
107
|
+
let items;
|
|
108
|
+
if (Array.isArray(value)) items = value;
|
|
109
|
+
else if (isObjectValue(value)) {
|
|
110
|
+
if (!Array.isArray(value.value)) return refuse("not_a_vector");
|
|
111
|
+
items = value.value;
|
|
112
|
+
} else if (typeof value === "string") {
|
|
113
|
+
let cleaned = value.trim();
|
|
114
|
+
if (cleaned.startsWith("{")) {
|
|
115
|
+
const object = readJsonObjectCell(cleaned);
|
|
116
|
+
if (!object || !Array.isArray(object.value)) return refuse("not_a_vector");
|
|
117
|
+
items = object.value;
|
|
118
|
+
} else {
|
|
119
|
+
if (cleaned.startsWith("[") && cleaned.endsWith("]")) cleaned = cleaned.slice(1, -1);
|
|
120
|
+
if (cleaned === "") return null;
|
|
121
|
+
items = cleaned.split(",");
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (items === void 0) return value;
|
|
125
|
+
const numbers = items.map((item) => typeof item === "number" ? item : typeof item === "string" ? readNumberExactly(item) : void 0);
|
|
126
|
+
if (numbers.some((item) => item === void 0 || !Number.isFinite(item))) return refuse("not_a_vector");
|
|
127
|
+
return new Vector(numbers);
|
|
128
|
+
}
|
|
129
|
+
if (to === "map" || to === "geopoint") {
|
|
130
|
+
if (typeof value === "string" && value.trim() === "") return null;
|
|
131
|
+
const object = typeof value === "string" ? readJsonObjectCell(value) : isObjectValue(value) ? value : void 0;
|
|
132
|
+
if (usedProperty.type === "geopoint") {
|
|
133
|
+
const { latitude, longitude } = object ?? {};
|
|
134
|
+
return typeof latitude === "number" && typeof longitude === "number" && Math.abs(latitude) <= 90 && Math.abs(longitude) <= 180 ? new GeoPoint(latitude, longitude) : refuse("not_a_geopoint");
|
|
135
|
+
}
|
|
136
|
+
if (!object) return refuse("not_a_map");
|
|
137
|
+
if (usedProperty.type !== "map" || !usedProperty.properties) return object;
|
|
138
|
+
const fields = { ...object };
|
|
139
|
+
for (const [key, fieldProperty] of Object.entries(usedProperty.properties)) {
|
|
140
|
+
if (!Object.hasOwn(object, key) || isPropertyBuilder(fieldProperty)) continue;
|
|
141
|
+
fields[key] = processValueMapping(authController, object[key], navigation, fieldProperty, onProblem, dateOrder);
|
|
142
|
+
}
|
|
143
|
+
return fields;
|
|
144
|
+
}
|
|
145
|
+
if (from === "string" && to === "array" && typeof value === "string") return processValueMapping(authController, splitListCell(value), navigation, usedProperty, onProblem, dateOrder);
|
|
146
|
+
else if (from === "string" && to === "boolean" && typeof value === "string") {
|
|
147
|
+
if (value.trim() === "") return null;
|
|
148
|
+
const read = readBooleanCell(value);
|
|
149
|
+
return read === void 0 ? refuse("not_a_boolean") : read;
|
|
150
|
+
} else if (from === "array" && to === "string") return JSON.stringify(value);
|
|
151
|
+
if (from === "array" && Array.isArray(value) && usedProperty.type === "array") {
|
|
152
|
+
const of = usedProperty.of;
|
|
153
|
+
if (usedProperty.oneOf) {
|
|
154
|
+
const oneOf = usedProperty.oneOf;
|
|
155
|
+
return value.map((item) => convertBlock(item, oneOf, (blockValue, blockProperty) => processValueMapping(authController, blockValue, navigation, blockProperty, onProblem, dateOrder)));
|
|
156
|
+
}
|
|
157
|
+
if (Array.isArray(of)) return value.map((item, index) => index < of.length && !isPropertyBuilder(of[index]) ? processValueMapping(authController, item, navigation, of[index], onProblem, dateOrder) : item);
|
|
158
|
+
if (of && !isPropertyBuilder(of)) return value.map((item) => processValueMapping(authController, item, navigation, of, onProblem, dateOrder));
|
|
159
|
+
}
|
|
160
|
+
if (from === "string" && to === "number" && typeof value === "string") {
|
|
161
|
+
const trimmed = value.trim();
|
|
162
|
+
if (trimmed === "") return null;
|
|
163
|
+
const read = readNumberExactly(trimmed);
|
|
164
|
+
if (read !== void 0) return read;
|
|
165
|
+
return refuse(whyNotANumber(trimmed));
|
|
166
|
+
} else if (from === "number" && to === "boolean") {
|
|
167
|
+
if (value === 1) return true;
|
|
168
|
+
if (value === 0) return false;
|
|
169
|
+
return refuse("not_a_boolean");
|
|
170
|
+
} else if (from === "boolean" && to === "number") return value ? 1 : 0;
|
|
171
|
+
else if (from === "boolean" && to === "string") return value ? "true" : "false";
|
|
172
|
+
else if (from === "number" && to === "string" && typeof value === "number") return value.toString();
|
|
173
|
+
else if (from === "string" && to === "date" && typeof value === "string") {
|
|
174
|
+
const read = readDateCell(value, dateOrder, isTimeOfDay(usedProperty));
|
|
175
|
+
return read instanceof Date ? read : refuse(read);
|
|
176
|
+
} else if (value instanceof Date && to === "string") return value.toISOString();
|
|
177
|
+
else if (from === "number" && to === "date" && typeof value === "number") return dateFromEpoch(value, isTimeOfDay(usedProperty)) ?? refuse("not_a_date");
|
|
178
|
+
else if (from === "string" && to === "reference" && typeof value === "string") {
|
|
179
|
+
let databaseId = void 0;
|
|
180
|
+
let referencePath = value;
|
|
181
|
+
if (value.includes(":::")) {
|
|
182
|
+
const [dbName, pathPart] = value.split(":::");
|
|
183
|
+
if (dbName && dbName !== "(default)") databaseId = dbName;
|
|
184
|
+
referencePath = pathPart;
|
|
185
|
+
}
|
|
186
|
+
const path = referencePath.split("/").slice(0, -1).join("/");
|
|
187
|
+
const entityId = referencePath.split("/").slice(-1)[0];
|
|
188
|
+
if (databaseId === void 0) databaseId = navigation.getCollection(path)?.databaseId;
|
|
189
|
+
return new EntityReference({
|
|
190
|
+
id: entityId,
|
|
191
|
+
path,
|
|
192
|
+
databaseId
|
|
193
|
+
});
|
|
194
|
+
} else if (from === to) return value;
|
|
195
|
+
return value;
|
|
196
|
+
}
|
|
197
|
+
/** An object read from a file, as opposed to a list, a date or a primitive. */
|
|
198
|
+
function isObjectValue(value) {
|
|
199
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* One item of a block list (`oneOf`): the object the export wrote — or, in a
|
|
203
|
+
* CSV whose lists were written one cell per item, that object's JSON — with
|
|
204
|
+
* its value converted to the property its type names.
|
|
205
|
+
*/
|
|
206
|
+
function convertBlock(item, oneOf, convert) {
|
|
207
|
+
const block = typeof item === "string" ? readJsonObjectCell(item) : isObjectValue(item) ? item : void 0;
|
|
208
|
+
if (!block) return item;
|
|
209
|
+
const typeField = oneOf.typeField ?? "type";
|
|
210
|
+
const valueField = oneOf.valueField ?? "value";
|
|
211
|
+
const type = block[typeField];
|
|
212
|
+
const blockProperty = typeof type === "string" && Object.hasOwn(oneOf.properties, type) ? oneOf.properties[type] : void 0;
|
|
213
|
+
if (!blockProperty || isPropertyBuilder(blockProperty) || !Object.hasOwn(block, valueField)) return block;
|
|
214
|
+
return {
|
|
215
|
+
...block,
|
|
216
|
+
[valueField]: convert(block[valueField], blockProperty)
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/** A cell holding the JSON of an object, read; `undefined` for anything else. */
|
|
220
|
+
function readJsonObjectCell(cell) {
|
|
221
|
+
const trimmed = cell.trim();
|
|
222
|
+
if (!trimmed.startsWith("{")) return void 0;
|
|
223
|
+
try {
|
|
224
|
+
const parsed = JSON.parse(trimmed);
|
|
225
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : void 0;
|
|
226
|
+
} catch {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* The items of a list cell: a JSON array as written (the export writes lists
|
|
232
|
+
* that way), otherwise the text split on commas. Each item is trimmed and an
|
|
233
|
+
* empty one dropped, so `news, sports` is two tags rather than one with a
|
|
234
|
+
* leading space, and a blank cell is no tags rather than one empty tag.
|
|
235
|
+
*/
|
|
236
|
+
function splitListCell(cell) {
|
|
237
|
+
const trimmed = cell.trim();
|
|
238
|
+
if (trimmed.startsWith("[")) try {
|
|
239
|
+
const parsed = JSON.parse(trimmed);
|
|
240
|
+
if (Array.isArray(parsed)) return parsed;
|
|
241
|
+
} catch (e) {}
|
|
242
|
+
return trimmed.split(",").map((item) => item.trim()).filter((item) => item !== "");
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* A boolean cell as spreadsheets and people write it: Excel and Sheets export
|
|
246
|
+
* `TRUE`/`FALSE`, and `yes`/`no` and `1`/`0` are common by hand. Anything
|
|
247
|
+
* unreadable is absent — `null`, as a number cell is — rather than a confident
|
|
248
|
+
* `false`.
|
|
249
|
+
*/
|
|
250
|
+
function readBooleanCell(cell) {
|
|
251
|
+
const normalised = cell.trim().toLowerCase();
|
|
252
|
+
if ([
|
|
253
|
+
"true",
|
|
254
|
+
"1",
|
|
255
|
+
"yes",
|
|
256
|
+
"y"
|
|
257
|
+
].includes(normalised)) return true;
|
|
258
|
+
if ([
|
|
259
|
+
"false",
|
|
260
|
+
"0",
|
|
261
|
+
"no",
|
|
262
|
+
"n"
|
|
263
|
+
].includes(normalised)) return false;
|
|
264
|
+
}
|
|
265
|
+
/** Why a text is not a number `readNumberExactly` accepts. */
|
|
266
|
+
function whyNotANumber(text) {
|
|
267
|
+
if (/^-?0\d/.test(text) && Number.isFinite(Number(text))) return "number_leading_zero";
|
|
268
|
+
if (/^-?\d+(\.\d+)?$/.test(text)) return "number_too_precise";
|
|
269
|
+
return "not_a_number";
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Below this, an epoch number is in seconds: 1e11 seconds is the year 5138,
|
|
273
|
+
* and 1e11 milliseconds is March 1973.
|
|
274
|
+
*/
|
|
275
|
+
var EPOCH_SECONDS_BELOW = 1e11;
|
|
276
|
+
/** One day, in milliseconds. */
|
|
277
|
+
var DAY_MS = 864e5;
|
|
278
|
+
/** Whether a property holds a time of day — a time on 1970-01-01, in UTC. */
|
|
279
|
+
function isTimeOfDay(property) {
|
|
280
|
+
return property.type === "date" && property.columnType === "time";
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* @param timeOfDay the number lands in a time-of-day property. The export
|
|
284
|
+
* writes such a time as the milliseconds since that midnight, a number below
|
|
285
|
+
* one day; read as epoch seconds, 12:30 was a day in 1971 at 20:00.
|
|
286
|
+
*/
|
|
287
|
+
function dateFromEpoch(epoch, timeOfDay = false) {
|
|
288
|
+
if (!Number.isFinite(epoch)) return void 0;
|
|
289
|
+
const date = new Date(timeOfDay && epoch >= 0 && epoch < DAY_MS || Math.abs(epoch) >= EPOCH_SECONDS_BELOW ? epoch : epoch * 1e3);
|
|
290
|
+
return isNaN(date.getTime()) ? void 0 : date;
|
|
291
|
+
}
|
|
292
|
+
/** `05/01/2024`, `5.1.2024`, `05-01-2024`: day and month as numbers, year last. */
|
|
293
|
+
var SLASH_DATE = /^(\d{1,2})([/.-])(\d{1,2})\2(\d{4})$/;
|
|
294
|
+
/**
|
|
295
|
+
* Whether a date that names no time is the day it names in UTC — as an ISO
|
|
296
|
+
* `2024-01-05` already is — rather than local midnight, which `new Date()`
|
|
297
|
+
* makes of `5 Jan 2024`.
|
|
298
|
+
*/
|
|
299
|
+
function utcDay(date) {
|
|
300
|
+
return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
301
|
+
}
|
|
302
|
+
function validUtcDate(year, month, day) {
|
|
303
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
304
|
+
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day ? date : void 0;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Read a date cell. `new Date()` never throws, so its failures used to import
|
|
308
|
+
* as an Invalid Date (sent as `null`); it reads `05/01/2024` month first
|
|
309
|
+
* wherever the file came from, an epoch in seconds as milliseconds (1970), and
|
|
310
|
+
* `5 Jan 2024` at local midnight where `2024-01-05` is UTC midnight.
|
|
311
|
+
*/
|
|
312
|
+
function readDateCell(cell, order, timeOfDay = false) {
|
|
313
|
+
const text = cell.trim();
|
|
314
|
+
if (/^-?\d+$/.test(text)) return dateFromEpoch(Number(text), timeOfDay) ?? "not_a_date";
|
|
315
|
+
const slash = SLASH_DATE.exec(text);
|
|
316
|
+
if (slash) {
|
|
317
|
+
const first = Number(slash[1]);
|
|
318
|
+
const second = Number(slash[3]);
|
|
319
|
+
const year = Number(slash[4]);
|
|
320
|
+
let dayFirst;
|
|
321
|
+
if (order === "dmy" || order === "mdy") dayFirst = order === "dmy";
|
|
322
|
+
else if (order === "each") {
|
|
323
|
+
if (first > 12 === second > 12) return "ambiguous_date";
|
|
324
|
+
dayFirst = first > 12;
|
|
325
|
+
} else dayFirst = first > 12 || second <= 12 && localeWritesDayFirst();
|
|
326
|
+
return (dayFirst ? validUtcDate(year, second, first) : validUtcDate(year, first, second)) ?? "not_a_date";
|
|
327
|
+
}
|
|
328
|
+
const date = new Date(text);
|
|
329
|
+
if (isNaN(date.getTime())) return "not_a_date";
|
|
330
|
+
return /\d:\d/.test(text) || /^\d{4}-\d{2}-\d{2}$/.test(text) ? date : utcDay(date);
|
|
331
|
+
}
|
|
332
|
+
/** Whether this browser's locale writes the day before the month. */
|
|
333
|
+
function localeWritesDayFirst() {
|
|
334
|
+
const parts = new Intl.DateTimeFormat().formatToParts(new Date(2e3, 10, 22));
|
|
335
|
+
const day = parts.findIndex((part) => part.type === "day");
|
|
336
|
+
const month = parts.findIndex((part) => part.type === "month");
|
|
337
|
+
return day >= 0 && month >= 0 && day < month;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* For each column of the file, how it writes day/month dates with numbers
|
|
341
|
+
* only, when its values say: a first number past 12 is a day, so the column
|
|
342
|
+
* is day first; a second number past 12, month first; both, and each date
|
|
343
|
+
* is read by the only order that fits it. A column that never says is read
|
|
344
|
+
* in the order of the browser's locale.
|
|
345
|
+
*/
|
|
346
|
+
function slashDateOrdersByColumn(data, properties, targetOf) {
|
|
347
|
+
const seen = {};
|
|
348
|
+
for (const row of data) for (const [column, value] of Object.entries(flattenEntry(row, properties, targetOf))) {
|
|
349
|
+
if (typeof value !== "string") continue;
|
|
350
|
+
const slash = SLASH_DATE.exec(value.trim());
|
|
351
|
+
if (!slash) continue;
|
|
352
|
+
const entry = Object.hasOwn(seen, column) ? seen[column] : seen[column] = {
|
|
353
|
+
dayFirst: false,
|
|
354
|
+
monthFirst: false
|
|
355
|
+
};
|
|
356
|
+
if (Number(slash[1]) > 12) entry.dayFirst = true;
|
|
357
|
+
if (Number(slash[3]) > 12) entry.monthFirst = true;
|
|
358
|
+
}
|
|
359
|
+
const orders = {};
|
|
360
|
+
for (const [column, { dayFirst, monthFirst }] of Object.entries(seen)) orders[column] = dayFirst && monthFirst ? "each" : dayFirst ? "dmy" : monthFirst ? "mdy" : void 0;
|
|
361
|
+
return orders;
|
|
362
|
+
}
|
|
363
|
+
//#endregion
|
|
364
|
+
export { convertDataToEntity, convertImportData, flattenEntry, mappedColumnTarget, processValueMapping, slashDateOrdersByColumn };
|
|
365
|
+
|
|
366
|
+
//# sourceMappingURL=data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.js","names":[],"sources":["../../../src/data_import/utils/data.ts"],"sourcesContent":["import { getPropertyInPath } from \"../../util\";\nimport { ArrayProperty, DataType, Entity, EntityReference, CollectionRegistryController, GeoPoint, Properties, Property, Vector } from \"@rebasepro/types\";\nimport { AuthController, AdminCollection } from \"@rebasepro/cms-types\";\nimport { isPropertyBuilder } from \"@rebasepro/common\";\nimport { unflattenObject } from \"./transforms\";\nimport { ColumnTarget, importColumns } from \"./import_columns\";\nimport { inferTypeFromValue, readNumberExactly } from \"@rebasepro/inference\";\nimport { mergeDeep } from \"@rebasepro/utils\";\n\n/** What the conversion asks of the collection registry: the collection a reference points into. */\nexport type ImportCollectionLookup = Pick<CollectionRegistryController, \"getCollection\">;\n\n/**\n * Why a cell could not be converted to its property's type. Each one is a\n * translation key under `import_problem_`.\n */\nexport type ImportProblemReason =\n | \"not_a_number\"\n | \"number_leading_zero\"\n | \"number_too_precise\"\n | \"not_a_boolean\"\n | \"not_a_date\"\n | \"ambiguous_date\"\n | \"not_a_vector\"\n | \"not_a_map\"\n | \"not_a_geopoint\";\n\n/**\n * A cell the import could not convert to the type of the property it maps\n * to. It is left out of the row — the property's default applies — and shown\n * to the person importing before anything is written.\n */\nexport type ImportConversionProblem = {\n /** The row's index among the file's data rows, from 0. */\n row: number;\n /** The column, as the file names it. */\n column: string;\n /** The property the column maps to. */\n property: string;\n /** The type that property holds. */\n expected: DataType;\n /** The cell, as it was read from the file. */\n value: unknown;\n reason: ImportProblemReason;\n};\n\n/** Reports one cell that did not convert; the cell is then left out. */\nexport type ImportProblemListener = (problem: { reason: ImportProblemReason }) => void;\n\n/**\n * How a column writes the dates whose day and month are both numbers\n * (`05/01/2024`): day first, month first, or — when the column holds both —\n * each date by the only order that can read it.\n */\nexport type SlashDateOrder = \"dmy\" | \"mdy\" | \"each\";\n\n/**\n * Convert every row of an imported file, and list each cell that did not\n * convert. The previews call this, so the list is in front of the person\n * importing before the first row is written.\n */\nexport function convertImportData(authController: AuthController,\n navigation: ImportCollectionLookup,\n data: object[],\n idColumn: string | undefined,\n headersMapping: Record<string, string | null>,\n properties: Properties,\n path: string,\n defaultValues: Record<string, any>): { entities: Entity<any>[], problems: ImportConversionProblem[] } {\n const problems: ImportConversionProblem[] = [];\n const dateOrders = slashDateOrdersByColumn(data, properties, mappedColumnTarget(headersMapping));\n const entities = data.map((row, index) => convertDataToEntity(authController, navigation,\n row as Record<string, unknown>, idColumn, headersMapping, properties, path, defaultValues,\n (problem) => problems.push({ row: index, ...problem }),\n dateOrders));\n return { entities, problems };\n}\n\nexport function convertDataToEntity(authController: AuthController,\n navigation: ImportCollectionLookup,\n data: Record<any, any>,\n idColumn: string | undefined,\n headersMapping: Record<string, string | null>,\n properties: Properties,\n path: string,\n defaultValues: Record<string, any>,\n onProblem?: (problem: Omit<ImportConversionProblem, \"row\">) => void,\n dateOrders?: Record<string, SlashDateOrder | undefined>): Entity<any> {\n const flatObject = flattenEntry(data, properties, mappedColumnTarget(headersMapping));\n if (idColumn)\n delete flatObject[idColumn];\n // One accumulator, written in place: spreading it once per column made\n // converting a row quadratic in its column count. No prototype, so a\n // `__proto__` key is a key here; `unflattenObject` refuses it below.\n const mappedKeysObject: Record<string, unknown> = Object.create(null);\n for (const [key, value] of Object.entries(flatObject)) {\n // The mapping is keyed by the column's flat name — `address.street`\n // is one key, not a path — and `null` is \"Do not import this\n // property\". A column the mapping does not mention keeps its name.\n const mappedKey = Object.prototype.hasOwnProperty.call(headersMapping, key)\n ? headersMapping[key]\n : key;\n if (mappedKey === null) {\n continue;\n }\n // A blank cell is a value nobody filled in, not an empty one: it\n // sets nothing, so the default chosen for the property applies. An\n // empty spreadsheet cell already arrives without a key.\n if (value === \"\") {\n continue;\n }\n\n const mappedProperty = getPropertyInPath(properties, mappedKey);\n // `getPropertyInPath` answers `in`, so a `toString` column finds\n // `Object.prototype.toString`: a declared property is an object.\n if (!mappedProperty || typeof mappedProperty !== \"object\") {\n continue;\n }\n let reason: ImportProblemReason | undefined;\n const processedValue = processValueMapping(authController, value, navigation, mappedProperty,\n (problem) => { reason ??= problem.reason; },\n dateOrders && Object.hasOwn(dateOrders, key) ? dateOrders[key] : undefined);\n // A cell that did not convert is not imported as `null`, `0` or\n // `false` in its place: it is left out, and reported.\n if (reason !== undefined) {\n onProblem?.({ column: key, property: mappedKey, expected: mappedProperty.type, value, reason });\n continue;\n }\n mappedKeysObject[mappedKey] = processedValue;\n }\n\n const values = mergeDeep(defaultValues ?? {}, unflattenObject(mappedKeysObject));\n let id = idColumn ? data[idColumn] : undefined;\n if (typeof id === \"string\") {\n id = id.trim();\n } else if (typeof id === \"number\") {\n id = id.toString();\n } else if (typeof id === \"boolean\") {\n id = id.toString();\n } else if (id instanceof Date) {\n id = id.toISOString();\n } else if (id && \"toString\" in id) {\n id = id.toString();\n }\n\n return {\n id,\n values,\n path: path\n };\n}\n\n/**\n * Where a column lands under the import's mapping: the property the mapping\n * names for it, `null` for \"Do not import this property\", and the property\n * with the column's own name when the mapping does not mention the column.\n */\nexport function mappedColumnTarget(headersMapping: Record<string, string | null>): ColumnTarget {\n return (column) => Object.hasOwn(headersMapping, column) ? headersMapping[column] : column;\n}\n\n/**\n * The cells of one imported row by column name (`address.street`): each\n * value that is not split into columns of its own (see `importColumns`).\n * Without `properties`, every object is split.\n */\nexport function flattenEntry(obj: Record<string, unknown>,\n properties?: Properties,\n targetOf: ColumnTarget = (column) => column): Record<string, unknown> {\n const cells: Record<string, unknown> = {};\n for (const { column, value, split } of importColumns(obj, properties, targetOf)) {\n if (!split) cells[column] = value;\n }\n return cells;\n}\n\n/**\n * Convert one cell to the type of the property it lands in.\n *\n * A cell is converted only when the property's type can hold what it says:\n * text becomes a number when it spells one exactly (`readNumberExactly`, the\n * same answer the inference uses), a boolean when it says yes or no, a date\n * when it names a day. Anything else is reported to `onProblem`, and the\n * result is `null` — the caller leaves such a cell out rather than writing\n * that `null`, a `0` or a `false` in its place.\n *\n * @param dateOrder how the cell's column writes day/month dates, when it\n * writes them with numbers only (see `slashDateOrdersByColumn`).\n */\nexport function processValueMapping(authController: AuthController,\n value: any,\n navigation: ImportCollectionLookup,\n property?: Property,\n onProblem?: ImportProblemListener,\n dateOrder?: SlashDateOrder): any {\n if (value === null) return null;\n\n if (property === undefined) return value;\n const usedProperty: Property | null = property;\n if (usedProperty === null) return value;\n const from = inferTypeFromValue(value);\n const to = usedProperty.type;\n const refuse = (reason: ImportProblemReason) => {\n onProblem?.({ reason });\n return null;\n };\n\n if (to === \"vector\") {\n let items: unknown[] | undefined;\n if (Array.isArray(value)) {\n items = value;\n } else if (isObjectValue(value)) {\n // A JSON file holds the vector as the object the export wrote.\n if (!Array.isArray(value.value)) return refuse(\"not_a_vector\");\n items = value.value;\n } else if (typeof value === \"string\") {\n let cleaned = value.trim();\n if (cleaned.startsWith(\"{\")) {\n // A CSV cell holds it as that object's JSON, `{\"value\":[…]}`.\n const object = readJsonObjectCell(cleaned);\n if (!object || !Array.isArray(object.value)) return refuse(\"not_a_vector\");\n items = object.value;\n } else {\n if (cleaned.startsWith(\"[\") && cleaned.endsWith(\"]\")) {\n cleaned = cleaned.slice(1, -1);\n }\n if (cleaned === \"\") return null;\n items = cleaned.split(\",\");\n }\n }\n if (items === undefined) return value;\n const numbers = items.map(item => typeof item === \"number\"\n ? item\n : typeof item === \"string\" ? readNumberExactly(item) : undefined);\n // An item that is not a number used to become 0 (or NaN): a vector\n // with a made-up coordinate.\n if (numbers.some(item => item === undefined || !Number.isFinite(item))) return refuse(\"not_a_vector\");\n return new Vector(numbers as number[]);\n }\n\n if (to === \"map\" || to === \"geopoint\") {\n // The export writes a map and a geopoint as the JSON of the object in\n // a CSV cell — and each item of an array of maps the same way — and\n // as the object itself in a JSON file; that is what either reads as.\n // Kept as text, a map was stored as a JSON string and a geopoint\n // refused the whole batch at the server.\n if (typeof value === \"string\" && value.trim() === \"\") return null;\n const object = typeof value === \"string\" ? readJsonObjectCell(value) : isObjectValue(value) ? value : undefined;\n if (usedProperty.type === \"geopoint\") {\n const { latitude, longitude } = object ?? {};\n return typeof latitude === \"number\" && typeof longitude === \"number\"\n && Math.abs(latitude) <= 90 && Math.abs(longitude) <= 180\n ? new GeoPoint(latitude, longitude)\n : refuse(\"not_a_geopoint\");\n }\n if (!object) return refuse(\"not_a_map\");\n if (usedProperty.type !== \"map\" || !usedProperty.properties) return object;\n // A map that arrives whole — an item of an array of maps — has its\n // declared fields converted like the columns of a row: its dates\n // were left as the text or epoch number the export wrote.\n const fields: Record<string, unknown> = { ...object };\n for (const [key, fieldProperty] of Object.entries(usedProperty.properties)) {\n if (!Object.hasOwn(object, key) || isPropertyBuilder(fieldProperty)) continue;\n fields[key] = processValueMapping(authController, object[key], navigation, fieldProperty, onProblem, dateOrder);\n }\n return fields;\n }\n\n if (from === \"string\" && to === \"array\" && typeof value === \"string\") {\n return processValueMapping(authController, splitListCell(value), navigation, usedProperty, onProblem, dateOrder);\n } else if (from === \"string\" && to === \"boolean\" && typeof value === \"string\") {\n // A blank cell is no value; anything else unreadable is reported.\n if (value.trim() === \"\") return null;\n const read = readBooleanCell(value);\n return read === undefined ? refuse(\"not_a_boolean\") : read;\n } else if (from === \"array\" && to === \"string\") {\n // A CSV cell only arrives as an array when its text was the canonical\n // JSON of one (`mapJsonParse`), so this is that text again.\n return JSON.stringify(value);\n }\n\n if (from === \"array\" && Array.isArray(value) && usedProperty.type === \"array\") {\n const of = usedProperty.of;\n if (usedProperty.oneOf) {\n const oneOf = usedProperty.oneOf;\n return value.map(item => convertBlock(item, oneOf,\n (blockValue, blockProperty) => processValueMapping(authController, blockValue, navigation, blockProperty, onProblem, dateOrder)));\n }\n if (Array.isArray(of)) {\n // A fixed list: each position has a property of its own.\n return value.map((item, index) => index < of.length && !isPropertyBuilder(of[index])\n ? processValueMapping(authController, item, navigation, of[index], onProblem, dateOrder)\n : item);\n }\n if (of && !isPropertyBuilder(of)) {\n return value.map(item => processValueMapping(authController, item, navigation, of, onProblem, dateOrder));\n }\n }\n\n if (from === \"string\" && to === \"number\" && typeof value === \"string\") {\n // A blank cell is no value — not a real zero, which `Number(\"\")` is.\n const trimmed = value.trim();\n if (trimmed === \"\") return null;\n const read = readNumberExactly(trimmed);\n if (read !== undefined) return read;\n return refuse(whyNotANumber(trimmed));\n } else if (from === \"number\" && to === \"boolean\") {\n if (value === 1) return true;\n if (value === 0) return false;\n return refuse(\"not_a_boolean\");\n } else if (from === \"boolean\" && to === \"number\") {\n return value ? 1 : 0;\n } else if (from === \"boolean\" && to === \"string\") {\n return value ? \"true\" : \"false\";\n } else if (from === \"number\" && to === \"string\" && typeof value === \"number\") {\n return value.toString();\n } else if (from === \"string\" && to === \"date\" && typeof value === \"string\") {\n const read = readDateCell(value, dateOrder, isTimeOfDay(usedProperty));\n return read instanceof Date ? read : refuse(read);\n } else if (value instanceof Date && to === \"string\") {\n return value.toISOString();\n } else if (from === \"number\" && to === \"date\" && typeof value === \"number\") {\n const read = dateFromEpoch(value, isTimeOfDay(usedProperty));\n return read ?? refuse(\"not_a_date\");\n } else if (from === \"string\" && to === \"reference\" && typeof value === \"string\") {\n // Parse optional database name in format: database_name:::path/to/entity\n // or simple format: path/to/entity\n let databaseId: string | undefined = undefined;\n let referencePath = value;\n\n if (value.includes(\":::\")) {\n const [dbName, pathPart] = value.split(\":::\");\n if (dbName && dbName !== \"(default)\") {\n databaseId = dbName;\n }\n referencePath = pathPart;\n }\n\n // split value into path and entityId (entityId is the last part of the path, after the last /)\n const path = referencePath.split(\"/\").slice(0, -1).join(\"/\");\n const entityId = referencePath.split(\"/\").slice(-1)[0];\n\n // If no explicit database was provided in the string, try to get it from the collection\n if (databaseId === undefined) {\n const targetCollection: AdminCollection<any> | undefined = navigation.getCollection(path);\n databaseId = targetCollection?.databaseId;\n }\n\n return new EntityReference({ id: entityId,\npath,\ndatabaseId });\n\n } else if (from === to) {\n return value;\n }\n\n return value;\n}\n\n/** An object read from a file, as opposed to a list, a date or a primitive. */\nfunction isObjectValue(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value) && !(value instanceof Date);\n}\n\n/**\n * One item of a block list (`oneOf`): the object the export wrote — or, in a\n * CSV whose lists were written one cell per item, that object's JSON — with\n * its value converted to the property its type names.\n */\nfunction convertBlock(item: unknown,\n oneOf: NonNullable<ArrayProperty[\"oneOf\"]>,\n convert: (value: unknown, property: Property) => unknown): unknown {\n const block = typeof item === \"string\" ? readJsonObjectCell(item) : isObjectValue(item) ? item : undefined;\n if (!block) return item;\n const typeField = oneOf.typeField ?? \"type\";\n const valueField = oneOf.valueField ?? \"value\";\n const type = block[typeField];\n const blockProperty = typeof type === \"string\" && Object.hasOwn(oneOf.properties, type) ? oneOf.properties[type] : undefined;\n if (!blockProperty || isPropertyBuilder(blockProperty) || !Object.hasOwn(block, valueField)) return block;\n return { ...block, [valueField]: convert(block[valueField], blockProperty) };\n}\n\n/** A cell holding the JSON of an object, read; `undefined` for anything else. */\nfunction readJsonObjectCell(cell: string): Record<string, unknown> | undefined {\n const trimmed = cell.trim();\n if (!trimmed.startsWith(\"{\")) return undefined;\n try {\n const parsed: unknown = JSON.parse(trimmed);\n return parsed && typeof parsed === \"object\" && !Array.isArray(parsed)\n ? parsed as Record<string, unknown>\n : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The items of a list cell: a JSON array as written (the export writes lists\n * that way), otherwise the text split on commas. Each item is trimmed and an\n * empty one dropped, so `news, sports` is two tags rather than one with a\n * leading space, and a blank cell is no tags rather than one empty tag.\n */\nfunction splitListCell(cell: string): unknown[] {\n const trimmed = cell.trim();\n if (trimmed.startsWith(\"[\")) {\n try {\n const parsed: unknown = JSON.parse(trimmed);\n if (Array.isArray(parsed)) return parsed;\n } catch (e) {\n // Not JSON after all: a list that happens to start with a bracket.\n }\n }\n return trimmed.split(\",\")\n .map(item => item.trim())\n .filter(item => item !== \"\");\n}\n\n/**\n * A boolean cell as spreadsheets and people write it: Excel and Sheets export\n * `TRUE`/`FALSE`, and `yes`/`no` and `1`/`0` are common by hand. Anything\n * unreadable is absent — `null`, as a number cell is — rather than a confident\n * `false`.\n */\nfunction readBooleanCell(cell: string): boolean | undefined {\n const normalised = cell.trim().toLowerCase();\n if ([\"true\", \"1\", \"yes\", \"y\"].includes(normalised)) return true;\n if ([\"false\", \"0\", \"no\", \"n\"].includes(normalised)) return false;\n return undefined;\n}\n\n/** Why a text is not a number `readNumberExactly` accepts. */\nfunction whyNotANumber(text: string): ImportProblemReason {\n // A leading zero is an identifier — a zip code, a product code — and\n // more than 15 significant digits is more than a double holds: `Number()`\n // would read both, and change them.\n if (/^-?0\\d/.test(text) && Number.isFinite(Number(text))) return \"number_leading_zero\";\n if (/^-?\\d+(\\.\\d+)?$/.test(text)) return \"number_too_precise\";\n return \"not_a_number\";\n}\n\n/**\n * Below this, an epoch number is in seconds: 1e11 seconds is the year 5138,\n * and 1e11 milliseconds is March 1973.\n */\nconst EPOCH_SECONDS_BELOW = 1e11;\n\n/** One day, in milliseconds. */\nconst DAY_MS = 86_400_000;\n\n/** Whether a property holds a time of day — a time on 1970-01-01, in UTC. */\nfunction isTimeOfDay(property: Property): boolean {\n return property.type === \"date\" && property.columnType === \"time\";\n}\n\n/**\n * @param timeOfDay the number lands in a time-of-day property. The export\n * writes such a time as the milliseconds since that midnight, a number below\n * one day; read as epoch seconds, 12:30 was a day in 1971 at 20:00.\n */\nfunction dateFromEpoch(epoch: number, timeOfDay = false): Date | undefined {\n if (!Number.isFinite(epoch)) return undefined;\n const inMilliseconds = (timeOfDay && epoch >= 0 && epoch < DAY_MS) || Math.abs(epoch) >= EPOCH_SECONDS_BELOW;\n const date = new Date(inMilliseconds ? epoch : epoch * 1000);\n return isNaN(date.getTime()) ? undefined : date;\n}\n\n/** `05/01/2024`, `5.1.2024`, `05-01-2024`: day and month as numbers, year last. */\nconst SLASH_DATE = /^(\\d{1,2})([/.-])(\\d{1,2})\\2(\\d{4})$/;\n\n/**\n * Whether a date that names no time is the day it names in UTC — as an ISO\n * `2024-01-05` already is — rather than local midnight, which `new Date()`\n * makes of `5 Jan 2024`.\n */\nfunction utcDay(date: Date): Date {\n return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));\n}\n\nfunction validUtcDate(year: number, month: number, day: number): Date | undefined {\n const date = new Date(Date.UTC(year, month - 1, day));\n return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day\n ? date\n : undefined;\n}\n\n/**\n * Read a date cell. `new Date()` never throws, so its failures used to import\n * as an Invalid Date (sent as `null`); it reads `05/01/2024` month first\n * wherever the file came from, an epoch in seconds as milliseconds (1970), and\n * `5 Jan 2024` at local midnight where `2024-01-05` is UTC midnight.\n */\nfunction readDateCell(cell: string, order: SlashDateOrder | undefined, timeOfDay = false): Date | ImportProblemReason {\n const text = cell.trim();\n if (/^-?\\d+$/.test(text)) {\n return dateFromEpoch(Number(text), timeOfDay) ?? \"not_a_date\";\n }\n const slash = SLASH_DATE.exec(text);\n if (slash) {\n const first = Number(slash[1]);\n const second = Number(slash[3]);\n const year = Number(slash[4]);\n let dayFirst: boolean;\n if (order === \"dmy\" || order === \"mdy\") {\n dayFirst = order === \"dmy\";\n } else if (order === \"each\") {\n // The column writes both orders; only a date that just one order\n // can read is placed.\n if (first > 12 === second > 12) return \"ambiguous_date\";\n dayFirst = first > 12;\n } else {\n dayFirst = first > 12 || (second <= 12 && localeWritesDayFirst());\n }\n const date = dayFirst ? validUtcDate(year, second, first) : validUtcDate(year, first, second);\n return date ?? \"not_a_date\";\n }\n const date = new Date(text);\n if (isNaN(date.getTime())) return \"not_a_date\";\n const namesATime = /\\d:\\d/.test(text);\n return namesATime || /^\\d{4}-\\d{2}-\\d{2}$/.test(text) ? date : utcDay(date);\n}\n\n/** Whether this browser's locale writes the day before the month. */\nfunction localeWritesDayFirst(): boolean {\n const parts = new Intl.DateTimeFormat().formatToParts(new Date(2000, 10, 22));\n const day = parts.findIndex(part => part.type === \"day\");\n const month = parts.findIndex(part => part.type === \"month\");\n return day >= 0 && month >= 0 && day < month;\n}\n\n/**\n * For each column of the file, how it writes day/month dates with numbers\n * only, when its values say: a first number past 12 is a day, so the column\n * is day first; a second number past 12, month first; both, and each date\n * is read by the only order that fits it. A column that never says is read\n * in the order of the browser's locale.\n */\nexport function slashDateOrdersByColumn(data: object[],\n properties?: Properties,\n targetOf?: ColumnTarget): Record<string, SlashDateOrder | undefined> {\n const seen: Record<string, { dayFirst: boolean, monthFirst: boolean }> = {};\n for (const row of data) {\n for (const [column, value] of Object.entries(flattenEntry(row as Record<string, unknown>, properties, targetOf))) {\n if (typeof value !== \"string\") continue;\n const slash = SLASH_DATE.exec(value.trim());\n if (!slash) continue;\n const entry = Object.hasOwn(seen, column) ? seen[column] : (seen[column] = { dayFirst: false, monthFirst: false });\n if (Number(slash[1]) > 12) entry.dayFirst = true;\n if (Number(slash[3]) > 12) entry.monthFirst = true;\n }\n }\n const orders: Record<string, SlashDateOrder | undefined> = {};\n for (const [column, { dayFirst, monthFirst }] of Object.entries(seen)) {\n orders[column] = dayFirst && monthFirst ? \"each\" : dayFirst ? \"dmy\" : monthFirst ? \"mdy\" : undefined;\n }\n return orders;\n}\n"],"mappings":";;;;;;;;;;;;;AA6DA,SAAgB,kBAAkB,gBAC9B,YACA,MACA,UACA,gBACA,YACA,MACA,eAAsG;CACtG,MAAM,WAAsC,CAAC;CAC7C,MAAM,aAAa,wBAAwB,MAAM,YAAY,mBAAmB,cAAc,CAAC;CAK/F,OAAO;EAAE,UAJQ,KAAK,KAAK,KAAK,UAAU,oBAAoB,gBAAgB,YAC1E,KAAgC,UAAU,gBAAgB,YAAY,MAAM,gBAC3E,YAAY,SAAS,KAAK;GAAE,KAAK;GAAO,GAAG;EAAQ,CAAC,GACrD,UAAU,CACL;EAAU;CAAS;AAChC;AAEA,SAAgB,oBAAoB,gBAChC,YACA,MACA,UACA,gBACA,YACA,MACA,eACA,WACA,YAAsE;CACtE,MAAM,aAAa,aAAa,MAAM,YAAY,mBAAmB,cAAc,CAAC;CACpF,IAAI,UACA,OAAO,WAAW;CAItB,MAAM,mBAA4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,UAAU,YAAY,aAAa,SAAS,WAAW,QAAQ,aAAa,QAAQ,KAAA;CAE/F,OAAO;AACX"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isPrototypePollutingKey } from "@rebasepro/utils";
|
|
2
|
+
//#region src/data_import/utils/file_headers.ts
|
|
3
|
+
/**
|
|
4
|
+
* Read the header names out of the first row.
|
|
5
|
+
*
|
|
6
|
+
* A column whose header is blank is left out entirely, so it contributes
|
|
7
|
+
* neither a field nor a value — the same intent as the old `filter(Boolean)`,
|
|
8
|
+
* without the shift.
|
|
9
|
+
*/
|
|
10
|
+
function getWorksheetHeaders(headerRow) {
|
|
11
|
+
const byColumn = /* @__PURE__ */ new Map();
|
|
12
|
+
const order = [];
|
|
13
|
+
const taken = /* @__PURE__ */ new Set();
|
|
14
|
+
headerRow.forEach((cell, index) => {
|
|
15
|
+
if (cell === null || cell === void 0) return;
|
|
16
|
+
const base = (cell instanceof Date ? cell.toISOString() : String(cell)).trim();
|
|
17
|
+
if (!base) return;
|
|
18
|
+
let name = base;
|
|
19
|
+
for (let n = 2; taken.has(name); n++) name = `${base}_${n}`;
|
|
20
|
+
taken.add(name);
|
|
21
|
+
byColumn.set(index, name);
|
|
22
|
+
if (!isPrototypePollutingKey(name)) order.push(name);
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
byColumn,
|
|
26
|
+
order
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { getWorksheetHeaders };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=file_headers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file_headers.js","names":[],"sources":["../../../src/data_import/utils/file_headers.ts"],"sourcesContent":["import { isPrototypePollutingKey } from \"@rebasepro/utils\";\n\n/**\n * The header row of a spreadsheet, as a column index → name map.\n *\n * A map rather than an array, and that is the whole point. The ExcelJS version\n * built a *sparse* array keyed by column and then returned\n * `headers.filter(Boolean)`, which compacts it — so a sheet with a blank header\n * in the middle shifted every later name one column to the left, and the import\n * wrote each of those columns' values into its neighbour's field. Silently: the\n * row count was right, the field names were right, and only the values were in\n * the wrong places.\n *\n * Keeping the column index means a blank header can be dropped (which is what\n * `filter(Boolean)` was reaching for) without moving anything else.\n */\nexport interface SheetHeaders {\n /** Column index (0-based) → the field name that column feeds. */\n byColumn: Map<number, string>;\n /** The names in column order — the import's `propertiesOrder`. */\n order: string[];\n}\n\n/** A cell as `read-excel-file` hands it over: a primitive, or null when empty. */\nexport type SheetCell = string | number | boolean | Date | null;\n\n/**\n * Read the header names out of the first row.\n *\n * A column whose header is blank is left out entirely, so it contributes\n * neither a field nor a value — the same intent as the old `filter(Boolean)`,\n * without the shift.\n */\nexport function getWorksheetHeaders(headerRow: readonly SheetCell[]): SheetHeaders {\n const byColumn = new Map<number, string>();\n const order: string[] = [];\n const taken = new Set<string>();\n\n headerRow.forEach((cell, index) => {\n // `0` and `false` are legitimate header text and must survive; only an\n // empty cell and an all-whitespace one are \"no header\".\n if (cell === null || cell === undefined) return;\n const base = (cell instanceof Date ? cell.toISOString() : String(cell)).trim();\n if (!base) return;\n // A repeated header is a column of its own (`x`, `x_2`), as in the\n // CSV reader: under one name, the later column's cells overwrote the\n // earlier's.\n let name = base;\n for (let n = 2; taken.has(name); n++) name = `${base}_${n}`;\n taken.add(name);\n byColumn.set(index, name);\n // Refused as a column when the rows are read, so not one of the\n // file's order either (see `parseCsvToObjects`).\n if (!isPrototypePollutingKey(name)) order.push(name);\n });\n\n return { byColumn, order };\n}\n"],"mappings":";;;;;;;;;AAiCA,SAAgB,oBAAoB,WAA+C;CAC/E,MAAM,2BAAW,IAAI,IAAoB;CACzC,MAAM,QAAkB,CAAC;CACzB,MAAM,wBAAQ,IAAI,IAAY;CAE9B,UAAU,SAAS,MAAM,UAAU;EAG/B,IAAI,SAAS,QAAQ,SAAS,KAAA,GAAW;EACzC,MAAM,QAAQ,gBAAgB,OAAO,KAAK,YAAY,IAAI,OAAO,IAAI,EAAA,CAAG,KAAK;EAC7E,IAAI,CAAC,MAAM;EAIX,IAAI,OAAO;EACX,KAAK,IAAI,IAAI,GAAG,MAAM,IAAI,IAAI,GAAG,KAAK,OAAO,GAAG,KAAK,GAAG;EACxD,MAAM,IAAI,IAAI;EACd,SAAS,IAAI,OAAO,IAAI;EAGxB,IAAI,CAAC,wBAAwB,IAAI,GAAG,MAAM,KAAK,IAAI;CACvD,CAAC;CAED,OAAO;EAAE;EAAU;CAAM;AAC7B"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { getWorksheetHeaders } from "./file_headers.js";
|
|
2
|
+
import { mapJsonParse, unflattenObject } from "./transforms.js";
|
|
3
|
+
import { parseCsvToObjects } from "./csv.js";
|
|
4
|
+
import { isPrototypePollutingKey } from "@rebasepro/utils";
|
|
5
|
+
//#region src/data_import/utils/file_to_json.ts
|
|
6
|
+
var xlsxReader;
|
|
7
|
+
function loadXlsxReader() {
|
|
8
|
+
xlsxReader ??= import("read-excel-file/browser").then((mod) => {
|
|
9
|
+
const candidate = mod.default ?? mod;
|
|
10
|
+
const fn = typeof candidate === "function" ? candidate : candidate?.default;
|
|
11
|
+
if (typeof fn !== "function") throw new Error("read-excel-file did not resolve to a function");
|
|
12
|
+
return fn;
|
|
13
|
+
});
|
|
14
|
+
return xlsxReader;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Put a date the reader left a millisecond short back on its second.
|
|
18
|
+
*
|
|
19
|
+
* `read-excel-file` turns Excel's date serials (fractional days) into
|
|
20
|
+
* milliseconds with `Math.floor`, and the fraction is rarely exact in floating
|
|
21
|
+
* point: a time of 12:30:00 arrives as 12:29:59.999, and a field that shows
|
|
22
|
+
* minutes displays 12:29. A date within a millisecond of a whole second is put
|
|
23
|
+
* back on it; a genuine sub-second value is left alone.
|
|
24
|
+
*/
|
|
25
|
+
function snapToSecond(cell) {
|
|
26
|
+
if (!(cell instanceof Date)) return cell;
|
|
27
|
+
const time = cell.getTime();
|
|
28
|
+
const second = Math.round(time / 1e3) * 1e3;
|
|
29
|
+
return Math.abs(time - second) <= 1 ? new Date(second) : cell;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Whether this file is delimited text rather than a workbook.
|
|
33
|
+
*
|
|
34
|
+
* Browsers report `text/csv`, `application/csv` or nothing at all for the same
|
|
35
|
+
* `.csv`, so the extension is the reliable half of the test.
|
|
36
|
+
*/
|
|
37
|
+
function isCsvFile(file) {
|
|
38
|
+
const name = (file.name ?? "").toLowerCase();
|
|
39
|
+
if (name.endsWith(".csv") || name.endsWith(".tsv")) return true;
|
|
40
|
+
return file.type === "text/csv" || file.type === "application/csv";
|
|
41
|
+
}
|
|
42
|
+
/** Turn the parsed cells of one sheet/file into the entity-shaped rows the import maps. */
|
|
43
|
+
function toImportRows(rows) {
|
|
44
|
+
return rows.map(mapJsonParse).map(unflattenObject);
|
|
45
|
+
}
|
|
46
|
+
function convertFileToJson(file) {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
if (isCsvFile(file)) {
|
|
49
|
+
console.debug("Converting CSV file to JSON", file.name);
|
|
50
|
+
const reader = new FileReader();
|
|
51
|
+
reader.onload = function(e) {
|
|
52
|
+
try {
|
|
53
|
+
const { headers, data } = parseCsvToObjects(e.target?.result);
|
|
54
|
+
if (headers.length === 0) {
|
|
55
|
+
reject(/* @__PURE__ */ new Error("The CSV file is empty"));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
resolve({
|
|
59
|
+
data: toImportRows(data),
|
|
60
|
+
propertiesOrder: headers
|
|
61
|
+
});
|
|
62
|
+
} catch (err) {
|
|
63
|
+
console.error("Error parsing CSV file", err);
|
|
64
|
+
reject(err);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
reader.onerror = () => reject(reader.error ?? /* @__PURE__ */ new Error("Could not read the file"));
|
|
68
|
+
reader.readAsText(file, "utf-8");
|
|
69
|
+
} else if (file.type === "application/json") {
|
|
70
|
+
console.debug("Converting JSON file to JSON", file.name);
|
|
71
|
+
const reader = new FileReader();
|
|
72
|
+
reader.onload = function(e) {
|
|
73
|
+
try {
|
|
74
|
+
const data = e.target?.result;
|
|
75
|
+
const jsonData = JSON.parse(data);
|
|
76
|
+
if (!Array.isArray(jsonData)) reject(/* @__PURE__ */ new Error("JSON file should contain an array of objects"));
|
|
77
|
+
else resolve({
|
|
78
|
+
data: jsonData,
|
|
79
|
+
propertiesOrder: jsonData.length > 0 ? Object.keys(jsonData[0]) : []
|
|
80
|
+
});
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.error("Error parsing JSON file", e);
|
|
83
|
+
reject(e);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
reader.readAsText(file);
|
|
87
|
+
} else {
|
|
88
|
+
console.debug("Converting Excel file to JSON", file.name);
|
|
89
|
+
const reader = new FileReader();
|
|
90
|
+
reader.onload = async function(e) {
|
|
91
|
+
try {
|
|
92
|
+
const buffer = e.target?.result;
|
|
93
|
+
const readXlsxFile = await loadXlsxReader();
|
|
94
|
+
const magic = new Uint8Array(buffer, 0, Math.min(2, buffer.byteLength));
|
|
95
|
+
if (magic[0] !== 80 || magic[1] !== 75) {
|
|
96
|
+
reject(/* @__PURE__ */ new Error(`'${file.name}' is not a readable .xlsx workbook. Export it again as .xlsx, or save it as .csv.`));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
let sheets;
|
|
100
|
+
try {
|
|
101
|
+
sheets = await readXlsxFile(buffer);
|
|
102
|
+
} catch (readError) {
|
|
103
|
+
console.debug("Spreadsheet reader failed", readError);
|
|
104
|
+
reject(/* @__PURE__ */ new Error("No worksheets found in file — it has no sheets, or none this reader can open."));
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const firstSheet = sheets[0];
|
|
108
|
+
if (!firstSheet) {
|
|
109
|
+
reject(/* @__PURE__ */ new Error("No worksheets found in file"));
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const [headerRow, ...dataRows] = firstSheet.data;
|
|
113
|
+
if (!headerRow) {
|
|
114
|
+
reject(/* @__PURE__ */ new Error("The spreadsheet is empty"));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const headers = getWorksheetHeaders(headerRow);
|
|
118
|
+
if (headers.order.length === 0) {
|
|
119
|
+
reject(/* @__PURE__ */ new Error("The spreadsheet has no column headers in its first row"));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const parsedData = [];
|
|
123
|
+
for (const row of dataRows) {
|
|
124
|
+
if (row.every((cell) => cell === null || cell === void 0)) continue;
|
|
125
|
+
const obj = {};
|
|
126
|
+
row.forEach((cell, index) => {
|
|
127
|
+
if (cell === null || cell === void 0) return;
|
|
128
|
+
const header = headers.byColumn.get(index);
|
|
129
|
+
if (header && !isPrototypePollutingKey(header)) obj[header] = snapToSecond(cell);
|
|
130
|
+
});
|
|
131
|
+
parsedData.push(obj);
|
|
132
|
+
}
|
|
133
|
+
resolve({
|
|
134
|
+
data: toImportRows(parsedData),
|
|
135
|
+
propertiesOrder: headers.order
|
|
136
|
+
});
|
|
137
|
+
} catch (err) {
|
|
138
|
+
console.error("Error parsing Excel file", err);
|
|
139
|
+
reject(err);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
reader.readAsArrayBuffer(file);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
export { convertFileToJson };
|
|
148
|
+
|
|
149
|
+
//# sourceMappingURL=file_to_json.js.map
|