@rebasepro/plugin-data-enhancement 0.0.1-canary.000dc36
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/LICENSE +114 -0
- package/README.md +89 -0
- package/dist/common/src/collections/CollectionRegistry.d.ts +56 -0
- package/dist/common/src/collections/index.d.ts +1 -0
- package/dist/common/src/data/buildRebaseData.d.ts +14 -0
- package/dist/common/src/index.d.ts +3 -0
- package/dist/common/src/util/builders.d.ts +57 -0
- package/dist/common/src/util/callbacks.d.ts +6 -0
- package/dist/common/src/util/collections.d.ts +11 -0
- package/dist/common/src/util/common.d.ts +2 -0
- package/dist/common/src/util/conditions.d.ts +26 -0
- package/dist/common/src/util/entities.d.ts +58 -0
- package/dist/common/src/util/enums.d.ts +3 -0
- package/dist/common/src/util/index.d.ts +16 -0
- package/dist/common/src/util/navigation_from_path.d.ts +34 -0
- package/dist/common/src/util/navigation_utils.d.ts +20 -0
- package/dist/common/src/util/parent_references_from_path.d.ts +6 -0
- package/dist/common/src/util/paths.d.ts +14 -0
- package/dist/common/src/util/permissions.d.ts +5 -0
- package/dist/common/src/util/references.d.ts +2 -0
- package/dist/common/src/util/relations.d.ts +22 -0
- package/dist/common/src/util/resolutions.d.ts +72 -0
- package/dist/common/src/util/storage.d.ts +24 -0
- package/dist/core/src/components/AIIcon.d.ts +16 -0
- package/dist/core/src/components/ConfirmationDialog.d.ts +9 -0
- package/dist/core/src/components/Debug/UIReferenceView.d.ts +1 -0
- package/dist/core/src/components/Debug/UIStyleGuide.d.ts +1 -0
- package/dist/core/src/components/ErrorTooltip.d.ts +2 -0
- package/dist/core/src/components/ErrorView.d.ts +21 -0
- package/dist/core/src/components/LanguageToggle.d.ts +1 -0
- package/dist/core/src/components/LoginView/LoginView.d.ts +68 -0
- package/dist/core/src/components/LoginView/index.d.ts +2 -0
- package/dist/core/src/components/NotFoundPage.d.ts +1 -0
- package/dist/core/src/components/RebaseAuth.d.ts +10 -0
- package/dist/core/src/components/RebaseLogo.d.ts +7 -0
- package/dist/core/src/components/UnsavedChangesDialog.d.ts +9 -0
- package/dist/core/src/components/UserDisplay.d.ts +7 -0
- package/dist/core/src/components/UserSelectPopover.d.ts +62 -0
- package/dist/core/src/components/UserSettingsView.d.ts +1 -0
- package/dist/core/src/components/common/index.d.ts +6 -0
- package/dist/core/src/components/common/table_height.d.ts +5 -0
- package/dist/core/src/components/common/types.d.ts +63 -0
- package/dist/core/src/components/common/useColumnsIds.d.ts +9 -0
- package/dist/core/src/components/common/useDataTableController.d.ts +45 -0
- package/dist/core/src/components/common/useDebouncedData.d.ts +9 -0
- package/dist/core/src/components/common/useScrollRestoration.d.ts +14 -0
- package/dist/core/src/components/index.d.ts +16 -0
- package/dist/core/src/contexts/AdminModeController.d.ts +4 -0
- package/dist/core/src/contexts/AnalyticsContext.d.ts +3 -0
- package/dist/core/src/contexts/AuthControllerContext.d.ts +3 -0
- package/dist/core/src/contexts/CustomizationControllerContext.d.ts +3 -0
- package/dist/core/src/contexts/DataDriverContext.d.ts +3 -0
- package/dist/core/src/contexts/DatabaseAdminContext.d.ts +3 -0
- package/dist/core/src/contexts/DialogsProvider.d.ts +4 -0
- package/dist/core/src/contexts/EffectiveRoleController.d.ts +4 -0
- package/dist/core/src/contexts/InternalUserManagementContext.d.ts +3 -0
- package/dist/core/src/contexts/ModeController.d.ts +4 -0
- package/dist/core/src/contexts/RebaseClientInstanceContext.d.ts +6 -0
- package/dist/core/src/contexts/RebaseDataContext.d.ts +3 -0
- package/dist/core/src/contexts/SnackbarProvider.d.ts +2 -0
- package/dist/core/src/contexts/StorageSourceContext.d.ts +3 -0
- package/dist/core/src/contexts/UserConfigurationPersistenceContext.d.ts +3 -0
- package/dist/core/src/contexts/index.d.ts +13 -0
- package/dist/core/src/core/PluginLifecycleManager.d.ts +17 -0
- package/dist/core/src/core/PluginProviderStack.d.ts +21 -0
- package/dist/core/src/core/Rebase.d.ts +14 -0
- package/dist/core/src/core/RebaseProps.d.ts +136 -0
- package/dist/core/src/core/RebaseRouter.d.ts +4 -0
- package/dist/core/src/core/RebaseRoutes.d.ts +17 -0
- package/dist/core/src/core/index.d.ts +4 -0
- package/dist/core/src/hooks/ApiConfigContext.d.ts +24 -0
- package/dist/core/src/hooks/data/delete.d.ts +31 -0
- package/dist/core/src/hooks/data/save.d.ts +34 -0
- package/dist/core/src/hooks/data/useCollectionFetch.d.ts +51 -0
- package/dist/core/src/hooks/data/useData.d.ts +13 -0
- package/dist/core/src/hooks/data/useDataOrder.d.ts +12 -0
- package/dist/core/src/hooks/data/useEntityFetch.d.ts +38 -0
- package/dist/core/src/hooks/data/useRelationSelector.d.ts +52 -0
- package/dist/core/src/hooks/data/useUserSelector.d.ts +31 -0
- package/dist/core/src/hooks/index.d.ts +37 -0
- package/dist/core/src/hooks/useAdminModeController.d.ts +19 -0
- package/dist/core/src/hooks/useAnalyticsController.d.ts +5 -0
- package/dist/core/src/hooks/useAuthController.d.ts +11 -0
- package/dist/core/src/hooks/useAuthSubscription.d.ts +2 -0
- package/dist/core/src/hooks/useBackendStorageSource.d.ts +30 -0
- package/dist/core/src/hooks/useBridgeRegistration.d.ts +18 -0
- package/dist/core/src/hooks/useBrowserTitleAndIcon.d.ts +6 -0
- package/dist/core/src/hooks/useBuildAdminModeController.d.ts +6 -0
- package/dist/core/src/hooks/useBuildEffectiveRoleController.d.ts +8 -0
- package/dist/core/src/hooks/useBuildLocalConfigurationPersistence.d.ts +2 -0
- package/dist/core/src/hooks/useBuildModeController.d.ts +6 -0
- package/dist/core/src/hooks/useClipboard.d.ts +57 -0
- package/dist/core/src/hooks/useCollapsedGroups.d.ts +12 -0
- package/dist/core/src/hooks/useCustomizationController.d.ts +11 -0
- package/dist/core/src/hooks/useDialogsController.d.ts +11 -0
- package/dist/core/src/hooks/useEffectiveRoleController.d.ts +7 -0
- package/dist/core/src/hooks/useInternalUserManagementController.d.ts +12 -0
- package/dist/core/src/hooks/useLargeLayout.d.ts +1 -0
- package/dist/core/src/hooks/useModeController.d.ts +19 -0
- package/dist/core/src/hooks/usePermissions.d.ts +12 -0
- package/dist/core/src/hooks/useRebaseClient.d.ts +5 -0
- package/dist/core/src/hooks/useRebaseContext.d.ts +11 -0
- package/dist/core/src/hooks/useRebaseRegistry.d.ts +34 -0
- package/dist/core/src/hooks/useSlot.d.ts +18 -0
- package/dist/core/src/hooks/useSnackbarController.d.ts +20 -0
- package/dist/core/src/hooks/useStorageSource.d.ts +7 -0
- package/dist/core/src/hooks/useStudioBridge.d.ts +91 -0
- package/dist/core/src/hooks/useTranslation.d.ts +17 -0
- package/dist/core/src/hooks/useUnsavedChangesDialog.d.ts +12 -0
- package/dist/core/src/hooks/useUserConfigurationPersistence.d.ts +8 -0
- package/dist/core/src/hooks/useValidateAuthenticator.d.ts +21 -0
- package/dist/core/src/i18n/RebaseI18nProvider.d.ts +33 -0
- package/dist/core/src/index.d.ts +15 -0
- package/dist/core/src/internal/common.d.ts +3 -0
- package/dist/core/src/internal/useRestoreScroll.d.ts +6 -0
- package/dist/core/src/locales/de.d.ts +2 -0
- package/dist/core/src/locales/en.d.ts +10 -0
- package/dist/core/src/locales/es.d.ts +10 -0
- package/dist/core/src/locales/fr.d.ts +2 -0
- package/dist/core/src/locales/hi.d.ts +2 -0
- package/dist/core/src/locales/it.d.ts +2 -0
- package/dist/core/src/locales/pt.d.ts +7 -0
- package/dist/core/src/util/constants.d.ts +1 -0
- package/dist/core/src/util/createFormexStub.d.ts +2 -0
- package/dist/core/src/util/entity_cache.d.ts +27 -0
- package/dist/core/src/util/enums.d.ts +5 -0
- package/dist/core/src/util/icon_list.d.ts +5 -0
- package/dist/core/src/util/icon_synonyms.d.ts +1 -0
- package/dist/core/src/util/icons.d.ts +20 -0
- package/dist/core/src/util/index.d.ts +10 -0
- package/dist/core/src/util/previews.d.ts +4 -0
- package/dist/core/src/util/useStorageUploadController.d.ts +38 -0
- package/dist/core/src/util/useTraceUpdate.d.ts +2 -0
- package/dist/formex/src/Field.d.ts +52 -0
- package/dist/formex/src/Formex.d.ts +7 -0
- package/dist/formex/src/index.d.ts +5 -0
- package/dist/formex/src/types.d.ts +40 -0
- package/dist/formex/src/useCreateFormex.d.ts +14 -0
- package/dist/formex/src/utils.d.ts +16 -0
- package/dist/index.es.js +751 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +746 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/plugin-data-enhancement/src/api.d.ts +34 -0
- package/dist/plugin-data-enhancement/src/components/DataEnhancementControllerProvider.d.ts +14 -0
- package/dist/plugin-data-enhancement/src/components/FormEnhanceAction.d.ts +10 -0
- package/dist/plugin-data-enhancement/src/editor/useEditorAIController.d.ts +4 -0
- package/dist/plugin-data-enhancement/src/index.d.ts +4 -0
- package/dist/plugin-data-enhancement/src/locales/de.d.ts +21 -0
- package/dist/plugin-data-enhancement/src/locales/en.d.ts +21 -0
- package/dist/plugin-data-enhancement/src/locales/es.d.ts +21 -0
- package/dist/plugin-data-enhancement/src/locales/fr.d.ts +21 -0
- package/dist/plugin-data-enhancement/src/locales/hi.d.ts +21 -0
- package/dist/plugin-data-enhancement/src/locales/it.d.ts +21 -0
- package/dist/plugin-data-enhancement/src/locales/pt.d.ts +21 -0
- package/dist/plugin-data-enhancement/src/types/data_enhancement_controller.d.ts +71 -0
- package/dist/plugin-data-enhancement/src/types/subscriptions_message_props.d.ts +3 -0
- package/dist/plugin-data-enhancement/src/useDataEnhancementPlugin.d.ts +29 -0
- package/dist/plugin-data-enhancement/src/utils/diffStrings.d.ts +7 -0
- package/dist/plugin-data-enhancement/src/utils/properties.d.ts +3 -0
- package/dist/plugin-data-enhancement/src/utils/strings_counter.d.ts +2 -0
- package/dist/plugin-data-enhancement/src/utils/suggestions.d.ts +1 -0
- package/dist/plugin-data-enhancement/src/utils/values.d.ts +1 -0
- package/dist/types/src/controllers/analytics_controller.d.ts +7 -0
- package/dist/types/src/controllers/auth.d.ts +119 -0
- package/dist/types/src/controllers/client.d.ts +170 -0
- package/dist/types/src/controllers/collection_registry.d.ts +46 -0
- package/dist/types/src/controllers/customization_controller.d.ts +60 -0
- package/dist/types/src/controllers/data.d.ts +168 -0
- package/dist/types/src/controllers/data_driver.d.ts +195 -0
- package/dist/types/src/controllers/database_admin.d.ts +11 -0
- package/dist/types/src/controllers/dialogs_controller.d.ts +36 -0
- package/dist/types/src/controllers/effective_role.d.ts +4 -0
- package/dist/types/src/controllers/email.d.ts +34 -0
- package/dist/types/src/controllers/index.d.ts +18 -0
- package/dist/types/src/controllers/local_config_persistence.d.ts +20 -0
- package/dist/types/src/controllers/navigation.d.ts +213 -0
- package/dist/types/src/controllers/registry.d.ts +54 -0
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +67 -0
- package/dist/types/src/controllers/side_entity_controller.d.ts +90 -0
- package/dist/types/src/controllers/snackbar.d.ts +24 -0
- package/dist/types/src/controllers/storage.d.ts +171 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/rebase_context.d.ts +105 -0
- package/dist/types/src/types/backend.d.ts +536 -0
- package/dist/types/src/types/backend_hooks.d.ts +187 -0
- package/dist/types/src/types/builders.d.ts +15 -0
- package/dist/types/src/types/chips.d.ts +5 -0
- package/dist/types/src/types/collections.d.ts +857 -0
- package/dist/types/src/types/cron.d.ts +102 -0
- package/dist/types/src/types/data_source.d.ts +64 -0
- package/dist/types/src/types/entities.d.ts +145 -0
- package/dist/types/src/types/entity_actions.d.ts +98 -0
- package/dist/types/src/types/entity_callbacks.d.ts +173 -0
- package/dist/types/src/types/entity_link_builder.d.ts +7 -0
- package/dist/types/src/types/entity_overrides.d.ts +10 -0
- package/dist/types/src/types/entity_views.d.ts +59 -0
- package/dist/types/src/types/export_import.d.ts +21 -0
- package/dist/types/src/types/formex.d.ts +40 -0
- package/dist/types/src/types/index.d.ts +25 -0
- package/dist/types/src/types/locales.d.ts +4 -0
- package/dist/types/src/types/modify_collections.d.ts +5 -0
- package/dist/types/src/types/plugins.d.ts +282 -0
- package/dist/types/src/types/properties.d.ts +1148 -0
- package/dist/types/src/types/property_config.d.ts +70 -0
- package/dist/types/src/types/relations.d.ts +336 -0
- package/dist/types/src/types/slots.d.ts +262 -0
- package/dist/types/src/types/translations.d.ts +874 -0
- package/dist/types/src/types/user_management_delegate.d.ts +121 -0
- package/dist/types/src/types/websockets.d.ts +78 -0
- package/dist/types/src/users/index.d.ts +2 -0
- package/dist/types/src/users/roles.d.ts +22 -0
- package/dist/types/src/users/user.d.ts +46 -0
- package/dist/ui/src/components/Alert.d.ts +12 -0
- package/dist/ui/src/components/Autocomplete.d.ts +21 -0
- package/dist/ui/src/components/Avatar.d.ts +11 -0
- package/dist/ui/src/components/Badge.d.ts +8 -0
- package/dist/ui/src/components/BooleanSwitch.d.ts +14 -0
- package/dist/ui/src/components/BooleanSwitchWithLabel.d.ts +17 -0
- package/dist/ui/src/components/Button.d.ts +14 -0
- package/dist/ui/src/components/Card.d.ts +9 -0
- package/dist/ui/src/components/CenteredView.d.ts +9 -0
- package/dist/ui/src/components/Checkbox.d.ts +13 -0
- package/dist/ui/src/components/Chip.d.ts +26 -0
- package/dist/ui/src/components/CircularProgress.d.ts +5 -0
- package/dist/ui/src/components/CircularProgressCenter.d.ts +11 -0
- package/dist/ui/src/components/Collapse.d.ts +9 -0
- package/dist/ui/src/components/ColorPicker.d.ts +30 -0
- package/dist/ui/src/components/Container.d.ts +8 -0
- package/dist/ui/src/components/DateTimeField.d.ts +24 -0
- package/dist/ui/src/components/DebouncedTextField.d.ts +2 -0
- package/dist/ui/src/components/Dialog.d.ts +39 -0
- package/dist/ui/src/components/DialogActions.d.ts +7 -0
- package/dist/ui/src/components/DialogContent.d.ts +7 -0
- package/dist/ui/src/components/DialogTitle.d.ts +10 -0
- package/dist/ui/src/components/ErrorBoundary.d.ts +11 -0
- package/dist/ui/src/components/ExpandablePanel.d.ts +12 -0
- package/dist/ui/src/components/FileUpload.d.ts +23 -0
- package/dist/ui/src/components/IconButton.d.ts +12 -0
- package/dist/ui/src/components/InfoLabel.d.ts +5 -0
- package/dist/ui/src/components/InputLabel.d.ts +11 -0
- package/dist/ui/src/components/Label.d.ts +7 -0
- package/dist/ui/src/components/LoadingButton.d.ts +7 -0
- package/dist/ui/src/components/Markdown.d.ts +10 -0
- package/dist/ui/src/components/Menu.d.ts +23 -0
- package/dist/ui/src/components/Menubar.d.ts +80 -0
- package/dist/ui/src/components/MultiSelect.d.ts +48 -0
- package/dist/ui/src/components/Paper.d.ts +6 -0
- package/dist/ui/src/components/Popover.d.ts +24 -0
- package/dist/ui/src/components/RadioGroup.d.ts +28 -0
- package/dist/ui/src/components/ResizablePanels.d.ts +18 -0
- package/dist/ui/src/components/SearchBar.d.ts +22 -0
- package/dist/ui/src/components/Select.d.ts +43 -0
- package/dist/ui/src/components/Separator.d.ts +5 -0
- package/dist/ui/src/components/Sheet.d.ts +22 -0
- package/dist/ui/src/components/Skeleton.d.ts +6 -0
- package/dist/ui/src/components/Slider.d.ts +21 -0
- package/dist/ui/src/components/Table.d.ts +34 -0
- package/dist/ui/src/components/Tabs.d.ts +19 -0
- package/dist/ui/src/components/TextField.d.ts +58 -0
- package/dist/ui/src/components/TextareaAutosize.d.ts +43 -0
- package/dist/ui/src/components/ToggleButtonGroup.d.ts +30 -0
- package/dist/ui/src/components/Tooltip.d.ts +19 -0
- package/dist/ui/src/components/Typography.d.ts +36 -0
- package/dist/ui/src/components/VirtualTable/VirtualTable.d.ts +11 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableCell.d.ts +21 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableHeader.d.ts +29 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableHeaderRow.d.ts +2 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableProps.d.ts +243 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableRow.d.ts +3 -0
- package/dist/ui/src/components/VirtualTable/index.d.ts +3 -0
- package/dist/ui/src/components/VirtualTable/types.d.ts +38 -0
- package/dist/ui/src/components/common/SelectInputLabel.d.ts +5 -0
- package/dist/ui/src/components/index.d.ts +53 -0
- package/dist/ui/src/hooks/PortalContainerContext.d.ts +31 -0
- package/dist/ui/src/hooks/index.d.ts +6 -0
- package/dist/ui/src/hooks/useDebounceCallback.d.ts +1 -0
- package/dist/ui/src/hooks/useDebounceValue.d.ts +1 -0
- package/dist/ui/src/hooks/useDebouncedCallback.d.ts +1 -0
- package/dist/ui/src/hooks/useInjectStyles.d.ts +7 -0
- package/dist/ui/src/hooks/useOutsideAlerter.d.ts +5 -0
- package/dist/ui/src/icons/GitHubIcon.d.ts +2 -0
- package/dist/ui/src/icons/HandleIcon.d.ts +1 -0
- package/dist/ui/src/icons/Icon.d.ts +20 -0
- package/dist/ui/src/icons/cool_icon_keys.d.ts +1 -0
- package/dist/ui/src/icons/icon_keys.d.ts +1 -0
- package/dist/ui/src/icons/index.d.ts +6 -0
- package/dist/ui/src/index.d.ts +5 -0
- package/dist/ui/src/styles.d.ts +12 -0
- package/dist/ui/src/util/chip_colors.d.ts +4 -0
- package/dist/ui/src/util/cls.d.ts +2 -0
- package/dist/ui/src/util/debounce.d.ts +10 -0
- package/dist/ui/src/util/hash.d.ts +1 -0
- package/dist/ui/src/util/index.d.ts +4 -0
- package/dist/ui/src/util/key_to_icon_component.d.ts +1 -0
- package/package.json +86 -0
- package/src/api.ts +198 -0
- package/src/components/DataEnhancementControllerProvider.tsx +339 -0
- package/src/components/FormEnhanceAction.tsx +273 -0
- package/src/editor/useEditorAIController.tsx +37 -0
- package/src/index.ts +10 -0
- package/src/locales/de.ts +21 -0
- package/src/locales/en.ts +21 -0
- package/src/locales/es.ts +21 -0
- package/src/locales/fr.ts +21 -0
- package/src/locales/hi.ts +21 -0
- package/src/locales/it.ts +21 -0
- package/src/locales/pt.ts +21 -0
- package/src/tests/diffStrings.test.ts +128 -0
- package/src/types/data_enhancement_controller.tsx +75 -0
- package/src/types/subscriptions_message_props.tsx +1 -0
- package/src/useDataEnhancementPlugin.tsx +66 -0
- package/src/utils/diffStrings.ts +70 -0
- package/src/utils/properties.ts +168 -0
- package/src/utils/strings_counter.ts +22 -0
- package/src/utils/suggestions.ts +6 -0
- package/src/utils/values.ts +12 -0
- package/src/vite-env.d.ts +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rebasepro/plugin-data-enhancement",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1-canary.000dc36",
|
|
5
|
+
"main": "./dist/index.umd.js",
|
|
6
|
+
"module": "./dist/index.es.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"source": "src/index.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"development": "./src/index.ts",
|
|
13
|
+
"import": "./dist/index.es.js",
|
|
14
|
+
"require": "./dist/index.umd.js"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"react-compiler-runtime": "1.0.0",
|
|
20
|
+
"@rebasepro/admin": "0.0.1-canary.000dc36",
|
|
21
|
+
"@rebasepro/core": "0.0.1-canary.000dc36",
|
|
22
|
+
"@rebasepro/ui": "0.0.1-canary.000dc36",
|
|
23
|
+
"@rebasepro/types": "0.0.1-canary.000dc36",
|
|
24
|
+
"@rebasepro/utils": "0.0.1-canary.000dc36",
|
|
25
|
+
"@rebasepro/common": "0.0.1-canary.000dc36"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"react": ">=19.0.0",
|
|
29
|
+
"react-dom": ">=19.0.0",
|
|
30
|
+
"react-router": ">=6.28.0",
|
|
31
|
+
"react-router-dom": ">=6.28.0"
|
|
32
|
+
},
|
|
33
|
+
"browserslist": {
|
|
34
|
+
"production": [
|
|
35
|
+
">0.2%",
|
|
36
|
+
"not dead",
|
|
37
|
+
"not op_mini all"
|
|
38
|
+
],
|
|
39
|
+
"development": [
|
|
40
|
+
"last 1 chrome version",
|
|
41
|
+
"last 1 firefox version",
|
|
42
|
+
"last 1 safari version"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
47
|
+
"@types/jest": "^29.5.14",
|
|
48
|
+
"@types/react": "^19.0.8",
|
|
49
|
+
"@types/react-dom": "^19.0.3",
|
|
50
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
51
|
+
"babel-jest": "^29.7.0",
|
|
52
|
+
"babel-plugin-react-compiler": "^19.0.0-beta-af1b7da-20250417",
|
|
53
|
+
"eslint-plugin-react-compiler": "^19.1.0-rc.2",
|
|
54
|
+
"jest": "^29.7.0",
|
|
55
|
+
"ts-jest": "^29.4.5",
|
|
56
|
+
"typescript": "^5.9.3",
|
|
57
|
+
"vite": "^7.2.4"
|
|
58
|
+
},
|
|
59
|
+
"jest": {
|
|
60
|
+
"transform": {
|
|
61
|
+
"^.+\\.tsx?$": "ts-jest"
|
|
62
|
+
},
|
|
63
|
+
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
|
|
64
|
+
"moduleFileExtensions": [
|
|
65
|
+
"ts",
|
|
66
|
+
"tsx",
|
|
67
|
+
"js",
|
|
68
|
+
"jsx",
|
|
69
|
+
"json",
|
|
70
|
+
"node"
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
"files": [
|
|
74
|
+
"dist",
|
|
75
|
+
"src"
|
|
76
|
+
],
|
|
77
|
+
"publishConfig": {
|
|
78
|
+
"access": "public"
|
|
79
|
+
},
|
|
80
|
+
"gitHead": "d935eefa5aa8d1009a2398cfac2c1e4ee9aeb6b6",
|
|
81
|
+
"scripts": {
|
|
82
|
+
"dev": "vite",
|
|
83
|
+
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
|
|
84
|
+
"test": "jest --passWithNoTests"
|
|
85
|
+
}
|
|
86
|
+
}
|
package/src/api.ts
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DataEnhancementRequest,
|
|
3
|
+
EnhancedDataResult,
|
|
4
|
+
InputEntity,
|
|
5
|
+
InputProperty,
|
|
6
|
+
SamplePromptsResult
|
|
7
|
+
} from "./types/data_enhancement_controller";
|
|
8
|
+
import { EntityValues } from "@rebasepro/types";
|
|
9
|
+
import { flatMapEntityValues } from "./utils/values";
|
|
10
|
+
|
|
11
|
+
// const DEFAULT_SERVER = "http://localhost:5001/rebase-dev-2da42/europe-west3/api"; // Local
|
|
12
|
+
|
|
13
|
+
const DEFAULT_SERVER = "https://api.rebase.pro";
|
|
14
|
+
|
|
15
|
+
export async function enhanceDataAPIStream<M extends Record<string, unknown>>(props: {
|
|
16
|
+
apiKey: string,
|
|
17
|
+
entityId?: string | number,
|
|
18
|
+
entityName: string,
|
|
19
|
+
entityDescription?: string,
|
|
20
|
+
propertyKey?: string,
|
|
21
|
+
propertyInstructions?: string;
|
|
22
|
+
values: EntityValues<M>,
|
|
23
|
+
path: string,
|
|
24
|
+
properties: Record<string, InputProperty>,
|
|
25
|
+
|
|
26
|
+
instructions?: string,
|
|
27
|
+
firebaseToken: string,
|
|
28
|
+
onUpdate: (suggestions: Record<string, any>) => void;
|
|
29
|
+
onUpdateDelta: (propertyKey: string, partialValue: any) => void;
|
|
30
|
+
onError: (error: Error) => void;
|
|
31
|
+
onEnd: (result: EnhancedDataResult) => void;
|
|
32
|
+
host?: string;
|
|
33
|
+
}) {
|
|
34
|
+
|
|
35
|
+
const flatValues = flatMapEntityValues(props.values);
|
|
36
|
+
|
|
37
|
+
const properties = props.properties;
|
|
38
|
+
|
|
39
|
+
const inputEntity: InputEntity = {
|
|
40
|
+
entityId: props.entityId,
|
|
41
|
+
values: flatValues
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const request: DataEnhancementRequest = {
|
|
45
|
+
inputEntity,
|
|
46
|
+
properties,
|
|
47
|
+
entityName: props.entityName,
|
|
48
|
+
entityDescription: props.entityDescription,
|
|
49
|
+
propertyKey: props.propertyKey,
|
|
50
|
+
propertyInstructions: props.propertyInstructions,
|
|
51
|
+
instructions: props.instructions
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
console.debug("enhanceDataAPIStream", request);
|
|
55
|
+
|
|
56
|
+
return fetch((props.host ?? DEFAULT_SERVER) + "/data/enhance_stream/",
|
|
57
|
+
{
|
|
58
|
+
// mode: "no-cors",
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: {
|
|
61
|
+
"Content-Type": "application/json",
|
|
62
|
+
Authorization: `Basic ${props.firebaseToken}`,
|
|
63
|
+
"x-de-api-key": `Basic ${props.apiKey}`
|
|
64
|
+
// "x-de-version": version
|
|
65
|
+
},
|
|
66
|
+
body: JSON.stringify(request)
|
|
67
|
+
})
|
|
68
|
+
.then(async (res) => {
|
|
69
|
+
if (!res.ok) {
|
|
70
|
+
console.error("enhanceDataAPIStream error", res)
|
|
71
|
+
throw await res.json();
|
|
72
|
+
}
|
|
73
|
+
const reader = res.body?.getReader();
|
|
74
|
+
if (!reader) {
|
|
75
|
+
throw new Error("No reader");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
for await (const chunk of readChunks(reader)) {
|
|
79
|
+
const str = new TextDecoder().decode(chunk);
|
|
80
|
+
try {
|
|
81
|
+
str.split("&$# ").forEach((s) => {
|
|
82
|
+
if (s && s.length > 0) {
|
|
83
|
+
const data = JSON.parse(s.trim());
|
|
84
|
+
if (data.type === "suggestion_delta")
|
|
85
|
+
props.onUpdateDelta(data.data.propertyKey, data.data.partialValue);
|
|
86
|
+
else if (data.type === "suggestion")
|
|
87
|
+
props.onUpdate(data.data);
|
|
88
|
+
else if (data.type === "result")
|
|
89
|
+
props.onEnd(data.data);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
} catch (e: any) {
|
|
93
|
+
console.error("str", str);
|
|
94
|
+
console.error("Error parsing stream", e);
|
|
95
|
+
props.onError(e);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function readChunks(reader: ReadableStreamDefaultReader) {
|
|
104
|
+
return {
|
|
105
|
+
async *[Symbol.asyncIterator]() {
|
|
106
|
+
let readResult = await reader.read();
|
|
107
|
+
while (!readResult.done) {
|
|
108
|
+
yield readResult.value;
|
|
109
|
+
readResult = await reader.read();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export async function fetchEntityPromptSuggestion<M extends object>(props: {
|
|
116
|
+
input?: string,
|
|
117
|
+
entityName: string,
|
|
118
|
+
firebaseToken: string,
|
|
119
|
+
apiKey: string,
|
|
120
|
+
host?: string
|
|
121
|
+
}): Promise<SamplePromptsResult> {
|
|
122
|
+
|
|
123
|
+
return fetch((props.host ?? DEFAULT_SERVER) + "/data/prompt_autocomplete/",
|
|
124
|
+
{
|
|
125
|
+
// mode: "no-cors",
|
|
126
|
+
method: "POST",
|
|
127
|
+
headers: {
|
|
128
|
+
"Content-Type": "application/json",
|
|
129
|
+
Authorization: `Basic ${props.firebaseToken}`,
|
|
130
|
+
"x-de-api-key": `Basic ${props.apiKey}`
|
|
131
|
+
},
|
|
132
|
+
body: JSON.stringify({
|
|
133
|
+
entityName: props.entityName,
|
|
134
|
+
input: props.input ?? null
|
|
135
|
+
})
|
|
136
|
+
})
|
|
137
|
+
.then(async (res) => {
|
|
138
|
+
const data = await res.json();
|
|
139
|
+
if (!res.ok) {
|
|
140
|
+
console.error("fetchEntityPromptSuggestion", data);
|
|
141
|
+
throw Error(data.message);
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
prompts: data.data.prompts.map((e: string) => ({
|
|
145
|
+
prompt: e,
|
|
146
|
+
type: "sample"
|
|
147
|
+
}))
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export async function autocompleteStream(props: {
|
|
154
|
+
firebaseToken: string,
|
|
155
|
+
textBefore?: string,
|
|
156
|
+
textAfter: string,
|
|
157
|
+
host?: string;
|
|
158
|
+
onUpdate: (delta: string) => void;
|
|
159
|
+
}) {
|
|
160
|
+
|
|
161
|
+
let result = "";
|
|
162
|
+
return fetch((props.host ?? DEFAULT_SERVER) + "/data/autocomplete/",
|
|
163
|
+
{
|
|
164
|
+
// mode: "no-cors",
|
|
165
|
+
method: "POST",
|
|
166
|
+
headers: {
|
|
167
|
+
"Content-Type": "application/json",
|
|
168
|
+
Authorization: `Basic ${props.firebaseToken}`
|
|
169
|
+
// "x-de-version": version
|
|
170
|
+
},
|
|
171
|
+
body: JSON.stringify({
|
|
172
|
+
textBefore: props.textBefore,
|
|
173
|
+
textAfter: props.textAfter
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
.then(async (res) => {
|
|
177
|
+
if (!res.ok) {
|
|
178
|
+
console.error("enhanceDataAPIStream error", res)
|
|
179
|
+
throw await res.json();
|
|
180
|
+
}
|
|
181
|
+
const reader = res.body?.getReader();
|
|
182
|
+
if (!reader) {
|
|
183
|
+
throw new Error("No reader");
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
for await (const chunk of readChunks(reader)) {
|
|
187
|
+
const str = new TextDecoder().decode(chunk);
|
|
188
|
+
result += str;
|
|
189
|
+
console.debug("Autocomplete update:", str);
|
|
190
|
+
props.onUpdate(str);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
}).then(() => {
|
|
194
|
+
console.debug("Autocomplete result:", result);
|
|
195
|
+
return result;
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
}
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import React, { PropsWithChildren, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
DataEnhancementController,
|
|
5
|
+
EnhancedDataResult,
|
|
6
|
+
EnhanceParams,
|
|
7
|
+
InputProperty
|
|
8
|
+
} from "../types/data_enhancement_controller";
|
|
9
|
+
import {
|
|
10
|
+
useAuthController,
|
|
11
|
+
useCustomizationController,
|
|
12
|
+
useSnackbarController
|
|
13
|
+
} from "@rebasepro/core";
|
|
14
|
+
import { useUrlController } from "@rebasepro/admin";
|
|
15
|
+
import { DataDriver, Entity, EntityCollection, PluginFormActionProps } from "@rebasepro/types";
|
|
16
|
+
import { enhanceDataAPIStream, fetchEntityPromptSuggestion } from "../api";
|
|
17
|
+
import { getAppendableSuggestion } from "../utils/suggestions";
|
|
18
|
+
import { getSimplifiedProperties } from "../utils/properties";
|
|
19
|
+
import { useEditorAIController } from "../editor/useEditorAIController";
|
|
20
|
+
import { getValueInPath } from "@rebasepro/utils";
|
|
21
|
+
|
|
22
|
+
export const DataEnhancementControllerContext = React.createContext<DataEnhancementController>(null! as DataEnhancementController);
|
|
23
|
+
|
|
24
|
+
export type DataEnhancementControllerProviderProps = {
|
|
25
|
+
|
|
26
|
+
apiKey: string;
|
|
27
|
+
|
|
28
|
+
getConfigForPath?: (props: {
|
|
29
|
+
path: string,
|
|
30
|
+
collection: EntityCollection
|
|
31
|
+
}) => boolean;
|
|
32
|
+
|
|
33
|
+
host?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const useDataEnhancementController = (): DataEnhancementController => useContext(DataEnhancementControllerContext);
|
|
37
|
+
|
|
38
|
+
function getPropertyFromKey(properties: Record<string, InputProperty>, propertyKey: string) {
|
|
39
|
+
if (propertyKey in properties) {
|
|
40
|
+
return properties[propertyKey];
|
|
41
|
+
} else {
|
|
42
|
+
//split the property key
|
|
43
|
+
const split = propertyKey.split(".");
|
|
44
|
+
if (split.length === 1) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const parentKey = split.slice(0, split.length - 1).join(".");
|
|
48
|
+
return getPropertyFromKey(properties, parentKey);
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function DataEnhancementControllerProvider({
|
|
54
|
+
apiKey,
|
|
55
|
+
getConfigForPath,
|
|
56
|
+
children,
|
|
57
|
+
host,
|
|
58
|
+
path,
|
|
59
|
+
collection,
|
|
60
|
+
formContext
|
|
61
|
+
}: PropsWithChildren<DataEnhancementControllerProviderProps & PluginFormActionProps<any>>) {
|
|
62
|
+
|
|
63
|
+
const [enabled, setEnabled] = useState(false);
|
|
64
|
+
const [suggestions, setSuggestions] = useState<Record<string, string | number>>({});
|
|
65
|
+
const [loadingSuggestions, setLoadingSuggestions] = useState<string[]>([]);
|
|
66
|
+
|
|
67
|
+
const enhancingInProgress = useRef(false);
|
|
68
|
+
|
|
69
|
+
const authController = useAuthController();
|
|
70
|
+
const snackbarController = useSnackbarController();
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
const properties = useMemo(() => getSimplifiedProperties(collection.properties, formContext?.values ?? {}), [formContext?.values]);
|
|
74
|
+
// const preEnhanceValuesRef = React.useRef(formContext?.values ?? {});
|
|
75
|
+
const valuesRef = React.useRef(formContext?.values ?? {});
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (!enhancingInProgress.current)
|
|
78
|
+
valuesRef.current = formContext?.values ?? {};
|
|
79
|
+
}, [formContext?.values]);
|
|
80
|
+
|
|
81
|
+
const allowReferenceDataSelection = false;
|
|
82
|
+
|
|
83
|
+
const updateConfig = useCallback(async () => {
|
|
84
|
+
if (!getConfigForPath) return;
|
|
85
|
+
const config = getConfigForPath({
|
|
86
|
+
path,
|
|
87
|
+
collection
|
|
88
|
+
});
|
|
89
|
+
if (config) {
|
|
90
|
+
setEnabled(true);
|
|
91
|
+
}
|
|
92
|
+
}, [collection, getConfigForPath, path]);
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (!getConfigForPath) {
|
|
96
|
+
setEnabled(true);
|
|
97
|
+
} else {
|
|
98
|
+
updateConfig();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
}, [getConfigForPath, updateConfig]);
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
const urlController = useUrlController();
|
|
105
|
+
|
|
106
|
+
const clearSuggestion = useCallback((propertyKey: string) => {
|
|
107
|
+
setSuggestions((prev) => {
|
|
108
|
+
//remove propertyKey from prev
|
|
109
|
+
const {
|
|
110
|
+
[propertyKey]: _,
|
|
111
|
+
...rest
|
|
112
|
+
} = prev;
|
|
113
|
+
return rest;
|
|
114
|
+
});
|
|
115
|
+
}, []);
|
|
116
|
+
|
|
117
|
+
const appendValueDelta = useCallback((propertyKey: string, delta: string) => {
|
|
118
|
+
|
|
119
|
+
const property = getPropertyFromKey(properties, propertyKey);
|
|
120
|
+
if (delta === null || property?.disabled) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// clearSuggestion(propertyKey);
|
|
125
|
+
const value = getValueInPath(valuesRef.current, propertyKey);
|
|
126
|
+
|
|
127
|
+
const currentValue = value ? (value as string) + "" : "";
|
|
128
|
+
const updatedValue = currentValue + delta;
|
|
129
|
+
// if (currentValue.length === 0) updatedValue = updatedValue.trimStart();
|
|
130
|
+
valuesRef.current = {
|
|
131
|
+
...valuesRef.current,
|
|
132
|
+
[propertyKey]: updatedValue
|
|
133
|
+
};
|
|
134
|
+
formContext?.setFieldValue(propertyKey, updatedValue, false);
|
|
135
|
+
setSuggestions(prev => ({
|
|
136
|
+
...prev,
|
|
137
|
+
[propertyKey]: (prev[propertyKey] ?? "") + delta
|
|
138
|
+
}));
|
|
139
|
+
}, [properties, formContext]);
|
|
140
|
+
|
|
141
|
+
const updateSuggestedValues = useCallback((currentValues: object, updatedValues: Record<string, string | number>, replaceValues: boolean) => {
|
|
142
|
+
|
|
143
|
+
setLoadingSuggestions((prev) => {
|
|
144
|
+
return prev.filter(p => !Object.keys(updatedValues).includes(p));
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
Object.entries(updatedValues).forEach(([propertyKey, suggestion]) => {
|
|
148
|
+
|
|
149
|
+
const value = getValueInPath(currentValues, propertyKey);
|
|
150
|
+
const property = getPropertyFromKey(properties, propertyKey);
|
|
151
|
+
|
|
152
|
+
if (!property || suggestion === null || property?.disabled) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (typeof suggestion === "number") {
|
|
157
|
+
formContext?.setFieldValue(propertyKey, suggestion);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (replaceValues) {
|
|
162
|
+
formContext?.setFieldValue(propertyKey, suggestion);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const appendableValue = getAppendableSuggestion(suggestion, value);
|
|
167
|
+
|
|
168
|
+
const currentValue = value ? (value as string) + "" : "";
|
|
169
|
+
if (appendableValue) {
|
|
170
|
+
formContext?.setFieldValue(propertyKey, suggestion);
|
|
171
|
+
} else {
|
|
172
|
+
const multiline = property?.fieldConfigId === "multiline" || property?.fieldConfigId === "markdown";
|
|
173
|
+
const trimmedValue = currentValue.trimEnd();
|
|
174
|
+
if (multiline && (trimmedValue.endsWith(".") || trimmedValue.endsWith("?") || trimmedValue.endsWith("!") || trimmedValue.endsWith(":"))) {
|
|
175
|
+
formContext?.setFieldValue(propertyKey, trimmedValue + "\n\n" + (suggestion as string).trimStart());
|
|
176
|
+
} else {
|
|
177
|
+
formContext?.setFieldValue(propertyKey, trimmedValue + (trimmedValue.length > 0 ? " " : "") + (suggestion as string));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
setSuggestions(prev => ({
|
|
183
|
+
...prev,
|
|
184
|
+
...Object.keys(updatedValues)
|
|
185
|
+
.reduce((acc, key) => {
|
|
186
|
+
const value = getValueInPath(formContext?.values, key);
|
|
187
|
+
const suggestion = updatedValues[key];
|
|
188
|
+
return {
|
|
189
|
+
...acc,
|
|
190
|
+
[key]: getAppendableSuggestion(suggestion, value) ?? suggestion
|
|
191
|
+
};
|
|
192
|
+
}, {})
|
|
193
|
+
}));
|
|
194
|
+
}, [properties, formContext]);
|
|
195
|
+
|
|
196
|
+
const displayNeededSubscriptionSnackbar = useCallback((projectId: any) => {
|
|
197
|
+
snackbarController.open({
|
|
198
|
+
type: "warning",
|
|
199
|
+
message: "A valid subscription is needed in order to use this function.",
|
|
200
|
+
autoHideDuration: 4000
|
|
201
|
+
});
|
|
202
|
+
}, [snackbarController]);
|
|
203
|
+
|
|
204
|
+
const editorAIController = useEditorAIController({ getAuthToken: authController.getAuthToken });
|
|
205
|
+
|
|
206
|
+
const clearAllSuggestions = useCallback(() => {
|
|
207
|
+
setSuggestions({});
|
|
208
|
+
}, []);
|
|
209
|
+
|
|
210
|
+
const enhance = useCallback(async (props: EnhanceParams<any>): Promise<EnhancedDataResult | null> => {
|
|
211
|
+
|
|
212
|
+
if (!authController.user) {
|
|
213
|
+
snackbarController.open({
|
|
214
|
+
type: "warning",
|
|
215
|
+
message: "You need to be logged in to enhance data"
|
|
216
|
+
});
|
|
217
|
+
return Promise.reject(new Error("Not logged in"));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const resolvedPath = urlController.resolveDatabasePathsFrom(path);
|
|
221
|
+
const firebaseToken = await authController.getAuthToken();
|
|
222
|
+
|
|
223
|
+
if (props.propertyKey) {
|
|
224
|
+
clearSuggestion(props.propertyKey)
|
|
225
|
+
} else {
|
|
226
|
+
clearAllSuggestions();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
setLoadingSuggestions((prev) => [...prev, ...(props.propertyKey ? [props.propertyKey] : Object.keys(properties))]);
|
|
230
|
+
enhancingInProgress.current = true;
|
|
231
|
+
|
|
232
|
+
const currentValues = valuesRef.current ?? {};
|
|
233
|
+
|
|
234
|
+
return new Promise((resolve, reject) => {
|
|
235
|
+
function onError(e: any) {
|
|
236
|
+
setLoadingSuggestions([]);
|
|
237
|
+
if (e.code === "payment-required") {
|
|
238
|
+
const projectId = e.data.projectId;
|
|
239
|
+
displayNeededSubscriptionSnackbar(projectId);
|
|
240
|
+
} else {
|
|
241
|
+
console.error("Enhance error", e);
|
|
242
|
+
}
|
|
243
|
+
reject(e);
|
|
244
|
+
enhancingInProgress.current = false;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
try {
|
|
248
|
+
enhanceDataAPIStream({
|
|
249
|
+
...props,
|
|
250
|
+
host,
|
|
251
|
+
apiKey,
|
|
252
|
+
properties,
|
|
253
|
+
path: resolvedPath,
|
|
254
|
+
entityName: collection.singularName ?? collection.name,
|
|
255
|
+
entityDescription: collection.description,
|
|
256
|
+
|
|
257
|
+
firebaseToken,
|
|
258
|
+
onUpdate: (suggestions) => {
|
|
259
|
+
console.debug("de onUpdate", suggestions);
|
|
260
|
+
updateSuggestedValues(currentValues, suggestions, props.replaceValues ?? false);
|
|
261
|
+
},
|
|
262
|
+
onUpdateDelta: (propertyKey: string, partialValue: string) => {
|
|
263
|
+
// console.debug("de delta", propertyKey, partialValue);
|
|
264
|
+
appendValueDelta(propertyKey, partialValue);
|
|
265
|
+
},
|
|
266
|
+
onError,
|
|
267
|
+
onEnd: (result) => {
|
|
268
|
+
console.debug("de onEnd", result);
|
|
269
|
+
if (result.errors) {
|
|
270
|
+
result.errors.forEach((error) => {
|
|
271
|
+
snackbarController.open({
|
|
272
|
+
type: "warning",
|
|
273
|
+
message: error
|
|
274
|
+
})
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
if (Object.keys(result.suggestions).length === 0) {
|
|
278
|
+
snackbarController.open({
|
|
279
|
+
type: "info",
|
|
280
|
+
autoHideDuration: 1800,
|
|
281
|
+
message: "No fields were updated"
|
|
282
|
+
})
|
|
283
|
+
}
|
|
284
|
+
setLoadingSuggestions([]);
|
|
285
|
+
resolve(result);
|
|
286
|
+
enhancingInProgress.current = false;
|
|
287
|
+
}
|
|
288
|
+
}).catch(onError);
|
|
289
|
+
} catch (e: any) {
|
|
290
|
+
onError(e);
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}, [
|
|
294
|
+
authController, urlController, path, clearSuggestion, clearAllSuggestions,
|
|
295
|
+
properties, host, apiKey, collection, updateSuggestedValues, appendValueDelta, displayNeededSubscriptionSnackbar, snackbarController
|
|
296
|
+
]);
|
|
297
|
+
|
|
298
|
+
const getSamplePrompts = useCallback(async (entityName: string, input?: string) => {
|
|
299
|
+
const firebaseToken = await authController.getAuthToken()
|
|
300
|
+
return fetchEntityPromptSuggestion({
|
|
301
|
+
host,
|
|
302
|
+
entityName,
|
|
303
|
+
firebaseToken,
|
|
304
|
+
apiKey,
|
|
305
|
+
input
|
|
306
|
+
});
|
|
307
|
+
}, [apiKey, authController.getAuthToken, host]);
|
|
308
|
+
|
|
309
|
+
const dataEnhancementController: DataEnhancementController = useMemo(() => ({
|
|
310
|
+
enabled,
|
|
311
|
+
suggestions,
|
|
312
|
+
clearSuggestion,
|
|
313
|
+
enhance,
|
|
314
|
+
allowReferenceDataSelection,
|
|
315
|
+
clearAllSuggestions,
|
|
316
|
+
getSamplePrompts,
|
|
317
|
+
loadingSuggestions,
|
|
318
|
+
editorAIController
|
|
319
|
+
}), [
|
|
320
|
+
enabled,
|
|
321
|
+
suggestions,
|
|
322
|
+
clearSuggestion,
|
|
323
|
+
enhance,
|
|
324
|
+
allowReferenceDataSelection,
|
|
325
|
+
clearAllSuggestions,
|
|
326
|
+
getSamplePrompts,
|
|
327
|
+
loadingSuggestions,
|
|
328
|
+
editorAIController
|
|
329
|
+
]);
|
|
330
|
+
|
|
331
|
+
return (
|
|
332
|
+
<DataEnhancementControllerContext.Provider
|
|
333
|
+
value={dataEnhancementController}>
|
|
334
|
+
{children}
|
|
335
|
+
</DataEnhancementControllerContext.Provider>
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
|