@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
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import type { AdminUser, AdminRole } from "../controllers/client";
|
|
2
|
+
/**
|
|
3
|
+
* Context passed to every backend hook.
|
|
4
|
+
* Provides information about the request that triggered the hook.
|
|
5
|
+
* @group Backend Hooks
|
|
6
|
+
*/
|
|
7
|
+
export interface BackendHookContext {
|
|
8
|
+
/** The currently authenticated user making the request (if any) */
|
|
9
|
+
requestUser?: {
|
|
10
|
+
userId: string;
|
|
11
|
+
roles: string[];
|
|
12
|
+
};
|
|
13
|
+
/** The HTTP method of the request */
|
|
14
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Hooks for intercepting Admin User data at the API boundary.
|
|
18
|
+
*
|
|
19
|
+
* These hooks run on the server after the database operation completes
|
|
20
|
+
* but before the response is sent to the client.
|
|
21
|
+
*
|
|
22
|
+
* @group Backend Hooks
|
|
23
|
+
*/
|
|
24
|
+
export interface UserHooks {
|
|
25
|
+
/**
|
|
26
|
+
* Transform a user record after it's read from the database,
|
|
27
|
+
* before it's returned to the client.
|
|
28
|
+
*
|
|
29
|
+
* Return the modified user, or `null` to filter it out entirely
|
|
30
|
+
* (the user won't appear in listings or individual fetches).
|
|
31
|
+
*/
|
|
32
|
+
afterRead?(user: AdminUser, context: BackendHookContext): AdminUser | null | Promise<AdminUser | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Transform user data before it's written to the database.
|
|
35
|
+
* Runs on POST (create) and PUT (update).
|
|
36
|
+
*
|
|
37
|
+
* Return the (possibly modified) data to proceed with the save.
|
|
38
|
+
* Throw an error to abort the operation.
|
|
39
|
+
*/
|
|
40
|
+
beforeSave?(data: {
|
|
41
|
+
email?: string;
|
|
42
|
+
displayName?: string;
|
|
43
|
+
roles?: string[];
|
|
44
|
+
}, context: BackendHookContext): {
|
|
45
|
+
email?: string;
|
|
46
|
+
displayName?: string;
|
|
47
|
+
roles?: string[];
|
|
48
|
+
} | Promise<{
|
|
49
|
+
email?: string;
|
|
50
|
+
displayName?: string;
|
|
51
|
+
roles?: string[];
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* Called after a user is successfully created or updated.
|
|
55
|
+
* Useful for side-effects like sending notifications.
|
|
56
|
+
*/
|
|
57
|
+
afterSave?(user: AdminUser, context: BackendHookContext): void | Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Called before a user is deleted. Throw to prevent deletion.
|
|
60
|
+
*/
|
|
61
|
+
beforeDelete?(userId: string, context: BackendHookContext): void | Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Called after a user is successfully deleted.
|
|
64
|
+
*/
|
|
65
|
+
afterDelete?(userId: string, context: BackendHookContext): void | Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Hooks for intercepting Admin Role data at the API boundary.
|
|
69
|
+
* @group Backend Hooks
|
|
70
|
+
*/
|
|
71
|
+
export interface RoleHooks {
|
|
72
|
+
/**
|
|
73
|
+
* Transform a role record after it's read from the database,
|
|
74
|
+
* before it's returned to the client.
|
|
75
|
+
*
|
|
76
|
+
* Return the modified role, or `null` to filter it out entirely.
|
|
77
|
+
*/
|
|
78
|
+
afterRead?(role: AdminRole, context: BackendHookContext): AdminRole | null | Promise<AdminRole | null>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Hooks for intercepting collection entity data at the REST API boundary.
|
|
82
|
+
*
|
|
83
|
+
* These run **after** per-collection `EntityCallbacks` (which execute inside
|
|
84
|
+
* the DataDriver) and provide a single cross-cutting interception point for
|
|
85
|
+
* ALL collections flowing through the REST API.
|
|
86
|
+
*
|
|
87
|
+
* Every callback receives the collection `slug` so you can target specific
|
|
88
|
+
* collections or apply logic globally.
|
|
89
|
+
*
|
|
90
|
+
* @group Backend Hooks
|
|
91
|
+
*/
|
|
92
|
+
export interface DataHooks {
|
|
93
|
+
/**
|
|
94
|
+
* Transform an entity after it's read from the database,
|
|
95
|
+
* before it's returned to the client.
|
|
96
|
+
*
|
|
97
|
+
* Runs for both list (GET /:slug) and single (GET /:slug/:id) fetches.
|
|
98
|
+
* Return the modified entity, or `null` to filter it out.
|
|
99
|
+
*
|
|
100
|
+
* @param slug - The collection slug (e.g. "orders", "products")
|
|
101
|
+
* @param entity - The flattened entity object (id + values merged)
|
|
102
|
+
* @param context - Request context (authenticated user, HTTP method)
|
|
103
|
+
*/
|
|
104
|
+
afterRead?(slug: string, entity: Record<string, unknown>, context: BackendHookContext): Record<string, unknown> | null | Promise<Record<string, unknown> | null>;
|
|
105
|
+
/**
|
|
106
|
+
* Transform entity values before they are written to the database.
|
|
107
|
+
* Runs on POST (create) and PUT (update).
|
|
108
|
+
*
|
|
109
|
+
* Return the (possibly modified) values. Throw to abort the save.
|
|
110
|
+
*
|
|
111
|
+
* @param slug - The collection slug
|
|
112
|
+
* @param values - The raw request body values
|
|
113
|
+
* @param entityId - The entity ID (only present on updates)
|
|
114
|
+
* @param context - Request context
|
|
115
|
+
*/
|
|
116
|
+
beforeSave?(slug: string, values: Record<string, unknown>, entityId: string | undefined, context: BackendHookContext): Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
117
|
+
/**
|
|
118
|
+
* Called after an entity is successfully saved (created or updated).
|
|
119
|
+
* Useful for side-effects like syncing to external systems.
|
|
120
|
+
*
|
|
121
|
+
* @param slug - The collection slug
|
|
122
|
+
* @param entity - The saved entity (flattened)
|
|
123
|
+
* @param context - Request context
|
|
124
|
+
*/
|
|
125
|
+
afterSave?(slug: string, entity: Record<string, unknown>, context: BackendHookContext): void | Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Called before an entity is deleted. Throw to prevent deletion.
|
|
128
|
+
*
|
|
129
|
+
* @param slug - The collection slug
|
|
130
|
+
* @param entityId - The entity ID being deleted
|
|
131
|
+
* @param context - Request context
|
|
132
|
+
*/
|
|
133
|
+
beforeDelete?(slug: string, entityId: string, context: BackendHookContext): void | Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Called after an entity is successfully deleted.
|
|
136
|
+
*
|
|
137
|
+
* @param slug - The collection slug
|
|
138
|
+
* @param entityId - The deleted entity ID
|
|
139
|
+
* @param context - Request context
|
|
140
|
+
*/
|
|
141
|
+
afterDelete?(slug: string, entityId: string, context: BackendHookContext): void | Promise<void>;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Backend-level hooks for intercepting data at the API boundary.
|
|
145
|
+
*
|
|
146
|
+
* These hooks run server-side after database operations complete and before
|
|
147
|
+
* API responses are sent.
|
|
148
|
+
*
|
|
149
|
+
* - `users` / `roles` — intercept admin user and role management endpoints
|
|
150
|
+
* - `data` — intercept ALL collection entity data flowing through the REST API
|
|
151
|
+
*
|
|
152
|
+
* `data` hooks complement per-collection `EntityCallbacks`. Entity callbacks
|
|
153
|
+
* run inside the DataDriver (close to the DB); data hooks run at the HTTP
|
|
154
|
+
* boundary (close to the client). Use data hooks for cross-cutting concerns
|
|
155
|
+
* like audit logging, response enrichment, or field masking.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const hooks: BackendHooks = {
|
|
160
|
+
* data: {
|
|
161
|
+
* afterRead(slug, entity, ctx) {
|
|
162
|
+
* // Mask PII for non-admin users across all collections
|
|
163
|
+
* if (!ctx.requestUser?.roles.includes("admin") && entity.email) {
|
|
164
|
+
* return { ...entity, email: "***" };
|
|
165
|
+
* }
|
|
166
|
+
* return entity;
|
|
167
|
+
* }
|
|
168
|
+
* },
|
|
169
|
+
* users: {
|
|
170
|
+
* afterRead(user, ctx) {
|
|
171
|
+
* if (user.email.endsWith("@system.internal")) return null;
|
|
172
|
+
* return user;
|
|
173
|
+
* }
|
|
174
|
+
* }
|
|
175
|
+
* };
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* @group Backend Hooks
|
|
179
|
+
*/
|
|
180
|
+
export interface BackendHooks {
|
|
181
|
+
/** Hooks for intercepting user management data */
|
|
182
|
+
users?: UserHooks;
|
|
183
|
+
/** Hooks for intercepting role management data */
|
|
184
|
+
roles?: RoleHooks;
|
|
185
|
+
/** Hooks for intercepting ALL collection entity data via the REST API */
|
|
186
|
+
data?: DataHooks;
|
|
187
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AuthController } from "../controllers/auth";
|
|
2
|
+
import type { RebaseData } from "../controllers/data";
|
|
3
|
+
import type { User } from "../users";
|
|
4
|
+
import type { EntityCollection } from "./collections";
|
|
5
|
+
import type { AppView } from "../controllers/navigation";
|
|
6
|
+
export type EntityCollectionsBuilder<EC extends EntityCollection = EntityCollection> = (params: {
|
|
7
|
+
user: User | null;
|
|
8
|
+
authController: AuthController;
|
|
9
|
+
data: RebaseData;
|
|
10
|
+
}) => EC[] | Promise<EC[]>;
|
|
11
|
+
export type AppViewsBuilder = (params: {
|
|
12
|
+
user: User | null;
|
|
13
|
+
authController: AuthController;
|
|
14
|
+
data: RebaseData;
|
|
15
|
+
}) => AppView[] | Promise<AppView[]>;
|