@webiny/app-admin 6.6.0-alpha.11 → 6.6.0-alpha.13
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/base/Admin.js +2 -0
- package/base/Admin.js.map +1 -1
- package/base/Base/FieldRenderers/ObjectRenderer/KeyValueTagsRenderer.js.map +1 -1
- package/base/Base/FieldRenderers/ObjectRenderer/MultiValueDynamicZone/MultiValueDynamicZone.js.map +1 -1
- package/base/Base/FieldRenderers/ObjectRenderer/ObjectAccordionMultipleRenderer.js.map +1 -1
- package/base/Base/FieldRenderers/ObjectRenderer/ObjectFieldComponents.js.map +1 -1
- package/base/Base/LexicalPreset.js +1 -1
- package/base/Base/LexicalPreset.js.map +1 -1
- package/base/Base/Menus.js.map +1 -1
- package/base/Base/RoutesConfig.js.map +1 -1
- package/base/Base/Tenant.js.map +1 -1
- package/base/Base/UserMenu/SwitchTenant.d.ts +20 -0
- package/base/Base/UserMenu/SwitchTenant.js +45 -0
- package/base/Base/UserMenu/SwitchTenant.js.map +1 -0
- package/base/Base/UserMenu.js +4 -0
- package/base/Base/UserMenu.js.map +1 -1
- package/base/Base.js.map +1 -1
- package/base/createRootContainer.js +2 -0
- package/base/createRootContainer.js.map +1 -1
- package/base/resolveApiUrl.js +3 -2
- package/base/resolveApiUrl.js.map +1 -1
- package/base/ui/AssumedPermissionsSelector.js.map +1 -1
- package/base/ui/Brand.js.map +1 -1
- package/base/ui/Dashboard.js.map +1 -1
- package/base/ui/FileManager.js.map +1 -1
- package/base/ui/LoginScreen.js.map +1 -1
- package/base/ui/Logo.js.map +1 -1
- package/base/ui/Navigation.js.map +1 -1
- package/base/ui/NotFound.js.map +1 -1
- package/base/ui/Tags.js.map +1 -1
- package/base/ui/TenantSelector.js.map +1 -1
- package/base/ui/UserMenu/UserMenu.js.map +1 -1
- package/base/ui/UserMenu/UserMenuHandle.js.map +1 -1
- package/base/ui/UserMenu.js.map +1 -1
- package/components/Buttons/useButtons.js.map +1 -1
- package/components/Dialogs/DialogParamsContext.js.map +1 -1
- package/components/Dialogs/DialogsContext.js.map +1 -1
- package/components/Drawers/DrawerParamsContext.js.map +1 -1
- package/components/Drawers/DrawersContext.js.map +1 -1
- package/components/Filters/FiltersToggle.js.map +1 -1
- package/components/IconPicker/IconPickerPresenterProvider.js.map +1 -1
- package/components/IconPicker/IconPickerTab.js.map +1 -1
- package/components/IconPicker/IconRenderer.js.map +1 -1
- package/components/IconPicker/config/IconType.js.map +1 -1
- package/components/IconPicker/config/index.js.map +1 -1
- package/components/IconPicker/plugins/customPlugin.js.map +1 -1
- package/components/IconPicker/plugins/emojisPlugin.js.map +1 -1
- package/components/IconPicker/plugins/iconsPlugin.js.map +1 -1
- package/components/IconPicker/types.js.map +1 -1
- package/components/LexicalEditor/DefaultLexicalEditorConfig.js +1 -1
- package/components/LexicalEditor/DefaultLexicalEditorConfig.js.map +1 -1
- package/components/LexicalEditor/LexicalEditor.d.ts +3 -1
- package/components/LexicalEditor/LexicalEditor.js +3 -2
- package/components/LexicalEditor/LexicalEditor.js.map +1 -1
- package/components/LexicalEditor/LexicalLinkForm.js.map +1 -1
- package/components/ListView/ListViewBottomBar.js.map +1 -1
- package/components/ListView/ListViewHeader.js.map +1 -1
- package/components/OptionsMenu/useOptionsMenuItem.js.map +1 -1
- package/components/SimpleForm/SimpleForm.js +2 -2
- package/components/SimpleForm/SimpleForm.js.map +1 -1
- package/components/Table/useTableRow.js.map +1 -1
- package/config/AdminConfig/LexicalTheme/Typography.js +4 -4
- package/config/AdminConfig/LexicalTheme/Typography.js.map +1 -1
- package/config/AdminConfig/Menu.js.map +1 -1
- package/config/AdminConfig/Theme.js +1 -1
- package/config/AdminConfig/Theme.js.map +1 -1
- package/config/AdminConfig.js +2 -2
- package/config/AdminConfig.js.map +1 -1
- package/config/createAdminConfig.js.map +1 -1
- package/domain/Identity.d.ts +8 -0
- package/domain/Identity.js +6 -0
- package/domain/Identity.js.map +1 -1
- package/exports/admin/security.d.ts +4 -1
- package/exports/admin/security.js +4 -1
- package/exports/admin.d.ts +2 -0
- package/exports/admin.js +2 -0
- package/features/accessManagement/constants.js.map +1 -1
- package/features/accessManagement/roles/roleEvents/ApplyRoleChangeToCache.d.ts +17 -0
- package/features/accessManagement/roles/roleEvents/ApplyRoleChangeToCache.js +26 -0
- package/features/accessManagement/roles/roleEvents/ApplyRoleChangeToCache.js.map +1 -0
- package/features/accessManagement/roles/roleEvents/abstractions.d.ts +0 -25
- package/features/accessManagement/roles/roleEvents/abstractions.js +1 -4
- package/features/accessManagement/roles/roleEvents/abstractions.js.map +1 -1
- package/features/accessManagement/roles/roleEvents/feature.js +2 -8
- package/features/accessManagement/roles/roleEvents/feature.js.map +1 -1
- package/features/accessManagement/teams/teamEvents/ApplyTeamChangeToCache.d.ts +17 -0
- package/features/accessManagement/teams/teamEvents/ApplyTeamChangeToCache.js +26 -0
- package/features/accessManagement/teams/teamEvents/ApplyTeamChangeToCache.js.map +1 -0
- package/features/accessManagement/teams/teamEvents/abstractions.d.ts +0 -25
- package/features/accessManagement/teams/teamEvents/abstractions.js +1 -4
- package/features/accessManagement/teams/teamEvents/abstractions.js.map +1 -1
- package/features/accessManagement/teams/teamEvents/feature.js +2 -8
- package/features/accessManagement/teams/teamEvents/feature.js.map +1 -1
- package/features/adminAssistant/AdminAssistantGateway.js +1 -0
- package/features/adminAssistant/AdminAssistantGateway.js.map +1 -1
- package/features/adminAssistant/AdminAssistantPresenter.d.ts +8 -1
- package/features/adminAssistant/AdminAssistantPresenter.js +17 -9
- package/features/adminAssistant/AdminAssistantPresenter.js.map +1 -1
- package/features/adminAssistant/abstractions.d.ts +3 -0
- package/features/adminAssistant/abstractions.js.map +1 -1
- package/features/adminUsers/capabilities/abstractions.d.ts +18 -0
- package/features/adminUsers/capabilities/abstractions.js +5 -0
- package/features/adminUsers/capabilities/abstractions.js.map +1 -0
- package/features/adminUsers/capabilities/feature.d.ts +4 -0
- package/features/adminUsers/capabilities/feature.js +19 -0
- package/features/adminUsers/capabilities/feature.js.map +1 -0
- package/features/adminUsers/capabilities/index.d.ts +3 -0
- package/features/adminUsers/capabilities/index.js +2 -0
- package/features/adminUsers/users/checkEmail/CheckEmailGateway.d.ts +11 -0
- package/features/adminUsers/users/checkEmail/CheckEmailGateway.js +44 -0
- package/features/adminUsers/users/checkEmail/CheckEmailGateway.js.map +1 -0
- package/features/adminUsers/users/checkEmail/CheckEmailUseCase.d.ts +10 -0
- package/features/adminUsers/users/checkEmail/CheckEmailUseCase.js +18 -0
- package/features/adminUsers/users/checkEmail/CheckEmailUseCase.js.map +1 -0
- package/features/adminUsers/users/checkEmail/abstractions/CheckEmailGateway.d.ts +14 -0
- package/features/adminUsers/users/checkEmail/abstractions/CheckEmailGateway.js +5 -0
- package/features/adminUsers/users/checkEmail/abstractions/CheckEmailGateway.js.map +1 -0
- package/features/adminUsers/users/checkEmail/abstractions/CheckEmailUseCase.d.ts +9 -0
- package/features/adminUsers/users/checkEmail/abstractions/CheckEmailUseCase.js +5 -0
- package/features/adminUsers/users/checkEmail/abstractions/CheckEmailUseCase.js.map +1 -0
- package/features/adminUsers/users/checkEmail/abstractions/index.d.ts +2 -0
- package/features/adminUsers/users/checkEmail/abstractions/index.js +2 -0
- package/features/adminUsers/users/checkEmail/feature.d.ts +3 -0
- package/features/adminUsers/users/checkEmail/feature.js +19 -0
- package/features/adminUsers/users/checkEmail/feature.js.map +1 -0
- package/features/adminUsers/users/checkEmail/index.d.ts +2 -0
- package/features/adminUsers/users/checkEmail/index.js +2 -0
- package/features/adminUsers/users/createUser/CreateUserGateway.js +2 -1
- package/features/adminUsers/users/createUser/CreateUserGateway.js.map +1 -1
- package/features/adminUsers/users/createUser/CreateUserUseCase.test.d.ts +1 -0
- package/features/adminUsers/users/createUser/CreateUserUseCase.test.js +65 -0
- package/features/adminUsers/users/createUser/CreateUserUseCase.test.js.map +1 -0
- package/features/adminUsers/users/linkUser/LinkUserGateway.d.ts +11 -0
- package/features/adminUsers/users/linkUser/LinkUserGateway.js +50 -0
- package/features/adminUsers/users/linkUser/LinkUserGateway.js.map +1 -0
- package/features/adminUsers/users/linkUser/LinkUserUseCase.d.ts +10 -0
- package/features/adminUsers/users/linkUser/LinkUserUseCase.js +18 -0
- package/features/adminUsers/users/linkUser/LinkUserUseCase.js.map +1 -0
- package/features/adminUsers/users/linkUser/abstractions/LinkUserGateway.d.ts +18 -0
- package/features/adminUsers/users/linkUser/abstractions/LinkUserGateway.js +5 -0
- package/features/adminUsers/users/linkUser/abstractions/LinkUserGateway.js.map +1 -0
- package/features/adminUsers/users/linkUser/abstractions/LinkUserUseCase.d.ts +15 -0
- package/features/adminUsers/users/linkUser/abstractions/LinkUserUseCase.js +5 -0
- package/features/adminUsers/users/linkUser/abstractions/LinkUserUseCase.js.map +1 -0
- package/features/adminUsers/users/linkUser/abstractions/index.d.ts +2 -0
- package/features/adminUsers/users/linkUser/abstractions/index.js +2 -0
- package/features/adminUsers/users/linkUser/feature.d.ts +3 -0
- package/features/adminUsers/users/linkUser/feature.js +19 -0
- package/features/adminUsers/users/linkUser/feature.js.map +1 -0
- package/features/adminUsers/users/linkUser/index.d.ts +2 -0
- package/features/adminUsers/users/linkUser/index.js +2 -0
- package/features/adminUsers/users/resetUserMfa/ResetUserMfaGateway.d.ts +11 -0
- package/features/adminUsers/users/resetUserMfa/ResetUserMfaGateway.js +42 -0
- package/features/adminUsers/users/resetUserMfa/ResetUserMfaGateway.js.map +1 -0
- package/features/adminUsers/users/resetUserMfa/ResetUserMfaUseCase.d.ts +10 -0
- package/features/adminUsers/users/resetUserMfa/ResetUserMfaUseCase.js +18 -0
- package/features/adminUsers/users/resetUserMfa/ResetUserMfaUseCase.js.map +1 -0
- package/features/adminUsers/users/resetUserMfa/abstractions/ResetUserMfaGateway.d.ts +11 -0
- package/features/adminUsers/users/resetUserMfa/abstractions/ResetUserMfaGateway.js +5 -0
- package/features/adminUsers/users/resetUserMfa/abstractions/ResetUserMfaGateway.js.map +1 -0
- package/features/adminUsers/users/resetUserMfa/abstractions/ResetUserMfaUseCase.d.ts +12 -0
- package/features/adminUsers/users/resetUserMfa/abstractions/ResetUserMfaUseCase.js +5 -0
- package/features/adminUsers/users/resetUserMfa/abstractions/ResetUserMfaUseCase.js.map +1 -0
- package/features/adminUsers/users/resetUserMfa/abstractions/index.d.ts +2 -0
- package/features/adminUsers/users/resetUserMfa/abstractions/index.js +2 -0
- package/features/adminUsers/users/resetUserMfa/feature.d.ts +3 -0
- package/features/adminUsers/users/resetUserMfa/feature.js +19 -0
- package/features/adminUsers/users/resetUserMfa/feature.js.map +1 -0
- package/features/adminUsers/users/resetUserMfa/index.d.ts +2 -0
- package/features/adminUsers/users/resetUserMfa/index.js +2 -0
- package/features/adminUsers/users/shared/AdminUsersError.d.ts +13 -0
- package/features/adminUsers/users/shared/AdminUsersError.js +11 -0
- package/features/adminUsers/users/shared/AdminUsersError.js.map +1 -0
- package/features/adminUsers/users/userEvents/MarkUsersChanged.d.ts +16 -0
- package/features/adminUsers/users/userEvents/MarkUsersChanged.js +23 -0
- package/features/adminUsers/users/userEvents/MarkUsersChanged.js.map +1 -0
- package/features/adminUsers/users/userEvents/UsersRevision.d.ts +13 -0
- package/features/adminUsers/users/userEvents/UsersRevision.js +25 -0
- package/features/adminUsers/users/userEvents/UsersRevision.js.map +1 -0
- package/features/adminUsers/users/userEvents/abstractions.d.ts +17 -0
- package/features/adminUsers/users/userEvents/abstractions.js +5 -0
- package/features/adminUsers/users/userEvents/abstractions.js.map +1 -0
- package/features/adminUsers/users/userEvents/feature.d.ts +4 -0
- package/features/adminUsers/users/userEvents/feature.js +19 -0
- package/features/adminUsers/users/userEvents/feature.js.map +1 -0
- package/features/adminUsers/users/userEvents/index.d.ts +1 -0
- package/features/adminUsers/users/userEvents/index.js +1 -0
- package/features/assistantPageContext/AssistantPageContext.d.ts +12 -0
- package/features/assistantPageContext/AssistantPageContext.js +32 -0
- package/features/assistantPageContext/AssistantPageContext.js.map +1 -0
- package/features/assistantPageContext/abstractions.d.ts +33 -0
- package/features/assistantPageContext/abstractions.js +5 -0
- package/features/assistantPageContext/abstractions.js.map +1 -0
- package/features/assistantPageContext/feature.d.ts +3 -0
- package/features/assistantPageContext/feature.js +17 -0
- package/features/assistantPageContext/feature.js.map +1 -0
- package/features/assistantPageContext/index.d.ts +2 -0
- package/features/assistantPageContext/index.js +2 -0
- package/features/assumePermissions/AssumePermissionsUseCase.js +2 -2
- package/features/assumePermissions/AssumePermissionsUseCase.js.map +1 -1
- package/features/assumePermissions/LogInUseCaseDecorator.d.ts +1 -1
- package/features/assumePermissions/LogInUseCaseDecorator.js +8 -6
- package/features/assumePermissions/LogInUseCaseDecorator.js.map +1 -1
- package/features/formModel/FormView.js.map +1 -1
- package/features/formModel/createFieldRenderer.js.map +1 -1
- package/features/formModel/demo/FormModelDemo.js.map +1 -1
- package/features/formModel/fieldTypes/dateLimits.js.map +1 -1
- package/features/security/LogIn/LogInError.d.ts +15 -0
- package/features/security/LogIn/LogInError.js +25 -0
- package/features/security/LogIn/LogInError.js.map +1 -0
- package/features/security/LogIn/LogInGateway.d.ts +2 -2
- package/features/security/LogIn/LogInGateway.js +22 -5
- package/features/security/LogIn/LogInGateway.js.map +1 -1
- package/features/security/LogIn/LogInRepository.d.ts +1 -2
- package/features/security/LogIn/LogInRepository.js +6 -2
- package/features/security/LogIn/LogInRepository.js.map +1 -1
- package/features/security/LogIn/LogInUseCase.d.ts +7 -2
- package/features/security/LogIn/LogInUseCase.js +53 -3
- package/features/security/LogIn/LogInUseCase.js.map +1 -1
- package/features/security/LogIn/LogInUseCase.test.d.ts +1 -0
- package/features/security/LogIn/LogInUseCase.test.js +321 -0
- package/features/security/LogIn/LogInUseCase.test.js.map +1 -0
- package/features/security/LogIn/abstractions.d.ts +48 -3
- package/features/security/LogIn/abstractions.js.map +1 -1
- package/features/security/LogIn/createLoginMutation.js +40 -27
- package/features/security/LogIn/createLoginMutation.js.map +1 -1
- package/features/security/LogIn/feature.js +2 -0
- package/features/security/LogIn/feature.js.map +1 -1
- package/features/security/LogIn/index.d.ts +1 -0
- package/features/security/LogIn/index.js +1 -0
- package/features/security/LoginTenantResolver/LoginTenantResolver.d.ts +14 -0
- package/features/security/LoginTenantResolver/LoginTenantResolver.js +52 -0
- package/features/security/LoginTenantResolver/LoginTenantResolver.js.map +1 -0
- package/features/security/LoginTenantResolver/abstractions.d.ts +38 -0
- package/features/security/LoginTenantResolver/abstractions.js +5 -0
- package/features/security/LoginTenantResolver/abstractions.js.map +1 -0
- package/features/security/LoginTenantResolver/feature.d.ts +3 -0
- package/features/security/LoginTenantResolver/feature.js +17 -0
- package/features/security/LoginTenantResolver/feature.js.map +1 -0
- package/features/security/LoginTenantResolver/index.d.ts +2 -0
- package/features/security/LoginTenantResolver/index.js +2 -0
- package/features/webinySdk/WebinySdk.d.ts +2 -1
- package/features/webinySdk/WebinySdk.js +14 -2
- package/features/webinySdk/WebinySdk.js.map +1 -1
- package/features/webinySdk/__tests__/WebinySdk.test.d.ts +1 -0
- package/features/webinySdk/__tests__/WebinySdk.test.js +89 -0
- package/features/webinySdk/__tests__/WebinySdk.test.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +2 -1
- package/modules/AccessManagementExtension.js +1 -1
- package/modules/AccessManagementExtension.js.map +1 -1
- package/modules/DebuggerExtension.js +1 -1
- package/modules/DebuggerExtension.js.map +1 -1
- package/package.json +30 -30
- package/permissions/PermissionRenderer.js.map +1 -1
- package/permissions/PermissionValueContext.js.map +1 -1
- package/presentation/accessManagement/SecurityPermissions.js +1 -1
- package/presentation/accessManagement/SecurityPermissions.js.map +1 -1
- package/presentation/accessManagement/apiKeys/ApiKeysDataSource.d.ts +5 -6
- package/presentation/accessManagement/apiKeys/ApiKeysDataSource.js +12 -13
- package/presentation/accessManagement/apiKeys/ApiKeysDataSource.js.map +1 -1
- package/presentation/accessManagement/apiKeys/ApiKeysPresenter.d.ts +5 -0
- package/presentation/accessManagement/apiKeys/ApiKeysPresenter.js +32 -2
- package/presentation/accessManagement/apiKeys/ApiKeysPresenter.js.map +1 -1
- package/presentation/accessManagement/apiKeys/ApiKeysPresenter.test.d.ts +1 -0
- package/presentation/accessManagement/apiKeys/ApiKeysPresenter.test.js +87 -0
- package/presentation/accessManagement/apiKeys/ApiKeysPresenter.test.js.map +1 -0
- package/presentation/accessManagement/apiKeys/abstractions.d.ts +2 -0
- package/presentation/accessManagement/apiKeys/abstractions.js.map +1 -1
- package/presentation/accessManagement/apiKeys/components/ApiKeysView.js +13 -37
- package/presentation/accessManagement/apiKeys/components/ApiKeysView.js.map +1 -1
- package/presentation/accessManagement/roles/RolesDataSource.d.ts +5 -6
- package/presentation/accessManagement/roles/RolesDataSource.js +12 -13
- package/presentation/accessManagement/roles/RolesDataSource.js.map +1 -1
- package/presentation/accessManagement/roles/RolesPresenter.d.ts +5 -0
- package/presentation/accessManagement/roles/RolesPresenter.js +32 -2
- package/presentation/accessManagement/roles/RolesPresenter.js.map +1 -1
- package/presentation/accessManagement/roles/RolesPresenter.test.d.ts +1 -0
- package/presentation/accessManagement/roles/RolesPresenter.test.js +168 -0
- package/presentation/accessManagement/roles/RolesPresenter.test.js.map +1 -0
- package/presentation/accessManagement/roles/abstractions.d.ts +2 -0
- package/presentation/accessManagement/roles/abstractions.js.map +1 -1
- package/presentation/accessManagement/roles/components/RolesDataList.js +12 -37
- package/presentation/accessManagement/roles/components/RolesDataList.js.map +1 -1
- package/presentation/accessManagement/roles/components/RolesView.js +1 -0
- package/presentation/accessManagement/roles/components/RolesView.js.map +1 -1
- package/presentation/accessManagement/teams/TeamsDataSource.d.ts +5 -6
- package/presentation/accessManagement/teams/TeamsDataSource.js +12 -13
- package/presentation/accessManagement/teams/TeamsDataSource.js.map +1 -1
- package/presentation/accessManagement/teams/TeamsPresenter.d.ts +5 -0
- package/presentation/accessManagement/teams/TeamsPresenter.js +33 -2
- package/presentation/accessManagement/teams/TeamsPresenter.js.map +1 -1
- package/presentation/accessManagement/teams/TeamsPresenter.test.d.ts +1 -0
- package/presentation/accessManagement/teams/TeamsPresenter.test.js +97 -0
- package/presentation/accessManagement/teams/TeamsPresenter.test.js.map +1 -0
- package/presentation/accessManagement/teams/abstractions.d.ts +2 -0
- package/presentation/accessManagement/teams/abstractions.js.map +1 -1
- package/presentation/accessManagement/teams/components/TeamsDataList.js +12 -37
- package/presentation/accessManagement/teams/components/TeamsDataList.js.map +1 -1
- package/presentation/accessManagement/teams/components/TeamsView.js +1 -0
- package/presentation/accessManagement/teams/components/TeamsView.js.map +1 -1
- package/presentation/adminUsers/AdminUsers.d.ts +8 -1
- package/presentation/adminUsers/AdminUsers.js +25 -2
- package/presentation/adminUsers/AdminUsers.js.map +1 -1
- package/presentation/adminUsers/SecurityPermission.js +1 -1
- package/presentation/adminUsers/SecurityPermission.js.map +1 -1
- package/presentation/adminUsers/resetMfa/ResetMfaPresenter.d.ts +27 -0
- package/presentation/adminUsers/resetMfa/ResetMfaPresenter.js +67 -0
- package/presentation/adminUsers/resetMfa/ResetMfaPresenter.js.map +1 -0
- package/presentation/adminUsers/resetMfa/ResetMfaPresenter.test.d.ts +1 -0
- package/presentation/adminUsers/resetMfa/ResetMfaPresenter.test.js +150 -0
- package/presentation/adminUsers/resetMfa/ResetMfaPresenter.test.js.map +1 -0
- package/presentation/adminUsers/resetMfa/abstractions.d.ts +38 -0
- package/presentation/adminUsers/resetMfa/abstractions.js +5 -0
- package/presentation/adminUsers/resetMfa/abstractions.js.map +1 -0
- package/presentation/adminUsers/resetMfa/feature.d.ts +6 -0
- package/presentation/adminUsers/resetMfa/feature.js +17 -0
- package/presentation/adminUsers/resetMfa/feature.js.map +1 -0
- package/presentation/adminUsers/userForm/UserFormPresenter.d.ts +32 -0
- package/presentation/adminUsers/userForm/UserFormPresenter.js +124 -0
- package/presentation/adminUsers/userForm/UserFormPresenter.js.map +1 -0
- package/presentation/adminUsers/userForm/UserFormPresenter.test.d.ts +1 -0
- package/presentation/adminUsers/userForm/UserFormPresenter.test.js +264 -0
- package/presentation/adminUsers/userForm/UserFormPresenter.test.js.map +1 -0
- package/presentation/adminUsers/userForm/abstractions.d.ts +52 -0
- package/presentation/adminUsers/userForm/abstractions.js +5 -0
- package/presentation/adminUsers/userForm/abstractions.js.map +1 -0
- package/presentation/adminUsers/userForm/feature.d.ts +7 -0
- package/presentation/adminUsers/userForm/feature.js +17 -0
- package/presentation/adminUsers/userForm/feature.js.map +1 -0
- package/presentation/adminUsers/userMenu/AccountDetails.js +1 -1
- package/presentation/adminUsers/userMenu/AccountDetails.js.map +1 -1
- package/presentation/adminUsers/views/Users/UsersDataList.js +22 -1
- package/presentation/adminUsers/views/Users/UsersDataList.js.map +1 -1
- package/presentation/adminUsers/views/Users/UsersForm.d.ts +3 -1
- package/presentation/adminUsers/views/Users/UsersForm.js +51 -20
- package/presentation/adminUsers/views/Users/UsersForm.js.map +1 -1
- package/presentation/adminUsers/views/Users/components/LinkAccountAlert.d.ts +10 -0
- package/presentation/adminUsers/views/Users/components/LinkAccountAlert.js +17 -0
- package/presentation/adminUsers/views/Users/components/LinkAccountAlert.js.map +1 -0
- package/presentation/adminUsers/views/Users/components/ResetMfa.d.ts +12 -0
- package/presentation/adminUsers/views/Users/components/ResetMfa.js +63 -0
- package/presentation/adminUsers/views/Users/components/ResetMfa.js.map +1 -0
- package/presentation/adminUsers/views/Users/hooks/useUserForm.d.ts +1 -0
- package/presentation/adminUsers/views/Users/hooks/useUserForm.js +70 -27
- package/presentation/adminUsers/views/Users/hooks/useUserForm.js.map +1 -1
- package/presentation/adminUsers/views/Users/hooks/useUserForm.test.d.ts +1 -0
- package/presentation/adminUsers/views/Users/hooks/useUserForm.test.js +158 -0
- package/presentation/adminUsers/views/Users/hooks/useUserForm.test.js.map +1 -0
- package/presentation/assumePermissions/components/AssumedPermissionsSelector.js.map +1 -1
- package/presentation/debugger/components/DebuggerIndicator.js.map +1 -1
- package/presentation/installation/components/SystemInstaller/steps/AdminUserStep.js.map +1 -1
- package/presentation/installation/components/SystemInstaller/steps/BasicInfoStep.js.map +1 -1
- package/presentation/listPresenter/ListPresenter.d.ts +12 -1
- package/presentation/listPresenter/ListPresenter.js +61 -5
- package/presentation/listPresenter/ListPresenter.js.map +1 -1
- package/presentation/listPresenter/ListPresenter.test.js +110 -0
- package/presentation/listPresenter/ListPresenter.test.js.map +1 -1
- package/presentation/listPresenter/LocalDataSource.d.ts +34 -0
- package/presentation/listPresenter/LocalDataSource.js +75 -0
- package/presentation/listPresenter/LocalDataSource.js.map +1 -0
- package/presentation/listPresenter/LocalDataSource.test.d.ts +1 -0
- package/presentation/listPresenter/LocalDataSource.test.js +124 -0
- package/presentation/listPresenter/LocalDataSource.test.js.map +1 -0
- package/presentation/listPresenter/QueryMatcher.js +1 -12
- package/presentation/listPresenter/QueryMatcher.js.map +1 -1
- package/presentation/listPresenter/abstractions.d.ts +21 -0
- package/presentation/listPresenter/abstractions.js.map +1 -1
- package/presentation/listPresenter/compareValues.d.ts +7 -0
- package/presentation/listPresenter/compareValues.js +15 -0
- package/presentation/listPresenter/compareValues.js.map +1 -0
- package/presentation/listPresenter/index.d.ts +2 -0
- package/presentation/listPresenter/index.js +2 -0
- package/presentation/listPresenter/sortOption.d.ts +7 -0
- package/presentation/listPresenter/sortOption.js +16 -0
- package/presentation/listPresenter/sortOption.js.map +1 -0
- package/presentation/listPresenter/sortOption.test.d.ts +1 -0
- package/presentation/listPresenter/sortOption.test.js +26 -0
- package/presentation/listPresenter/sortOption.test.js.map +1 -0
- package/presentation/security/components/LoginNoTenantAccess.d.ts +27 -0
- package/presentation/security/components/LoginNoTenantAccess.js +22 -0
- package/presentation/security/components/LoginNoTenantAccess.js.map +1 -0
- package/presentation/security/components/LoginTenantPicker.d.ts +30 -0
- package/presentation/security/components/LoginTenantPicker.js +32 -0
- package/presentation/security/components/LoginTenantPicker.js.map +1 -0
- package/presentation/security/hooks/useAuthentication.d.ts +2 -2
- package/presentation/security/hooks/useAuthentication.js.map +1 -1
- package/presentation/security/hooks/useSecurity.js +2 -2
- package/presentation/security/hooks/useSecurity.js.map +1 -1
- package/presentation/sortable/SortablePresenter.js +3 -2
- package/presentation/sortable/SortablePresenter.js.map +1 -1
- package/presentation/trashBin/TrashBinPresenter.js +9 -0
- package/presentation/trashBin/TrashBinPresenter.js.map +1 -1
- package/presentation/trashBin/TrashBinPresenter.test.js +75 -0
- package/presentation/trashBin/TrashBinPresenter.test.js.map +1 -1
- package/presentation/trashBin/abstractions.d.ts +9 -0
- package/presentation/trashBin/abstractions.js.map +1 -1
- package/presentation/trashBin/components/BulkActions/DeleteItems.test.js +1 -1
- package/presentation/trashBin/components/BulkActions/DeleteItems.test.js.map +1 -1
- package/presentation/trashBin/components/TrashBinConfigs.js +1 -1
- package/presentation/trashBin/components/TrashBinConfigs.js.map +1 -1
- package/presentation/trashBin/components/TrashBinOverlay.js.map +1 -1
- package/presentation/trashBin/configs/Browser/BulkAction.js +1 -1
- package/presentation/trashBin/configs/Browser/BulkAction.js.map +1 -1
- package/presentation/trashBin/hooks/useTrashBinItem.js +1 -1
- package/presentation/trashBin/hooks/useTrashBinItem.js.map +1 -1
- package/presentation/trashBin/hooks/useTrashBinPresenter.js +1 -1
- package/presentation/trashBin/hooks/useTrashBinPresenter.js.map +1 -1
- package/features/accessManagement/roles/roleEvents/AddCreatedRoleToCache.d.ts +0 -12
- package/features/accessManagement/roles/roleEvents/AddCreatedRoleToCache.js +0 -18
- package/features/accessManagement/roles/roleEvents/AddCreatedRoleToCache.js.map +0 -1
- package/features/accessManagement/roles/roleEvents/RefreshUpdatedRoleInCache.d.ts +0 -12
- package/features/accessManagement/roles/roleEvents/RefreshUpdatedRoleInCache.js +0 -18
- package/features/accessManagement/roles/roleEvents/RefreshUpdatedRoleInCache.js.map +0 -1
- package/features/accessManagement/roles/roleEvents/RemoveDeletedRoleFromCache.d.ts +0 -12
- package/features/accessManagement/roles/roleEvents/RemoveDeletedRoleFromCache.js +0 -20
- package/features/accessManagement/roles/roleEvents/RemoveDeletedRoleFromCache.js.map +0 -1
- package/features/accessManagement/roles/roleEvents/RoleCreatedEvent.d.ts +0 -14
- package/features/accessManagement/roles/roleEvents/RoleCreatedEvent.js +0 -13
- package/features/accessManagement/roles/roleEvents/RoleCreatedEvent.js.map +0 -1
- package/features/accessManagement/roles/roleEvents/RoleDeletedEvent.d.ts +0 -9
- package/features/accessManagement/roles/roleEvents/RoleDeletedEvent.js +0 -13
- package/features/accessManagement/roles/roleEvents/RoleDeletedEvent.js.map +0 -1
- package/features/accessManagement/roles/roleEvents/RoleUpdatedEvent.d.ts +0 -9
- package/features/accessManagement/roles/roleEvents/RoleUpdatedEvent.js +0 -13
- package/features/accessManagement/roles/roleEvents/RoleUpdatedEvent.js.map +0 -1
- package/features/accessManagement/roles/roleEvents/RoleWebsocketMessages.d.ts +0 -12
- package/features/accessManagement/roles/roleEvents/RoleWebsocketMessages.js +0 -49
- package/features/accessManagement/roles/roleEvents/RoleWebsocketMessages.js.map +0 -1
- package/features/accessManagement/teams/teamEvents/AddCreatedTeamToCache.d.ts +0 -12
- package/features/accessManagement/teams/teamEvents/AddCreatedTeamToCache.js +0 -18
- package/features/accessManagement/teams/teamEvents/AddCreatedTeamToCache.js.map +0 -1
- package/features/accessManagement/teams/teamEvents/RefreshUpdatedTeamInCache.d.ts +0 -12
- package/features/accessManagement/teams/teamEvents/RefreshUpdatedTeamInCache.js +0 -18
- package/features/accessManagement/teams/teamEvents/RefreshUpdatedTeamInCache.js.map +0 -1
- package/features/accessManagement/teams/teamEvents/RemoveDeletedTeamFromCache.d.ts +0 -12
- package/features/accessManagement/teams/teamEvents/RemoveDeletedTeamFromCache.js +0 -20
- package/features/accessManagement/teams/teamEvents/RemoveDeletedTeamFromCache.js.map +0 -1
- package/features/accessManagement/teams/teamEvents/TeamCreatedEvent.d.ts +0 -14
- package/features/accessManagement/teams/teamEvents/TeamCreatedEvent.js +0 -13
- package/features/accessManagement/teams/teamEvents/TeamCreatedEvent.js.map +0 -1
- package/features/accessManagement/teams/teamEvents/TeamDeletedEvent.d.ts +0 -9
- package/features/accessManagement/teams/teamEvents/TeamDeletedEvent.js +0 -13
- package/features/accessManagement/teams/teamEvents/TeamDeletedEvent.js.map +0 -1
- package/features/accessManagement/teams/teamEvents/TeamUpdatedEvent.d.ts +0 -9
- package/features/accessManagement/teams/teamEvents/TeamUpdatedEvent.js +0 -13
- package/features/accessManagement/teams/teamEvents/TeamUpdatedEvent.js.map +0 -1
- package/features/accessManagement/teams/teamEvents/TeamWebsocketMessages.d.ts +0 -12
- package/features/accessManagement/teams/teamEvents/TeamWebsocketMessages.js +0 -48
- package/features/accessManagement/teams/teamEvents/TeamWebsocketMessages.js.map +0 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RecordChangedEventHandler } from "@webiny/app/features/recordChanges/index.js";
|
|
2
|
+
import { RolesListCache } from "../listRoles/abstractions.js";
|
|
3
|
+
import { RefreshRoleInCacheRepository } from "./abstractions.js";
|
|
4
|
+
const ROLE_RECORD_TYPE = "security.role";
|
|
5
|
+
class ApplyRoleChangeToCacheImpl {
|
|
6
|
+
constructor(repository, cache){
|
|
7
|
+
this.repository = repository;
|
|
8
|
+
this.cache = cache;
|
|
9
|
+
}
|
|
10
|
+
async handle(event) {
|
|
11
|
+
const { type, id, change } = event.payload;
|
|
12
|
+
if (type !== ROLE_RECORD_TYPE) return;
|
|
13
|
+
if ("deleted" === change) return void this.cache.removeItems((role)=>role.id === id);
|
|
14
|
+
await this.repository.execute(id);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const ApplyRoleChangeToCache = RecordChangedEventHandler.createImplementation({
|
|
18
|
+
implementation: ApplyRoleChangeToCacheImpl,
|
|
19
|
+
dependencies: [
|
|
20
|
+
RefreshRoleInCacheRepository,
|
|
21
|
+
RolesListCache
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
export { ApplyRoleChangeToCache };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=ApplyRoleChangeToCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/accessManagement/roles/roleEvents/ApplyRoleChangeToCache.js","sources":["../../../../../src/features/accessManagement/roles/roleEvents/ApplyRoleChangeToCache.ts"],"sourcesContent":["import { RecordChangedEventHandler } from \"@webiny/app/features/recordChanges/index.js\";\nimport { RolesListCache } from \"../listRoles/abstractions.js\";\nimport { RefreshRoleInCacheRepository } from \"./abstractions.js\";\n\n// Sent by the api for roles; see `ROLE_RECORD_TYPE` in @webiny/api-core.\nconst ROLE_RECORD_TYPE = \"security.role\";\n\n/**\n * Keeps the roles list cache, which the Roles view renders from, in step with the server. A created\n * or updated role is read back into it; a deleted role cannot be read back, so it is taken out.\n */\nclass ApplyRoleChangeToCacheImpl implements RecordChangedEventHandler.Interface {\n constructor(\n private repository: RefreshRoleInCacheRepository.Interface,\n private cache: RolesListCache.Interface\n ) {}\n\n async handle(event: RecordChangedEventHandler.Event): Promise<void> {\n const { type, id, change } = event.payload;\n if (type !== ROLE_RECORD_TYPE) {\n return;\n }\n\n if (change === \"deleted\") {\n this.cache.removeItems(role => role.id === id);\n return;\n }\n\n await this.repository.execute(id);\n }\n}\n\nexport const ApplyRoleChangeToCache = RecordChangedEventHandler.createImplementation({\n implementation: ApplyRoleChangeToCacheImpl,\n dependencies: [RefreshRoleInCacheRepository, RolesListCache]\n});\n"],"names":["ROLE_RECORD_TYPE","ApplyRoleChangeToCacheImpl","repository","cache","event","type","id","change","role","ApplyRoleChangeToCache","RecordChangedEventHandler","RefreshRoleInCacheRepository","RolesListCache"],"mappings":";;;AAKA,MAAMA,mBAAmB;AAMzB,MAAMC;IACF,YACYC,UAAkD,EAClDC,KAA+B,CACzC;aAFUD,UAAU,GAAVA;aACAC,KAAK,GAALA;IACT;IAEH,MAAM,OAAOC,KAAsC,EAAiB;QAChE,MAAM,EAAEC,IAAI,EAAEC,EAAE,EAAEC,MAAM,EAAE,GAAGH,MAAM,OAAO;QAC1C,IAAIC,SAASL,kBACT;QAGJ,IAAIO,AAAW,cAAXA,QAAsB,YACtB,IAAI,CAAC,KAAK,CAAC,WAAW,CAACC,CAAAA,OAAQA,KAAK,EAAE,KAAKF;QAI/C,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACA;IAClC;AACJ;AAEO,MAAMG,yBAAyBC,0BAA0B,oBAAoB,CAAC;IACjF,gBAAgBT;IAChB,cAAc;QAACU;QAA8BC;KAAe;AAChE"}
|
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
import type { IEventHandler } from "@webiny/app/features/eventPublisher/index.js";
|
|
2
|
-
import type { RoleCreatedEvent } from "./RoleCreatedEvent.js";
|
|
3
|
-
import type { RoleUpdatedEvent } from "./RoleUpdatedEvent.js";
|
|
4
|
-
import type { RoleDeletedEvent } from "./RoleDeletedEvent.js";
|
|
5
|
-
/**
|
|
6
|
-
* Reacts to a role created somewhere the admin did not see, such as by the assistant. Roles the admin
|
|
7
|
-
* creates itself are already in its list.
|
|
8
|
-
*/
|
|
9
|
-
export declare const RoleCreatedEventHandler: import("@webiny/di").Abstraction<IEventHandler<RoleCreatedEvent>>;
|
|
10
|
-
export declare namespace RoleCreatedEventHandler {
|
|
11
|
-
type Interface = IEventHandler<RoleCreatedEvent>;
|
|
12
|
-
type Event = RoleCreatedEvent;
|
|
13
|
-
}
|
|
14
|
-
/** Reacts to a role changed somewhere the admin did not see, such as by the assistant. */
|
|
15
|
-
export declare const RoleUpdatedEventHandler: import("@webiny/di").Abstraction<IEventHandler<RoleUpdatedEvent>>;
|
|
16
|
-
export declare namespace RoleUpdatedEventHandler {
|
|
17
|
-
type Interface = IEventHandler<RoleUpdatedEvent>;
|
|
18
|
-
type Event = RoleUpdatedEvent;
|
|
19
|
-
}
|
|
20
|
-
/** Reacts to a role deleted somewhere the admin did not see, such as by the assistant. */
|
|
21
|
-
export declare const RoleDeletedEventHandler: import("@webiny/di").Abstraction<IEventHandler<RoleDeletedEvent>>;
|
|
22
|
-
export declare namespace RoleDeletedEventHandler {
|
|
23
|
-
type Interface = IEventHandler<RoleDeletedEvent>;
|
|
24
|
-
type Event = RoleDeletedEvent;
|
|
25
|
-
}
|
|
26
1
|
export interface IRefreshRoleInCacheRepository {
|
|
27
2
|
execute(id: string): Promise<void>;
|
|
28
3
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/admin";
|
|
2
|
-
const RoleCreatedEventHandler = createAbstraction("AccessManagement/RoleCreatedEventHandler");
|
|
3
|
-
const RoleUpdatedEventHandler = createAbstraction("AccessManagement/RoleUpdatedEventHandler");
|
|
4
|
-
const RoleDeletedEventHandler = createAbstraction("AccessManagement/RoleDeletedEventHandler");
|
|
5
2
|
const RefreshRoleInCacheRepository = createAbstraction("AccessManagement/RefreshRoleInCacheRepository");
|
|
6
|
-
export { RefreshRoleInCacheRepository
|
|
3
|
+
export { RefreshRoleInCacheRepository };
|
|
7
4
|
|
|
8
5
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/accessManagement/roles/roleEvents/abstractions.js","sources":["../../../../../src/features/accessManagement/roles/roleEvents/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\
|
|
1
|
+
{"version":3,"file":"features/accessManagement/roles/roleEvents/abstractions.js","sources":["../../../../../src/features/accessManagement/roles/roleEvents/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\n\nexport interface IRefreshRoleInCacheRepository {\n execute(id: string): Promise<void>;\n}\n\n/** Reads a role back by id and puts it into the roles list, replacing the copy the list has. */\nexport const RefreshRoleInCacheRepository = createAbstraction<IRefreshRoleInCacheRepository>(\n \"AccessManagement/RefreshRoleInCacheRepository\"\n);\n\nexport namespace RefreshRoleInCacheRepository {\n export type Interface = IRefreshRoleInCacheRepository;\n}\n"],"names":["RefreshRoleInCacheRepository","createAbstraction"],"mappings":";AAOO,MAAMA,+BAA+BC,kBACxC"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/admin";
|
|
2
2
|
import { RefreshRoleInCacheRepository } from "./RefreshRoleInCacheRepository.js";
|
|
3
|
-
import {
|
|
4
|
-
import { RefreshUpdatedRoleInCache } from "./RefreshUpdatedRoleInCache.js";
|
|
5
|
-
import { RemoveDeletedRoleFromCache } from "./RemoveDeletedRoleFromCache.js";
|
|
6
|
-
import { RoleWebsocketMessages } from "./RoleWebsocketMessages.js";
|
|
3
|
+
import { ApplyRoleChangeToCache } from "./ApplyRoleChangeToCache.js";
|
|
7
4
|
const RoleEventsFeature = createFeature({
|
|
8
5
|
name: "AccessManagement/RoleEvents",
|
|
9
6
|
register (container) {
|
|
10
7
|
container.register(RefreshRoleInCacheRepository).inSingletonScope();
|
|
11
|
-
container.register(
|
|
12
|
-
container.register(RefreshUpdatedRoleInCache);
|
|
13
|
-
container.register(RemoveDeletedRoleFromCache);
|
|
14
|
-
container.register(RoleWebsocketMessages);
|
|
8
|
+
container.register(ApplyRoleChangeToCache);
|
|
15
9
|
}
|
|
16
10
|
});
|
|
17
11
|
export { RoleEventsFeature };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/accessManagement/roles/roleEvents/feature.js","sources":["../../../../../src/features/accessManagement/roles/roleEvents/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { RefreshRoleInCacheRepository } from \"./RefreshRoleInCacheRepository.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/accessManagement/roles/roleEvents/feature.js","sources":["../../../../../src/features/accessManagement/roles/roleEvents/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { RefreshRoleInCacheRepository } from \"./RefreshRoleInCacheRepository.js\";\nimport { ApplyRoleChangeToCache } from \"./ApplyRoleChangeToCache.js\";\n\n/**\n * Keeps the roles list current when roles are created, updated or deleted on the server. Needs\n * `ListRolesFeature` and `GetRoleFeature` in the same container, for the cache and the gateway.\n */\nexport const RoleEventsFeature = createFeature({\n name: \"AccessManagement/RoleEvents\",\n register(container) {\n container.register(RefreshRoleInCacheRepository).inSingletonScope();\n container.register(ApplyRoleChangeToCache);\n }\n});\n"],"names":["RoleEventsFeature","createFeature","container","RefreshRoleInCacheRepository","ApplyRoleChangeToCache"],"mappings":";;;AAQO,MAAMA,oBAAoBC,cAAc;IAC3C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,8BAA8B,gBAAgB;QACjED,UAAU,QAAQ,CAACE;IACvB;AACJ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RecordChangedEventHandler } from "@webiny/app/features/recordChanges/index.js";
|
|
2
|
+
import { TeamsListCache } from "../listTeams/abstractions.js";
|
|
3
|
+
import { RefreshTeamInCacheRepository } from "./abstractions.js";
|
|
4
|
+
/**
|
|
5
|
+
* Keeps the teams list cache, which the Teams view renders from, in step with the server. A created
|
|
6
|
+
* or updated team is read back into it; a deleted team cannot be read back, so it is taken out.
|
|
7
|
+
*/
|
|
8
|
+
declare class ApplyTeamChangeToCacheImpl implements RecordChangedEventHandler.Interface {
|
|
9
|
+
private repository;
|
|
10
|
+
private cache;
|
|
11
|
+
constructor(repository: RefreshTeamInCacheRepository.Interface, cache: TeamsListCache.Interface);
|
|
12
|
+
handle(event: RecordChangedEventHandler.Event): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare const ApplyTeamChangeToCache: typeof ApplyTeamChangeToCacheImpl & {
|
|
15
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/app/features/eventPublisher/abstractions.js").IEventHandler<import("@webiny/app/features/recordChanges/RecordChangedEvent.js").RecordChangedEvent>>;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RecordChangedEventHandler } from "@webiny/app/features/recordChanges/index.js";
|
|
2
|
+
import { TeamsListCache } from "../listTeams/abstractions.js";
|
|
3
|
+
import { RefreshTeamInCacheRepository } from "./abstractions.js";
|
|
4
|
+
const TEAM_RECORD_TYPE = "security.team";
|
|
5
|
+
class ApplyTeamChangeToCacheImpl {
|
|
6
|
+
constructor(repository, cache){
|
|
7
|
+
this.repository = repository;
|
|
8
|
+
this.cache = cache;
|
|
9
|
+
}
|
|
10
|
+
async handle(event) {
|
|
11
|
+
const { type, id, change } = event.payload;
|
|
12
|
+
if (type !== TEAM_RECORD_TYPE) return;
|
|
13
|
+
if ("deleted" === change) return void this.cache.removeItems((team)=>team.id === id);
|
|
14
|
+
await this.repository.execute(id);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const ApplyTeamChangeToCache = RecordChangedEventHandler.createImplementation({
|
|
18
|
+
implementation: ApplyTeamChangeToCacheImpl,
|
|
19
|
+
dependencies: [
|
|
20
|
+
RefreshTeamInCacheRepository,
|
|
21
|
+
TeamsListCache
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
export { ApplyTeamChangeToCache };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=ApplyTeamChangeToCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/accessManagement/teams/teamEvents/ApplyTeamChangeToCache.js","sources":["../../../../../src/features/accessManagement/teams/teamEvents/ApplyTeamChangeToCache.ts"],"sourcesContent":["import { RecordChangedEventHandler } from \"@webiny/app/features/recordChanges/index.js\";\nimport { TeamsListCache } from \"../listTeams/abstractions.js\";\nimport { RefreshTeamInCacheRepository } from \"./abstractions.js\";\n\n// Sent by the api for teams; see `TEAM_RECORD_TYPE` in @webiny/api-core.\nconst TEAM_RECORD_TYPE = \"security.team\";\n\n/**\n * Keeps the teams list cache, which the Teams view renders from, in step with the server. A created\n * or updated team is read back into it; a deleted team cannot be read back, so it is taken out.\n */\nclass ApplyTeamChangeToCacheImpl implements RecordChangedEventHandler.Interface {\n constructor(\n private repository: RefreshTeamInCacheRepository.Interface,\n private cache: TeamsListCache.Interface\n ) {}\n\n async handle(event: RecordChangedEventHandler.Event): Promise<void> {\n const { type, id, change } = event.payload;\n if (type !== TEAM_RECORD_TYPE) {\n return;\n }\n\n if (change === \"deleted\") {\n this.cache.removeItems(team => team.id === id);\n return;\n }\n\n await this.repository.execute(id);\n }\n}\n\nexport const ApplyTeamChangeToCache = RecordChangedEventHandler.createImplementation({\n implementation: ApplyTeamChangeToCacheImpl,\n dependencies: [RefreshTeamInCacheRepository, TeamsListCache]\n});\n"],"names":["TEAM_RECORD_TYPE","ApplyTeamChangeToCacheImpl","repository","cache","event","type","id","change","team","ApplyTeamChangeToCache","RecordChangedEventHandler","RefreshTeamInCacheRepository","TeamsListCache"],"mappings":";;;AAKA,MAAMA,mBAAmB;AAMzB,MAAMC;IACF,YACYC,UAAkD,EAClDC,KAA+B,CACzC;aAFUD,UAAU,GAAVA;aACAC,KAAK,GAALA;IACT;IAEH,MAAM,OAAOC,KAAsC,EAAiB;QAChE,MAAM,EAAEC,IAAI,EAAEC,EAAE,EAAEC,MAAM,EAAE,GAAGH,MAAM,OAAO;QAC1C,IAAIC,SAASL,kBACT;QAGJ,IAAIO,AAAW,cAAXA,QAAsB,YACtB,IAAI,CAAC,KAAK,CAAC,WAAW,CAACC,CAAAA,OAAQA,KAAK,EAAE,KAAKF;QAI/C,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACA;IAClC;AACJ;AAEO,MAAMG,yBAAyBC,0BAA0B,oBAAoB,CAAC;IACjF,gBAAgBT;IAChB,cAAc;QAACU;QAA8BC;KAAe;AAChE"}
|
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
import type { IEventHandler } from "@webiny/app/features/eventPublisher/index.js";
|
|
2
|
-
import type { TeamCreatedEvent } from "./TeamCreatedEvent.js";
|
|
3
|
-
import type { TeamUpdatedEvent } from "./TeamUpdatedEvent.js";
|
|
4
|
-
import type { TeamDeletedEvent } from "./TeamDeletedEvent.js";
|
|
5
|
-
/**
|
|
6
|
-
* Reacts to a team created somewhere the admin did not see, such as by the assistant. Teams the admin
|
|
7
|
-
* creates itself are already in its list.
|
|
8
|
-
*/
|
|
9
|
-
export declare const TeamCreatedEventHandler: import("@webiny/di").Abstraction<IEventHandler<TeamCreatedEvent>>;
|
|
10
|
-
export declare namespace TeamCreatedEventHandler {
|
|
11
|
-
type Interface = IEventHandler<TeamCreatedEvent>;
|
|
12
|
-
type Event = TeamCreatedEvent;
|
|
13
|
-
}
|
|
14
|
-
/** Reacts to a team changed somewhere the admin did not see, such as by the assistant. */
|
|
15
|
-
export declare const TeamUpdatedEventHandler: import("@webiny/di").Abstraction<IEventHandler<TeamUpdatedEvent>>;
|
|
16
|
-
export declare namespace TeamUpdatedEventHandler {
|
|
17
|
-
type Interface = IEventHandler<TeamUpdatedEvent>;
|
|
18
|
-
type Event = TeamUpdatedEvent;
|
|
19
|
-
}
|
|
20
|
-
/** Reacts to a team deleted somewhere the admin did not see, such as by the assistant. */
|
|
21
|
-
export declare const TeamDeletedEventHandler: import("@webiny/di").Abstraction<IEventHandler<TeamDeletedEvent>>;
|
|
22
|
-
export declare namespace TeamDeletedEventHandler {
|
|
23
|
-
type Interface = IEventHandler<TeamDeletedEvent>;
|
|
24
|
-
type Event = TeamDeletedEvent;
|
|
25
|
-
}
|
|
26
1
|
export interface IRefreshTeamInCacheRepository {
|
|
27
2
|
execute(id: string): Promise<void>;
|
|
28
3
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/admin";
|
|
2
|
-
const TeamCreatedEventHandler = createAbstraction("AccessManagement/TeamCreatedEventHandler");
|
|
3
|
-
const TeamUpdatedEventHandler = createAbstraction("AccessManagement/TeamUpdatedEventHandler");
|
|
4
|
-
const TeamDeletedEventHandler = createAbstraction("AccessManagement/TeamDeletedEventHandler");
|
|
5
2
|
const RefreshTeamInCacheRepository = createAbstraction("AccessManagement/RefreshTeamInCacheRepository");
|
|
6
|
-
export { RefreshTeamInCacheRepository
|
|
3
|
+
export { RefreshTeamInCacheRepository };
|
|
7
4
|
|
|
8
5
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/accessManagement/teams/teamEvents/abstractions.js","sources":["../../../../../src/features/accessManagement/teams/teamEvents/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\
|
|
1
|
+
{"version":3,"file":"features/accessManagement/teams/teamEvents/abstractions.js","sources":["../../../../../src/features/accessManagement/teams/teamEvents/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\n\nexport interface IRefreshTeamInCacheRepository {\n execute(id: string): Promise<void>;\n}\n\n/** Reads a team back by id and puts it into the teams list, replacing the copy the list has. */\nexport const RefreshTeamInCacheRepository = createAbstraction<IRefreshTeamInCacheRepository>(\n \"AccessManagement/RefreshTeamInCacheRepository\"\n);\n\nexport namespace RefreshTeamInCacheRepository {\n export type Interface = IRefreshTeamInCacheRepository;\n}\n"],"names":["RefreshTeamInCacheRepository","createAbstraction"],"mappings":";AAOO,MAAMA,+BAA+BC,kBACxC"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/admin";
|
|
2
2
|
import { RefreshTeamInCacheRepository } from "./RefreshTeamInCacheRepository.js";
|
|
3
|
-
import {
|
|
4
|
-
import { RefreshUpdatedTeamInCache } from "./RefreshUpdatedTeamInCache.js";
|
|
5
|
-
import { RemoveDeletedTeamFromCache } from "./RemoveDeletedTeamFromCache.js";
|
|
6
|
-
import { TeamWebsocketMessages } from "./TeamWebsocketMessages.js";
|
|
3
|
+
import { ApplyTeamChangeToCache } from "./ApplyTeamChangeToCache.js";
|
|
7
4
|
const TeamEventsFeature = createFeature({
|
|
8
5
|
name: "AccessManagement/TeamEvents",
|
|
9
6
|
register (container) {
|
|
10
7
|
container.register(RefreshTeamInCacheRepository).inSingletonScope();
|
|
11
|
-
container.register(
|
|
12
|
-
container.register(RefreshUpdatedTeamInCache);
|
|
13
|
-
container.register(RemoveDeletedTeamFromCache);
|
|
14
|
-
container.register(TeamWebsocketMessages);
|
|
8
|
+
container.register(ApplyTeamChangeToCache);
|
|
15
9
|
}
|
|
16
10
|
});
|
|
17
11
|
export { TeamEventsFeature };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/accessManagement/teams/teamEvents/feature.js","sources":["../../../../../src/features/accessManagement/teams/teamEvents/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { RefreshTeamInCacheRepository } from \"./RefreshTeamInCacheRepository.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/accessManagement/teams/teamEvents/feature.js","sources":["../../../../../src/features/accessManagement/teams/teamEvents/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { RefreshTeamInCacheRepository } from \"./RefreshTeamInCacheRepository.js\";\nimport { ApplyTeamChangeToCache } from \"./ApplyTeamChangeToCache.js\";\n\n/**\n * Keeps the teams list current when teams are created, updated or deleted on the server. Needs\n * `ListTeamsFeature` and `GetTeamFeature` in the same container, for the cache and the gateway.\n */\nexport const TeamEventsFeature = createFeature({\n name: \"AccessManagement/TeamEvents\",\n register(container) {\n container.register(RefreshTeamInCacheRepository).inSingletonScope();\n container.register(ApplyTeamChangeToCache);\n }\n});\n"],"names":["TeamEventsFeature","createFeature","container","RefreshTeamInCacheRepository","ApplyTeamChangeToCache"],"mappings":";;;AAQO,MAAMA,oBAAoBC,cAAc;IAC3C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,8BAA8B,gBAAgB;QACjED,UAAU,QAAQ,CAACE;IACvB;AACJ"}
|
|
@@ -9,6 +9,7 @@ const toBody = (request)=>{
|
|
|
9
9
|
if (request.chatId) body["chatId"] = request.chatId;
|
|
10
10
|
if (request.prompt) body["prompt"] = request.prompt;
|
|
11
11
|
if (request.approvals?.length) body["approvals"] = request.approvals;
|
|
12
|
+
if (request.pageContext) body["pageContext"] = request.pageContext;
|
|
12
13
|
return body;
|
|
13
14
|
};
|
|
14
15
|
class AdminAssistantGatewayImpl {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/adminAssistant/AdminAssistantGateway.js","sources":["../../../src/features/adminAssistant/AdminAssistantGateway.ts"],"sourcesContent":["import { ApiStreamClient } from \"@webiny/app/features/apiStreamClient\";\nimport { readServerSentEvents } from \"@webiny/app/features/apiStreamClient\";\nimport { EnvConfig } from \"@webiny/app/features/envConfig\";\nimport { AdminAssistantGateway as Abstraction } from \"./abstractions.js\";\nimport type { AdminAssistantRequest } from \"./abstractions.js\";\nimport type { AdminAssistantStreamEvent } from \"./abstractions.js\";\nimport { AuthenticationContext } from \"~/features/security/AuthenticationContext/index.js\";\nimport { TenantContext } from \"~/features/tenancy/abstractions.js\";\n\n/*\n * The `/stream/` prefix is required, not cosmetic: it is the CloudFront behavior that targets the\n * Lambda Function URL. Any other path lands on API Gateway and gets buffered.\n */\nconst STREAM_PATH = \"/stream/ai/admin-assistant\";\n\nconst toBody = (request: AdminAssistantRequest): Record<string, unknown> => {\n const body: Record<string, unknown> = {};\n\n if (request.chatId) {\n body[\"chatId\"] = request.chatId;\n }\n if (request.prompt) {\n body[\"prompt\"] = request.prompt;\n }\n if (request.approvals?.length) {\n body[\"approvals\"] = request.approvals;\n }\n\n return body;\n};\n\n/**\n * Talks to the API app's chat routes.\n *\n * Streaming goes through `ApiStreamClient`, so auth and tenant headers come from the platform's own\n * decorators — including `x-webiny-authorization`, which the streaming path needs because on AWS\n * SigV4 occupies `Authorization`. Getting that wrong would silently make every streamed request\n * anonymous.\n *\n * The buffered call still uses `fetch`: `ApiStreamClient` hands back an unread `Response` for a caller\n * that owns a read loop, which is the wrong shape for a single JSON answer.\n */\nclass AdminAssistantGatewayImpl implements Abstraction.Interface {\n constructor(\n private authContext: AuthenticationContext.Interface,\n private envConfig: EnvConfig.Interface,\n private tenantContext: TenantContext.Interface,\n private streamClient: ApiStreamClient.Interface\n ) {}\n\n async *stream(\n request: AdminAssistantRequest,\n signal?: AbortSignal\n ): AsyncIterable<AdminAssistantStreamEvent> {\n const response = await this.streamClient.execute({\n path: STREAM_PATH,\n body: toBody(request),\n signal\n });\n\n yield* readServerSentEvents<AdminAssistantStreamEvent>(response);\n }\n}\n\nexport const AdminAssistantGateway = Abstraction.createImplementation({\n implementation: AdminAssistantGatewayImpl,\n dependencies: [AuthenticationContext, EnvConfig, TenantContext, ApiStreamClient]\n});\n"],"names":["STREAM_PATH","toBody","request","body","AdminAssistantGatewayImpl","authContext","envConfig","tenantContext","streamClient","signal","response","readServerSentEvents","AdminAssistantGateway","Abstraction","AuthenticationContext","EnvConfig","TenantContext","ApiStreamClient"],"mappings":";;;;;AAaA,MAAMA,cAAc;AAEpB,MAAMC,SAAS,CAACC;IACZ,MAAMC,OAAgC,CAAC;IAEvC,IAAID,QAAQ,MAAM,EACdC,IAAI,CAAC,SAAS,GAAGD,QAAQ,MAAM;IAEnC,IAAIA,QAAQ,MAAM,EACdC,IAAI,CAAC,SAAS,GAAGD,QAAQ,MAAM;IAEnC,IAAIA,QAAQ,SAAS,EAAE,QACnBC,IAAI,CAAC,YAAY,GAAGD,QAAQ,SAAS;
|
|
1
|
+
{"version":3,"file":"features/adminAssistant/AdminAssistantGateway.js","sources":["../../../src/features/adminAssistant/AdminAssistantGateway.ts"],"sourcesContent":["import { ApiStreamClient } from \"@webiny/app/features/apiStreamClient\";\nimport { readServerSentEvents } from \"@webiny/app/features/apiStreamClient\";\nimport { EnvConfig } from \"@webiny/app/features/envConfig\";\nimport { AdminAssistantGateway as Abstraction } from \"./abstractions.js\";\nimport type { AdminAssistantRequest } from \"./abstractions.js\";\nimport type { AdminAssistantStreamEvent } from \"./abstractions.js\";\nimport { AuthenticationContext } from \"~/features/security/AuthenticationContext/index.js\";\nimport { TenantContext } from \"~/features/tenancy/abstractions.js\";\n\n/*\n * The `/stream/` prefix is required, not cosmetic: it is the CloudFront behavior that targets the\n * Lambda Function URL. Any other path lands on API Gateway and gets buffered.\n */\nconst STREAM_PATH = \"/stream/ai/admin-assistant\";\n\nconst toBody = (request: AdminAssistantRequest): Record<string, unknown> => {\n const body: Record<string, unknown> = {};\n\n if (request.chatId) {\n body[\"chatId\"] = request.chatId;\n }\n if (request.prompt) {\n body[\"prompt\"] = request.prompt;\n }\n if (request.approvals?.length) {\n body[\"approvals\"] = request.approvals;\n }\n if (request.pageContext) {\n body[\"pageContext\"] = request.pageContext;\n }\n\n return body;\n};\n\n/**\n * Talks to the API app's chat routes.\n *\n * Streaming goes through `ApiStreamClient`, so auth and tenant headers come from the platform's own\n * decorators — including `x-webiny-authorization`, which the streaming path needs because on AWS\n * SigV4 occupies `Authorization`. Getting that wrong would silently make every streamed request\n * anonymous.\n *\n * The buffered call still uses `fetch`: `ApiStreamClient` hands back an unread `Response` for a caller\n * that owns a read loop, which is the wrong shape for a single JSON answer.\n */\nclass AdminAssistantGatewayImpl implements Abstraction.Interface {\n constructor(\n private authContext: AuthenticationContext.Interface,\n private envConfig: EnvConfig.Interface,\n private tenantContext: TenantContext.Interface,\n private streamClient: ApiStreamClient.Interface\n ) {}\n\n async *stream(\n request: AdminAssistantRequest,\n signal?: AbortSignal\n ): AsyncIterable<AdminAssistantStreamEvent> {\n const response = await this.streamClient.execute({\n path: STREAM_PATH,\n body: toBody(request),\n signal\n });\n\n yield* readServerSentEvents<AdminAssistantStreamEvent>(response);\n }\n}\n\nexport const AdminAssistantGateway = Abstraction.createImplementation({\n implementation: AdminAssistantGatewayImpl,\n dependencies: [AuthenticationContext, EnvConfig, TenantContext, ApiStreamClient]\n});\n"],"names":["STREAM_PATH","toBody","request","body","AdminAssistantGatewayImpl","authContext","envConfig","tenantContext","streamClient","signal","response","readServerSentEvents","AdminAssistantGateway","Abstraction","AuthenticationContext","EnvConfig","TenantContext","ApiStreamClient"],"mappings":";;;;;AAaA,MAAMA,cAAc;AAEpB,MAAMC,SAAS,CAACC;IACZ,MAAMC,OAAgC,CAAC;IAEvC,IAAID,QAAQ,MAAM,EACdC,IAAI,CAAC,SAAS,GAAGD,QAAQ,MAAM;IAEnC,IAAIA,QAAQ,MAAM,EACdC,IAAI,CAAC,SAAS,GAAGD,QAAQ,MAAM;IAEnC,IAAIA,QAAQ,SAAS,EAAE,QACnBC,IAAI,CAAC,YAAY,GAAGD,QAAQ,SAAS;IAEzC,IAAIA,QAAQ,WAAW,EACnBC,IAAI,CAAC,cAAc,GAAGD,QAAQ,WAAW;IAG7C,OAAOC;AACX;AAaA,MAAMC;IACF,YACYC,WAA4C,EAC5CC,SAA8B,EAC9BC,aAAsC,EACtCC,YAAuC,CACjD;aAJUH,WAAW,GAAXA;aACAC,SAAS,GAATA;aACAC,aAAa,GAAbA;aACAC,YAAY,GAAZA;IACT;IAEH,OAAO,OACHN,OAA8B,EAC9BO,MAAoB,EACoB;QACxC,MAAMC,WAAW,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;YAC7C,MAAMV;YACN,MAAMC,OAAOC;YACbO;QACJ;QAEA,OAAOE,qBAAgDD;IAC3D;AACJ;AAEO,MAAME,8CAAwBC,sBAAAA,oBAAgC,CAAC;IAClE,gBAAgBT;IAChB,cAAc;QAACU;QAAuBC;QAAWC;QAAeC;KAAgB;AACpF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AdminAssistantGateway } from "./abstractions.js";
|
|
2
2
|
import { AdminAssistantPresenter as Abstraction } from "./abstractions.js";
|
|
3
3
|
import { AiChatsRepository } from "../../features/aiChats/abstractions.js";
|
|
4
|
+
import { AssistantPageContext } from "../../features/assistantPageContext/abstractions.js";
|
|
4
5
|
/**
|
|
5
6
|
* Owns the palette's AI conversation.
|
|
6
7
|
*
|
|
@@ -16,6 +17,7 @@ import { AiChatsRepository } from "../../features/aiChats/abstractions.js";
|
|
|
16
17
|
declare class AdminAssistantPresenterImpl implements Abstraction.Interface {
|
|
17
18
|
private gateway;
|
|
18
19
|
private chats;
|
|
20
|
+
private pageContext;
|
|
19
21
|
private turns;
|
|
20
22
|
private busy;
|
|
21
23
|
private model;
|
|
@@ -25,7 +27,7 @@ declare class AdminAssistantPresenterImpl implements Abstraction.Interface {
|
|
|
25
27
|
private saveFailure;
|
|
26
28
|
private controller;
|
|
27
29
|
private generation;
|
|
28
|
-
constructor(gateway: AdminAssistantGateway.Interface, chats: AiChatsRepository.Interface);
|
|
30
|
+
constructor(gateway: AdminAssistantGateway.Interface, chats: AiChatsRepository.Interface, pageContext: AssistantPageContext.Interface);
|
|
29
31
|
get vm(): Abstraction.ViewModel;
|
|
30
32
|
ask(question: string): void;
|
|
31
33
|
decide(turnIndex: number, approved: boolean): void;
|
|
@@ -33,6 +35,11 @@ declare class AdminAssistantPresenterImpl implements Abstraction.Interface {
|
|
|
33
35
|
private get setupRequired();
|
|
34
36
|
reset(): void;
|
|
35
37
|
open(chatId: string): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* A question, with whatever the screen behind the palette says about itself. Read at the moment
|
|
40
|
+
* of asking, so a retry describes the screen the user is on now.
|
|
41
|
+
*/
|
|
42
|
+
private question;
|
|
36
43
|
/** A request for the chat on screen: the server reads its history from the saved chat. */
|
|
37
44
|
private request;
|
|
38
45
|
private run;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { makeAutoObservable } from "mobx";
|
|
2
2
|
import { AdminAssistantGateway, AdminAssistantPresenter } from "./abstractions.js";
|
|
3
3
|
import { AiChatsRepository } from "../aiChats/abstractions.js";
|
|
4
|
+
import { AssistantPageContext } from "../assistantPageContext/abstractions.js";
|
|
4
5
|
import { messageOf } from "../aiChats/messageOf.js";
|
|
5
6
|
import { turnsFromMessages } from "./turnsFromMessages.js";
|
|
6
7
|
const NOT_CONFIGURED = "AI_CAPABILITY_NOT_CONFIGURED";
|
|
@@ -17,9 +18,10 @@ const emptyTurn = (question)=>({
|
|
|
17
18
|
settled: false
|
|
18
19
|
});
|
|
19
20
|
class AdminAssistantPresenterImpl {
|
|
20
|
-
constructor(gateway, chats){
|
|
21
|
+
constructor(gateway, chats, pageContext){
|
|
21
22
|
this.gateway = gateway;
|
|
22
23
|
this.chats = chats;
|
|
24
|
+
this.pageContext = pageContext;
|
|
23
25
|
this.turns = [];
|
|
24
26
|
this.busy = false;
|
|
25
27
|
this.model = void 0;
|
|
@@ -32,7 +34,8 @@ class AdminAssistantPresenterImpl {
|
|
|
32
34
|
makeAutoObservable(this, {
|
|
33
35
|
controller: false,
|
|
34
36
|
generation: false,
|
|
35
|
-
chats: false
|
|
37
|
+
chats: false,
|
|
38
|
+
pageContext: false
|
|
36
39
|
});
|
|
37
40
|
}
|
|
38
41
|
get vm() {
|
|
@@ -71,9 +74,7 @@ class AdminAssistantPresenterImpl {
|
|
|
71
74
|
this.clearStorageError();
|
|
72
75
|
const index = this.turns.length;
|
|
73
76
|
this.addTurn(trimmed);
|
|
74
|
-
const request = this.
|
|
75
|
-
prompt: trimmed
|
|
76
|
-
});
|
|
77
|
+
const request = this.question(trimmed);
|
|
77
78
|
this.run(index, request);
|
|
78
79
|
}
|
|
79
80
|
decide(turnIndex, approved) {
|
|
@@ -109,9 +110,7 @@ class AdminAssistantPresenterImpl {
|
|
|
109
110
|
...fresh,
|
|
110
111
|
running: true
|
|
111
112
|
});
|
|
112
|
-
const request = this.
|
|
113
|
-
prompt: turn.question
|
|
114
|
-
});
|
|
113
|
+
const request = this.question(turn.question);
|
|
115
114
|
this.run(index, request);
|
|
116
115
|
}
|
|
117
116
|
get setupRequired() {
|
|
@@ -142,6 +141,14 @@ class AdminAssistantPresenterImpl {
|
|
|
142
141
|
if (generation === this.generation) this.setOpening(false);
|
|
143
142
|
}
|
|
144
143
|
}
|
|
144
|
+
question(prompt) {
|
|
145
|
+
const request = this.request({
|
|
146
|
+
prompt
|
|
147
|
+
});
|
|
148
|
+
const pageContext = this.pageContext.get();
|
|
149
|
+
if (pageContext) request.pageContext = pageContext;
|
|
150
|
+
return request;
|
|
151
|
+
}
|
|
145
152
|
request(rest) {
|
|
146
153
|
const request = {
|
|
147
154
|
...rest
|
|
@@ -327,7 +334,8 @@ const AdminAssistantPresenter_AdminAssistantPresenter = AdminAssistantPresenter.
|
|
|
327
334
|
implementation: AdminAssistantPresenterImpl,
|
|
328
335
|
dependencies: [
|
|
329
336
|
AdminAssistantGateway,
|
|
330
|
-
AiChatsRepository
|
|
337
|
+
AiChatsRepository,
|
|
338
|
+
AssistantPageContext
|
|
331
339
|
]
|
|
332
340
|
});
|
|
333
341
|
export { AdminAssistantPresenter_AdminAssistantPresenter as AdminAssistantPresenter };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/adminAssistant/AdminAssistantPresenter.js","sources":["../../../src/features/adminAssistant/AdminAssistantPresenter.ts"],"sourcesContent":["import { makeAutoObservable } from \"mobx\";\nimport { AdminAssistantGateway } from \"./abstractions.js\";\nimport type { AdminAssistantRequest } from \"./abstractions.js\";\nimport { AdminAssistantPresenter as Abstraction } from \"./abstractions.js\";\nimport type { AiTurnViewModel } from \"./abstractions.js\";\nimport { AiChatsRepository } from \"~/features/aiChats/abstractions.js\";\nimport type { AiChatSaveFailure } from \"~/features/aiChats/abstractions.js\";\nimport { messageOf } from \"~/features/aiChats/messageOf.js\";\nimport { turnsFromMessages } from \"./turnsFromMessages.js\";\n\n/** A turn plus the state the view never sees. `needsSetup` is derived from `errorCode`. */\ninterface Turn extends Omit<AiTurnViewModel, \"needsSetup\"> {\n /** The server's code for the failure, when it sent one. */\n errorCode?: string;\n}\n\n/** The code a run fails with when the project's AI settings give the assistant no model. */\nconst NOT_CONFIGURED = \"AI_CAPABILITY_NOT_CONFIGURED\";\n\nconst emptyTurn = (question: string): Turn => ({\n question,\n text: \"\",\n answerStart: 0,\n tools: [],\n completed: [],\n failed: [],\n running: false,\n pendingApprovals: [],\n followUps: [],\n settled: false\n});\n\n/**\n * Owns the palette's AI conversation.\n *\n * A presenter rather than component state: several pieces change together, a network stream drives\n * them, and an abort has to outlive any one render.\n *\n * Registered as a singleton, so `reset` genuinely clears rather than relying on unmount.\n *\n * The server keeps the conversation: a question sends only the chat id and the question, and the\n * assistant reads the history from the saved chat and saves the run when it ends. The turns here\n * are what is shown, never what is sent.\n */\nclass AdminAssistantPresenterImpl implements Abstraction.Interface {\n private turns: Turn[] = [];\n private busy = false;\n private model: string | undefined = undefined;\n private chatId: string | null = null;\n private opening = false;\n private storageError: string | null = null;\n private saveFailure: AiChatSaveFailure | null = null;\n private controller: AbortController | null = null;\n /*\n * Bumped whenever the conversation is replaced. An open that finishes after that belongs to a\n * conversation that is gone, and must not write its turns onto the new one.\n */\n private generation = 0;\n\n constructor(\n private gateway: AdminAssistantGateway.Interface,\n private chats: AiChatsRepository.Interface\n ) {\n // Machinery, not state anything renders, so keep them out of the map.\n makeAutoObservable<AdminAssistantPresenterImpl, \"controller\" | \"generation\" | \"chats\">(\n this,\n { controller: false, generation: false, chats: false }\n );\n }\n\n get vm(): Abstraction.ViewModel {\n const vm: Abstraction.ViewModel = {\n busy: this.busy,\n chatId: this.chatId,\n opening: this.opening,\n storageError: this.storageError,\n saveFailure: this.saveFailure,\n setupRequired: this.setupRequired,\n turns: this.turns.map(turn => {\n const view: AiTurnViewModel = {\n question: turn.question,\n text: turn.text,\n answerStart: turn.answerStart,\n tools: turn.tools,\n completed: turn.completed,\n failed: turn.failed,\n running: turn.running,\n pendingApprovals: turn.pendingApprovals,\n followUps: turn.followUps,\n settled: turn.settled,\n needsSetup: turn.errorCode === NOT_CONFIGURED\n };\n\n if (turn.error !== undefined) {\n view.error = turn.error;\n }\n\n return view;\n })\n };\n\n if (this.model !== undefined) {\n vm.model = this.model;\n }\n\n return vm;\n }\n\n ask(question: string): void {\n const trimmed = question.trim();\n\n /*\n * While a saved chat loads, a question would land in a conversation about to be replaced.\n * With no model set up it would fail the same way, so only \"Try again\" asks.\n */\n if (!trimmed || this.busy || this.opening || this.setupRequired) {\n return;\n }\n\n // Asking something else rejects a change still waiting; the server does the same.\n this.dropPendingApprovals();\n this.clearStorageError();\n\n const index = this.turns.length;\n this.addTurn(trimmed);\n const request = this.request({ prompt: trimmed });\n void this.run(index, request);\n }\n\n decide(turnIndex: number, approved: boolean): void {\n const turn = this.turns[turnIndex];\n\n if (!turn?.pendingApprovals.length || this.busy || this.opening) {\n return;\n }\n\n // The paused run is resumed from the saved chat, so a run that was not saved cannot be.\n if (!this.chatId || this.saveFailure) {\n this.patch(turnIndex, {\n pendingApprovals: [],\n error: \"This change can't run because the chat wasn't saved. Ask again to retry.\"\n });\n return;\n }\n\n const approvals = turn.pendingApprovals.map(approval => ({\n approvalId: approval.approvalId,\n approved\n }));\n\n // Clear the block immediately so the plan cannot be submitted twice.\n this.patch(turnIndex, {\n pendingApprovals: [],\n followUps: [],\n settled: false,\n running: true\n });\n\n const request = this.request({ approvals });\n void this.run(turnIndex, request, true);\n }\n\n /*\n * The newest turn asked again in place, from an empty answer: one that failed, or one that ran\n * but was not saved. Either way the saved chat does not have it, so the server answers it again\n * with the same history it had the first time.\n */\n retry(): void {\n const index = this.turns.length - 1;\n const turn = this.turns[index];\n\n if (!turn || this.busy || this.opening) {\n return;\n }\n // A run that cannot be saved by asking again is left for a new chat.\n if (!turn.error && this.saveFailure !== \"retryable\") {\n return;\n }\n\n this.clearStorageError();\n const fresh = emptyTurn(turn.question);\n this.replaceTurn(index, { ...fresh, running: true });\n const request = this.request({ prompt: turn.question });\n void this.run(index, request);\n }\n\n private get setupRequired(): boolean {\n const newest = this.turns[this.turns.length - 1];\n return newest?.errorCode === NOT_CONFIGURED;\n }\n\n reset(): void {\n this.controller?.abort();\n this.controller = null;\n this.generation++;\n this.clear();\n }\n\n async open(chatId: string): Promise<void> {\n this.reset();\n const generation = this.generation;\n this.setOpening(true);\n\n try {\n const chat = await this.chats.get(chatId);\n if (generation !== this.generation) {\n return;\n }\n const turns = turnsFromMessages(chat.messages);\n this.setConversation(chat.id, turns);\n } catch (error) {\n if (generation === this.generation) {\n const message = messageOf(error);\n this.setStorageError(message);\n }\n } finally {\n if (generation === this.generation) {\n this.setOpening(false);\n }\n }\n }\n\n /** A request for the chat on screen: the server reads its history from the saved chat. */\n private request(rest: Omit<AdminAssistantRequest, \"chatId\">): AdminAssistantRequest {\n const request: AdminAssistantRequest = { ...rest };\n if (this.chatId) {\n request.chatId = this.chatId;\n }\n return request;\n }\n\n private async run(\n index: number,\n request: AdminAssistantRequest,\n resuming = false\n ): Promise<void> {\n this.controller?.abort();\n const controller = new AbortController();\n this.controller = controller;\n\n this.setBusy(true);\n\n try {\n /*\n * Resuming continues the same turn: the tools already called, the text already shown and\n * the messages already collected all still belong to it. Starting from empty would strand\n * earlier chips as running and, worse, drop the assistant message carrying the `tool_use`\n * that the replayed `tool_result` refers to.\n */\n const existing = resuming ? this.turns[index] : undefined;\n let text = existing?.text ?? \"\";\n const tools: string[] = existing ? [...existing.tools] : [];\n const completed: string[] = existing ? [...existing.completed] : [];\n const failed: string[] = existing ? [...existing.failed] : [];\n /*\n * A resumed run writes on after the text shown before the approval pause. Without a\n * break, the two ran together (\"...a new folder:Understood, no folder was created.\").\n */\n let separateFromExisting = text.length > 0;\n\n for await (const event of this.gateway.stream(request, controller.signal)) {\n if (event.type === \"start\") {\n this.setModel(event.model);\n continue;\n }\n\n if (event.type === \"text\") {\n text += separateFromExisting ? `\\n\\n${event.text}` : event.text;\n separateFromExisting = false;\n this.patch(index, { text, running: false });\n continue;\n }\n\n if (event.type === \"tool-call\") {\n tools.push(event.name);\n this.patch(index, {\n tools: [...tools],\n running: true,\n answerStart: text.length\n });\n continue;\n }\n\n if (event.type === \"tool-result\") {\n completed.push(event.name);\n this.patch(index, { completed: [...completed] });\n continue;\n }\n\n if (event.type === \"tool-error\") {\n failed.push(event.name);\n this.patch(index, { failed: [...failed] });\n continue;\n }\n\n if (event.type === \"follow-ups\") {\n this.patch(index, { followUps: event.questions });\n continue;\n }\n\n if (event.type === \"approval\") {\n this.patch(index, { pendingApprovals: event.approvals, running: false });\n continue;\n }\n\n if (event.type === \"saved\") {\n this.setSaved(event.chat);\n continue;\n }\n\n /*\n * A resumed run may have carried out the change the user approved. Asking again\n * would start before that change, so the model proposes it again and approving\n * twice makes it twice. Only a new chat is offered then.\n */\n if (event.type === \"not-saved\") {\n const failure = event.retryable && !resuming ? \"retryable\" : \"final\";\n this.setSaveFailed(event.message, failure);\n continue;\n }\n\n if (event.type === \"done\") {\n this.patch(index, { settled: true, running: false });\n continue;\n }\n\n if (event.type === \"error\") {\n this.patch(index, {\n error: event.message,\n errorCode: event.code,\n settled: true,\n running: false\n });\n return;\n }\n }\n } catch (error) {\n // An abort is the palette closing, not a failure worth showing.\n if (!controller.signal.aborted) {\n this.patch(index, {\n error: error instanceof Error ? error.message : String(error),\n settled: true,\n running: false\n });\n }\n } finally {\n this.setBusy(false);\n }\n }\n\n /*\n * Every mutation below is its own method on purpose. `run` awaits, and a mutation after an await\n * has escaped the action it started in; `makeAutoObservable` makes these methods actions, so\n * calling them from there is correct.\n */\n private addTurn(question: string): void {\n this.turns = [...this.turns, { ...emptyTurn(question), running: true }];\n }\n\n private replaceTurn(index: number, turn: Turn): void {\n this.turns = this.turns.map((existing, i) => (i === index ? turn : existing));\n }\n\n private patch(index: number, change: Partial<Turn>): void {\n this.turns = this.turns.map((turn, i) => (i === index ? { ...turn, ...change } : turn));\n }\n\n private setBusy(busy: boolean): void {\n this.busy = busy;\n }\n\n private setModel(model: string): void {\n this.model = model;\n }\n\n private setOpening(opening: boolean): void {\n this.opening = opening;\n }\n\n private setConversation(chatId: string, turns: Turn[]): void {\n this.chatId = chatId;\n this.turns = turns;\n }\n\n // The chats list learns of the chat from here, so it shows up without being read again.\n private setSaved(chat: AiChatsRepository.Summary): void {\n this.chatId = chat.id;\n this.storageError = null;\n this.saveFailure = null;\n this.chats.remember(chat);\n }\n\n private dropPendingApprovals(): void {\n this.turns = this.turns.map(turn => {\n if (turn.pendingApprovals.length === 0) {\n return turn;\n }\n return { ...turn, pendingApprovals: [] };\n });\n }\n\n private setStorageError(message: string): void {\n this.storageError = message;\n this.saveFailure = null;\n }\n\n private setSaveFailed(message: string, failure: AiChatSaveFailure): void {\n this.storageError = message;\n this.saveFailure = failure;\n }\n\n private clearStorageError(): void {\n this.storageError = null;\n this.saveFailure = null;\n }\n\n private clear(): void {\n this.turns = [];\n this.busy = false;\n this.chatId = null;\n this.opening = false;\n this.storageError = null;\n this.saveFailure = null;\n }\n}\n\nexport const AdminAssistantPresenter = Abstraction.createImplementation({\n implementation: AdminAssistantPresenterImpl,\n dependencies: [AdminAssistantGateway, AiChatsRepository]\n});\n"],"names":["NOT_CONFIGURED","emptyTurn","question","AdminAssistantPresenterImpl","gateway","chats","undefined","makeAutoObservable","vm","turn","view","trimmed","index","request","turnIndex","approved","approvals","approval","fresh","newest","chatId","generation","chat","turns","turnsFromMessages","error","message","messageOf","rest","resuming","controller","AbortController","existing","text","tools","completed","failed","separateFromExisting","event","failure","Error","String","i","change","busy","model","opening","AdminAssistantPresenter","Abstraction","AdminAssistantGateway","AiChatsRepository"],"mappings":";;;;;AAiBA,MAAMA,iBAAiB;AAEvB,MAAMC,YAAY,CAACC,WAA4B;QAC3CA;QACA,MAAM;QACN,aAAa;QACb,OAAO,EAAE;QACT,WAAW,EAAE;QACb,QAAQ,EAAE;QACV,SAAS;QACT,kBAAkB,EAAE;QACpB,WAAW,EAAE;QACb,SAAS;IACb;AAcA,MAAMC;IAeF,YACYC,OAAwC,EACxCC,KAAkC,CAC5C;aAFUD,OAAO,GAAPA;aACAC,KAAK,GAALA;aAhBJ,KAAK,GAAW,EAAE;aAClB,IAAI,GAAG;aACP,KAAK,GAAuBC;aAC5B,MAAM,GAAkB;aACxB,OAAO,GAAG;aACV,YAAY,GAAkB;aAC9B,WAAW,GAA6B;aACxC,UAAU,GAA2B;QAI5C,KACO,UAAU,GAAG;QAOjBC,mBACI,IAAI,EACJ;YAAE,YAAY;YAAO,YAAY;YAAO,OAAO;QAAM;IAE7D;IAEA,IAAI,KAA4B;QAC5B,MAAMC,KAA4B;YAC9B,MAAM,IAAI,CAAC,IAAI;YACf,QAAQ,IAAI,CAAC,MAAM;YACnB,SA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;IAEQ,oBAA0B;QAC9B,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,WAAW,GAAG;IACvB;IAEQ,QAAc;QAClB,IAAI,CAAC,KAAK,GAAG,EAAE;QACf,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,MAAM,GAAG;QACd,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,WAAW,GAAG;IACvB;AACJ;AAEO,MAAMQ,kDAA0BC,wBAAAA,oBAAgC,CAAC;IACpE,gBAAgB7C;IAChB,cAAc;QAAC8C;QAAuBC;KAAkB;AAC5D"}
|
|
1
|
+
{"version":3,"file":"features/adminAssistant/AdminAssistantPresenter.js","sources":["../../../src/features/adminAssistant/AdminAssistantPresenter.ts"],"sourcesContent":["import { makeAutoObservable } from \"mobx\";\nimport { AdminAssistantGateway } from \"./abstractions.js\";\nimport type { AdminAssistantRequest } from \"./abstractions.js\";\nimport { AdminAssistantPresenter as Abstraction } from \"./abstractions.js\";\nimport type { AiTurnViewModel } from \"./abstractions.js\";\nimport { AiChatsRepository } from \"~/features/aiChats/abstractions.js\";\nimport { AssistantPageContext } from \"~/features/assistantPageContext/abstractions.js\";\nimport type { AiChatSaveFailure } from \"~/features/aiChats/abstractions.js\";\nimport { messageOf } from \"~/features/aiChats/messageOf.js\";\nimport { turnsFromMessages } from \"./turnsFromMessages.js\";\n\n/** A turn plus the state the view never sees. `needsSetup` is derived from `errorCode`. */\ninterface Turn extends Omit<AiTurnViewModel, \"needsSetup\"> {\n /** The server's code for the failure, when it sent one. */\n errorCode?: string;\n}\n\n/** The code a run fails with when the project's AI settings give the assistant no model. */\nconst NOT_CONFIGURED = \"AI_CAPABILITY_NOT_CONFIGURED\";\n\nconst emptyTurn = (question: string): Turn => ({\n question,\n text: \"\",\n answerStart: 0,\n tools: [],\n completed: [],\n failed: [],\n running: false,\n pendingApprovals: [],\n followUps: [],\n settled: false\n});\n\n/**\n * Owns the palette's AI conversation.\n *\n * A presenter rather than component state: several pieces change together, a network stream drives\n * them, and an abort has to outlive any one render.\n *\n * Registered as a singleton, so `reset` genuinely clears rather than relying on unmount.\n *\n * The server keeps the conversation: a question sends only the chat id and the question, and the\n * assistant reads the history from the saved chat and saves the run when it ends. The turns here\n * are what is shown, never what is sent.\n */\nclass AdminAssistantPresenterImpl implements Abstraction.Interface {\n private turns: Turn[] = [];\n private busy = false;\n private model: string | undefined = undefined;\n private chatId: string | null = null;\n private opening = false;\n private storageError: string | null = null;\n private saveFailure: AiChatSaveFailure | null = null;\n private controller: AbortController | null = null;\n /*\n * Bumped whenever the conversation is replaced. An open that finishes after that belongs to a\n * conversation that is gone, and must not write its turns onto the new one.\n */\n private generation = 0;\n\n constructor(\n private gateway: AdminAssistantGateway.Interface,\n private chats: AiChatsRepository.Interface,\n private pageContext: AssistantPageContext.Interface\n ) {\n // Machinery, not state anything renders, so keep them out of the map.\n makeAutoObservable<\n AdminAssistantPresenterImpl,\n \"controller\" | \"generation\" | \"chats\" | \"pageContext\"\n >(this, { controller: false, generation: false, chats: false, pageContext: false });\n }\n\n get vm(): Abstraction.ViewModel {\n const vm: Abstraction.ViewModel = {\n busy: this.busy,\n chatId: this.chatId,\n opening: this.opening,\n storageError: this.storageError,\n saveFailure: this.saveFailure,\n setupRequired: this.setupRequired,\n turns: this.turns.map(turn => {\n const view: AiTurnViewModel = {\n question: turn.question,\n text: turn.text,\n answerStart: turn.answerStart,\n tools: turn.tools,\n completed: turn.completed,\n failed: turn.failed,\n running: turn.running,\n pendingApprovals: turn.pendingApprovals,\n followUps: turn.followUps,\n settled: turn.settled,\n needsSetup: turn.errorCode === NOT_CONFIGURED\n };\n\n if (turn.error !== undefined) {\n view.error = turn.error;\n }\n\n return view;\n })\n };\n\n if (this.model !== undefined) {\n vm.model = this.model;\n }\n\n return vm;\n }\n\n ask(question: string): void {\n const trimmed = question.trim();\n\n /*\n * While a saved chat loads, a question would land in a conversation about to be replaced.\n * With no model set up it would fail the same way, so only \"Try again\" asks.\n */\n if (!trimmed || this.busy || this.opening || this.setupRequired) {\n return;\n }\n\n // Asking something else rejects a change still waiting; the server does the same.\n this.dropPendingApprovals();\n this.clearStorageError();\n\n const index = this.turns.length;\n this.addTurn(trimmed);\n const request = this.question(trimmed);\n void this.run(index, request);\n }\n\n decide(turnIndex: number, approved: boolean): void {\n const turn = this.turns[turnIndex];\n\n if (!turn?.pendingApprovals.length || this.busy || this.opening) {\n return;\n }\n\n // The paused run is resumed from the saved chat, so a run that was not saved cannot be.\n if (!this.chatId || this.saveFailure) {\n this.patch(turnIndex, {\n pendingApprovals: [],\n error: \"This change can't run because the chat wasn't saved. Ask again to retry.\"\n });\n return;\n }\n\n const approvals = turn.pendingApprovals.map(approval => ({\n approvalId: approval.approvalId,\n approved\n }));\n\n // Clear the block immediately so the plan cannot be submitted twice.\n this.patch(turnIndex, {\n pendingApprovals: [],\n followUps: [],\n settled: false,\n running: true\n });\n\n const request = this.request({ approvals });\n void this.run(turnIndex, request, true);\n }\n\n /*\n * The newest turn asked again in place, from an empty answer: one that failed, or one that ran\n * but was not saved. Either way the saved chat does not have it, so the server answers it again\n * with the same history it had the first time.\n */\n retry(): void {\n const index = this.turns.length - 1;\n const turn = this.turns[index];\n\n if (!turn || this.busy || this.opening) {\n return;\n }\n // A run that cannot be saved by asking again is left for a new chat.\n if (!turn.error && this.saveFailure !== \"retryable\") {\n return;\n }\n\n this.clearStorageError();\n const fresh = emptyTurn(turn.question);\n this.replaceTurn(index, { ...fresh, running: true });\n const request = this.question(turn.question);\n void this.run(index, request);\n }\n\n private get setupRequired(): boolean {\n const newest = this.turns[this.turns.length - 1];\n return newest?.errorCode === NOT_CONFIGURED;\n }\n\n reset(): void {\n this.controller?.abort();\n this.controller = null;\n this.generation++;\n this.clear();\n }\n\n async open(chatId: string): Promise<void> {\n this.reset();\n const generation = this.generation;\n this.setOpening(true);\n\n try {\n const chat = await this.chats.get(chatId);\n if (generation !== this.generation) {\n return;\n }\n const turns = turnsFromMessages(chat.messages);\n this.setConversation(chat.id, turns);\n } catch (error) {\n if (generation === this.generation) {\n const message = messageOf(error);\n this.setStorageError(message);\n }\n } finally {\n if (generation === this.generation) {\n this.setOpening(false);\n }\n }\n }\n\n /**\n * A question, with whatever the screen behind the palette says about itself. Read at the moment\n * of asking, so a retry describes the screen the user is on now.\n */\n private question(prompt: string): AdminAssistantRequest {\n const request = this.request({ prompt });\n const pageContext = this.pageContext.get();\n if (pageContext) {\n request.pageContext = pageContext;\n }\n return request;\n }\n\n /** A request for the chat on screen: the server reads its history from the saved chat. */\n private request(rest: Omit<AdminAssistantRequest, \"chatId\">): AdminAssistantRequest {\n const request: AdminAssistantRequest = { ...rest };\n if (this.chatId) {\n request.chatId = this.chatId;\n }\n return request;\n }\n\n private async run(\n index: number,\n request: AdminAssistantRequest,\n resuming = false\n ): Promise<void> {\n this.controller?.abort();\n const controller = new AbortController();\n this.controller = controller;\n\n this.setBusy(true);\n\n try {\n /*\n * Resuming continues the same turn: the tools already called, the text already shown and\n * the messages already collected all still belong to it. Starting from empty would strand\n * earlier chips as running and, worse, drop the assistant message carrying the `tool_use`\n * that the replayed `tool_result` refers to.\n */\n const existing = resuming ? this.turns[index] : undefined;\n let text = existing?.text ?? \"\";\n const tools: string[] = existing ? [...existing.tools] : [];\n const completed: string[] = existing ? [...existing.completed] : [];\n const failed: string[] = existing ? [...existing.failed] : [];\n /*\n * A resumed run writes on after the text shown before the approval pause. Without a\n * break, the two ran together (\"...a new folder:Understood, no folder was created.\").\n */\n let separateFromExisting = text.length > 0;\n\n for await (const event of this.gateway.stream(request, controller.signal)) {\n if (event.type === \"start\") {\n this.setModel(event.model);\n continue;\n }\n\n if (event.type === \"text\") {\n text += separateFromExisting ? `\\n\\n${event.text}` : event.text;\n separateFromExisting = false;\n this.patch(index, { text, running: false });\n continue;\n }\n\n if (event.type === \"tool-call\") {\n tools.push(event.name);\n this.patch(index, {\n tools: [...tools],\n running: true,\n answerStart: text.length\n });\n continue;\n }\n\n if (event.type === \"tool-result\") {\n completed.push(event.name);\n this.patch(index, { completed: [...completed] });\n continue;\n }\n\n if (event.type === \"tool-error\") {\n failed.push(event.name);\n this.patch(index, { failed: [...failed] });\n continue;\n }\n\n if (event.type === \"follow-ups\") {\n this.patch(index, { followUps: event.questions });\n continue;\n }\n\n if (event.type === \"approval\") {\n this.patch(index, { pendingApprovals: event.approvals, running: false });\n continue;\n }\n\n if (event.type === \"saved\") {\n this.setSaved(event.chat);\n continue;\n }\n\n /*\n * A resumed run may have carried out the change the user approved. Asking again\n * would start before that change, so the model proposes it again and approving\n * twice makes it twice. Only a new chat is offered then.\n */\n if (event.type === \"not-saved\") {\n const failure = event.retryable && !resuming ? \"retryable\" : \"final\";\n this.setSaveFailed(event.message, failure);\n continue;\n }\n\n if (event.type === \"done\") {\n this.patch(index, { settled: true, running: false });\n continue;\n }\n\n if (event.type === \"error\") {\n this.patch(index, {\n error: event.message,\n errorCode: event.code,\n settled: true,\n running: false\n });\n return;\n }\n }\n } catch (error) {\n // An abort is the palette closing, not a failure worth showing.\n if (!controller.signal.aborted) {\n this.patch(index, {\n error: error instanceof Error ? error.message : String(error),\n settled: true,\n running: false\n });\n }\n } finally {\n this.setBusy(false);\n }\n }\n\n /*\n * Every mutation below is its own method on purpose. `run` awaits, and a mutation after an await\n * has escaped the action it started in; `makeAutoObservable` makes these methods actions, so\n * calling them from there is correct.\n */\n private addTurn(question: string): void {\n this.turns = [...this.turns, { ...emptyTurn(question), running: true }];\n }\n\n private replaceTurn(index: number, turn: Turn): void {\n this.turns = this.turns.map((existing, i) => (i === index ? turn : existing));\n }\n\n private patch(index: number, change: Partial<Turn>): void {\n this.turns = this.turns.map((turn, i) => (i === index ? { ...turn, ...change } : turn));\n }\n\n private setBusy(busy: boolean): void {\n this.busy = busy;\n }\n\n private setModel(model: string): void {\n this.model = model;\n }\n\n private setOpening(opening: boolean): void {\n this.opening = opening;\n }\n\n private setConversation(chatId: string, turns: Turn[]): void {\n this.chatId = chatId;\n this.turns = turns;\n }\n\n // The chats list learns of the chat from here, so it shows up without being read again.\n private setSaved(chat: AiChatsRepository.Summary): void {\n this.chatId = chat.id;\n this.storageError = null;\n this.saveFailure = null;\n this.chats.remember(chat);\n }\n\n private dropPendingApprovals(): void {\n this.turns = this.turns.map(turn => {\n if (turn.pendingApprovals.length === 0) {\n return turn;\n }\n return { ...turn, pendingApprovals: [] };\n });\n }\n\n private setStorageError(message: string): void {\n this.storageError = message;\n this.saveFailure = null;\n }\n\n private setSaveFailed(message: string, failure: AiChatSaveFailure): void {\n this.storageError = message;\n this.saveFailure = failure;\n }\n\n private clearStorageError(): void {\n this.storageError = null;\n this.saveFailure = null;\n }\n\n private clear(): void {\n this.turns = [];\n this.busy = false;\n this.chatId = null;\n this.opening = false;\n this.storageError = null;\n this.saveFailure = null;\n }\n}\n\nexport const AdminAssistantPresenter = Abstraction.createImplementation({\n implementation: AdminAssistantPresenterImpl,\n dependencies: [AdminAssistantGateway, AiChatsRepository, AssistantPageContext]\n});\n"],"names":["NOT_CONFIGURED","emptyTurn","question","AdminAssistantPresenterImpl","gateway","chats","pageContext","undefined","makeAutoObservable","vm","turn","view","trimmed","index","request","turnIndex","approved","approvals","approval","fresh","newest","chatId","generation","chat","turns","turnsFromMessages","error","message","messageOf","prompt","rest","resuming","controller","AbortController","existing","text","tools","completed","failed","separateFromExisting","event","failure","Error","String","i","change","busy","model","opening","AdminAssistantPresenter","Abstraction","AdminAssistantGateway","AiChatsRepository","AssistantPageContext"],"mappings":";;;;;;AAkBA,MAAMA,iBAAiB;AAEvB,MAAMC,YAAY,CAACC,WAA4B;QAC3CA;QACA,MAAM;QACN,aAAa;QACb,OAAO,EAAE;QACT,WAAW,EAAE;QACb,QAAQ,EAAE;QACV,SAAS;QACT,kBAAkB,EAAE;QACpB,WAAW,EAAE;QACb,SAAS;IACb;AAcA,MAAMC;IAeF,YACYC,OAAwC,EACxCC,KAAkC,EAClCC,WAA2C,CACrD;aAHUF,OAAO,GAAP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AI,CAAC,MAAM,GAAGA,KAAK,EAAE;QACrB,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAACA;IACxB;IAEQ,uBAA6B;QACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAACb,CAAAA;YACxB,IAAIA,AAAiC,MAAjCA,KAAK,gBAAgB,CAAC,MAAM,EAC5B,OAAOA;YAEX,OAAO;gBAAE,GAAGA,IAAI;gBAAE,kBAAkB,EAAE;YAAC;QAC3C;IACJ;IAEQ,gBAAgBiB,OAAe,EAAQ;QAC3C,IAAI,CAAC,YAAY,GAAGA;QACpB,IAAI,CAAC,WAAW,GAAG;IACvB;IAEQ,cAAcA,OAAe,EAAEc,OAA0B,EAAQ;QACrE,IAAI,CAAC,YAAY,GAAGd;QACpB,IAAI,CAAC,WAAW,GAAGc;IACvB;IAEQ,oBAA0B;QAC9B,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,WAAW,GAAG;IACvB;IAEQ,QAAc;QAClB,IAAI,CAAC,KAAK,GAAG,EAAE;QACf,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,MAAM,GAAG;QACd,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,WAAW,GAAG;IACvB;AACJ;AAEO,MAAMQ,kDAA0BC,wBAAAA,oBAAgC,CAAC;IACpE,gBAAgB/C;IAChB,cAAc;QAACgD;QAAuBC;QAAmBC;KAAqB;AAClF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AiChatSaveFailure } from "../../features/aiChats/abstractions.js";
|
|
2
2
|
import type { AiChatsRepository } from "../../features/aiChats/abstractions.js";
|
|
3
|
+
import type { AssistantPageContext } from "../../features/assistantPageContext/abstractions.js";
|
|
3
4
|
/**
|
|
4
5
|
* A message of a saved chat. Opaque on purpose: the admin only reads them to show an opened chat,
|
|
5
6
|
* and the server is the one that sends them to the model.
|
|
@@ -36,6 +37,8 @@ export interface AdminAssistantRequest {
|
|
|
36
37
|
prompt?: string;
|
|
37
38
|
/** Approve or reject calls the server paused on. Needs the `chatId` of the paused run. */
|
|
38
39
|
approvals?: AdminAssistantDecision[];
|
|
40
|
+
/** What the user had on screen when they asked. Sent with questions only. */
|
|
41
|
+
pageContext?: AssistantPageContext.Data;
|
|
39
42
|
}
|
|
40
43
|
/**
|
|
41
44
|
* What the assistant emits while it works. Mirrors the server's `AdminAssistantEvent`; declared here so the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/adminAssistant/abstractions.js","sources":["../../../src/features/adminAssistant/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { AiChatSaveFailure } from \"~/features/aiChats/abstractions.js\";\nimport type { AiChatsRepository } from \"~/features/aiChats/abstractions.js\";\n\n/**\n * A message of a saved chat. Opaque on purpose: the admin only reads them to show an opened chat,\n * and the server is the one that sends them to the model.\n */\nexport type AdminAssistantMessage = { role: string; content: unknown };\n\n/** A tool the assistant invoked, so the UI can show its work rather than just an answer. */\nexport interface AdminAssistantToolCall {\n name: string;\n input: unknown;\n}\n\n/** A tool call the assistant wants to make but has not made, because it changes something. */\nexport interface AdminAssistantPendingApproval {\n approvalId: string;\n toolName: string;\n title?: string;\n input: unknown;\n /** The tool declared itself destructive — the UI should say so more loudly. */\n destructive: boolean;\n}\n\nexport interface AdminAssistantDecision {\n approvalId: string;\n approved: boolean;\n reason?: string;\n}\n\n/**\n * A question, or the decisions on the calls a run paused on. The server reads the rest of the\n * conversation from the saved chat, so only its id is sent; without one, a question starts a chat.\n */\nexport interface AdminAssistantRequest {\n chatId?: string;\n prompt?: string;\n /** Approve or reject calls the server paused on. Needs the `chatId` of the paused run. */\n approvals?: AdminAssistantDecision[];\n}\n\n/**\n * What the assistant emits while it works. Mirrors the server's `AdminAssistantEvent`; declared here so the\n * admin bundle carries no server or AI SDK code.\n */\nexport type AdminAssistantStreamEvent =\n // The run is going ahead, on this model (\"anthropic/claude-sonnet-4-5\").\n | { type: \"start\"; model: string }\n | { type: \"text\"; text: string }\n | { type: \"tool-call\"; name: string }\n | { type: \"tool-result\"; name: string }\n // A tool threw. Pairs with `tool-call` by name, and does not end the run.\n | { type: \"tool-error\"; name: string; message: string }\n | { type: \"follow-ups\"; questions: string[] }\n | { type: \"approval\"; approvals: AdminAssistantPendingApproval[] }\n // The run was saved, as a new chat or onto the one asked about.\n | { type: \"saved\"; chat: AiChatsRepository.Summary }\n // The run finished but the server could not save it. `retryable` says whether asking again could.\n | { type: \"not-saved\"; message: string; retryable: boolean }\n // Comes after `saved` or `not-saved`.\n | { type: \"done\"; steps: number }\n | { type: \"error\"; message: string; code?: \"AI_CAPABILITY_NOT_CONFIGURED\" };\n\nexport interface IAdminAssistantGateway {\n /**\n * Run and yield progress as it arrives. Preferred in the UI: a multi-tool question takes tens of\n * seconds, and an approval request is worth showing the moment it appears.\n */\n stream(\n request: AdminAssistantRequest,\n signal?: AbortSignal\n ): AsyncIterable<AdminAssistantStreamEvent>;\n}\n\n/** Sends a question to the server-side AI assistant (`POST /ai/chat`). */\nexport const AdminAssistantGateway =\n createAbstraction<IAdminAssistantGateway>(\"AdminAssistantGateway\");\n\nexport namespace AdminAssistantGateway {\n export type Interface = IAdminAssistantGateway;\n export type Message = AdminAssistantMessage;\n export type ToolCall = AdminAssistantToolCall;\n export type PendingApproval = AdminAssistantPendingApproval;\n export type Decision = AdminAssistantDecision;\n export type Request = AdminAssistantRequest;\n export type StreamEvent = AdminAssistantStreamEvent;\n}\n\n/** One question and the answer to it, as the view needs it. */\nexport interface AiTurnViewModel {\n question: string;\n /** Answer text so far. Grows as the stream arrives. */\n text: string;\n /**\n * Where the answer proper starts in `text`: after the last tool call. Text before it is the\n * model saying what it is about to look up, which is no summary of the answer.\n */\n answerStart: number;\n /** Tools called this turn, in call order. */\n tools: string[];\n /**\n * Tools that returned. A call pending approval still emits `tool-call`, so this is the only way\n * to tell a completed tool from one merely proposed.\n */\n completed: string[];\n /** Tools that threw. Settles the chip as a failure; the run continues. */\n failed: string[];\n /** Set while a tool is running and no answer text has arrived yet. */\n running: boolean;\n pendingApprovals: AdminAssistantPendingApproval[];\n /** Questions the assistant suggests asking next. Empty until the answer is in. */\n followUps: string[];\n settled: boolean;\n error?: string;\n /**\n * The turn failed because the project has no model set up. Shown as a setup screen rather\n * than an error; `error` holds the server's reason, which names the setting to fix.\n */\n needsSetup: boolean;\n}\n\nexport interface IAdminAssistantViewModel {\n turns: AiTurnViewModel[];\n /** A run is in flight. Asking again or deciding again is refused while true. */\n busy: boolean;\n /**\n * The model the last run used, fully qualified. Absent before the first run, since the admin\n * only learns it from the server.\n */\n model?: string;\n /** The saved chat this conversation is, once its first turn is saved or a chat is opened. */\n chatId: string | null;\n /** A saved chat is being read. */\n opening: boolean;\n /**\n * Why the last run was not saved, or the last open failed. The conversation on screen carries\n * on either way; this is only so the view can say it is not saved.\n */\n storageError: string | null;\n /**\n * Set when it was a run that was not saved, so the view can offer what fixes it. Null for an\n * open.\n */\n saveFailure: AiChatSaveFailure | null;\n /**\n * The newest turn needs a model set up first. No question is taken until \"Try again\" (`retry`)\n * succeeds, so the view can stop taking input.\n */\n setupRequired: boolean;\n}\n\nexport interface IAdminAssistantPresenter {\n readonly vm: IAdminAssistantViewModel;\n /**\n * Ask a question in the chat on screen. A change still waiting on a decision is rejected.\n * Refused while `setupRequired`.\n */\n ask(question: string): void;\n /** Approve or reject the calls a turn paused on, then resume it. */\n decide(turnIndex: number, approved: boolean): void;\n /** Drop the conversation and stop anything in flight. The saved chat is kept. */\n reset(): void;\n /** Replace the conversation with a saved chat, so asking again continues it. */\n open(chatId: string): Promise<void>;\n /** Ask the newest question again, when its run failed or was not saved. */\n retry(): void;\n}\n\nexport const AdminAssistantPresenter =\n createAbstraction<IAdminAssistantPresenter>(\"AdminAssistantPresenter\");\n\nexport namespace AdminAssistantPresenter {\n export type Interface = IAdminAssistantPresenter;\n export type ViewModel = IAdminAssistantViewModel;\n export type Turn = AiTurnViewModel;\n}\n"],"names":["AdminAssistantGateway","createAbstraction","AdminAssistantPresenter"],"mappings":";
|
|
1
|
+
{"version":3,"file":"features/adminAssistant/abstractions.js","sources":["../../../src/features/adminAssistant/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { AiChatSaveFailure } from \"~/features/aiChats/abstractions.js\";\nimport type { AiChatsRepository } from \"~/features/aiChats/abstractions.js\";\nimport type { AssistantPageContext } from \"~/features/assistantPageContext/abstractions.js\";\n\n/**\n * A message of a saved chat. Opaque on purpose: the admin only reads them to show an opened chat,\n * and the server is the one that sends them to the model.\n */\nexport type AdminAssistantMessage = { role: string; content: unknown };\n\n/** A tool the assistant invoked, so the UI can show its work rather than just an answer. */\nexport interface AdminAssistantToolCall {\n name: string;\n input: unknown;\n}\n\n/** A tool call the assistant wants to make but has not made, because it changes something. */\nexport interface AdminAssistantPendingApproval {\n approvalId: string;\n toolName: string;\n title?: string;\n input: unknown;\n /** The tool declared itself destructive — the UI should say so more loudly. */\n destructive: boolean;\n}\n\nexport interface AdminAssistantDecision {\n approvalId: string;\n approved: boolean;\n reason?: string;\n}\n\n/**\n * A question, or the decisions on the calls a run paused on. The server reads the rest of the\n * conversation from the saved chat, so only its id is sent; without one, a question starts a chat.\n */\nexport interface AdminAssistantRequest {\n chatId?: string;\n prompt?: string;\n /** Approve or reject calls the server paused on. Needs the `chatId` of the paused run. */\n approvals?: AdminAssistantDecision[];\n /** What the user had on screen when they asked. Sent with questions only. */\n pageContext?: AssistantPageContext.Data;\n}\n\n/**\n * What the assistant emits while it works. Mirrors the server's `AdminAssistantEvent`; declared here so the\n * admin bundle carries no server or AI SDK code.\n */\nexport type AdminAssistantStreamEvent =\n // The run is going ahead, on this model (\"anthropic/claude-sonnet-4-5\").\n | { type: \"start\"; model: string }\n | { type: \"text\"; text: string }\n | { type: \"tool-call\"; name: string }\n | { type: \"tool-result\"; name: string }\n // A tool threw. Pairs with `tool-call` by name, and does not end the run.\n | { type: \"tool-error\"; name: string; message: string }\n | { type: \"follow-ups\"; questions: string[] }\n | { type: \"approval\"; approvals: AdminAssistantPendingApproval[] }\n // The run was saved, as a new chat or onto the one asked about.\n | { type: \"saved\"; chat: AiChatsRepository.Summary }\n // The run finished but the server could not save it. `retryable` says whether asking again could.\n | { type: \"not-saved\"; message: string; retryable: boolean }\n // Comes after `saved` or `not-saved`.\n | { type: \"done\"; steps: number }\n | { type: \"error\"; message: string; code?: \"AI_CAPABILITY_NOT_CONFIGURED\" };\n\nexport interface IAdminAssistantGateway {\n /**\n * Run and yield progress as it arrives. Preferred in the UI: a multi-tool question takes tens of\n * seconds, and an approval request is worth showing the moment it appears.\n */\n stream(\n request: AdminAssistantRequest,\n signal?: AbortSignal\n ): AsyncIterable<AdminAssistantStreamEvent>;\n}\n\n/** Sends a question to the server-side AI assistant (`POST /ai/chat`). */\nexport const AdminAssistantGateway =\n createAbstraction<IAdminAssistantGateway>(\"AdminAssistantGateway\");\n\nexport namespace AdminAssistantGateway {\n export type Interface = IAdminAssistantGateway;\n export type Message = AdminAssistantMessage;\n export type ToolCall = AdminAssistantToolCall;\n export type PendingApproval = AdminAssistantPendingApproval;\n export type Decision = AdminAssistantDecision;\n export type Request = AdminAssistantRequest;\n export type StreamEvent = AdminAssistantStreamEvent;\n}\n\n/** One question and the answer to it, as the view needs it. */\nexport interface AiTurnViewModel {\n question: string;\n /** Answer text so far. Grows as the stream arrives. */\n text: string;\n /**\n * Where the answer proper starts in `text`: after the last tool call. Text before it is the\n * model saying what it is about to look up, which is no summary of the answer.\n */\n answerStart: number;\n /** Tools called this turn, in call order. */\n tools: string[];\n /**\n * Tools that returned. A call pending approval still emits `tool-call`, so this is the only way\n * to tell a completed tool from one merely proposed.\n */\n completed: string[];\n /** Tools that threw. Settles the chip as a failure; the run continues. */\n failed: string[];\n /** Set while a tool is running and no answer text has arrived yet. */\n running: boolean;\n pendingApprovals: AdminAssistantPendingApproval[];\n /** Questions the assistant suggests asking next. Empty until the answer is in. */\n followUps: string[];\n settled: boolean;\n error?: string;\n /**\n * The turn failed because the project has no model set up. Shown as a setup screen rather\n * than an error; `error` holds the server's reason, which names the setting to fix.\n */\n needsSetup: boolean;\n}\n\nexport interface IAdminAssistantViewModel {\n turns: AiTurnViewModel[];\n /** A run is in flight. Asking again or deciding again is refused while true. */\n busy: boolean;\n /**\n * The model the last run used, fully qualified. Absent before the first run, since the admin\n * only learns it from the server.\n */\n model?: string;\n /** The saved chat this conversation is, once its first turn is saved or a chat is opened. */\n chatId: string | null;\n /** A saved chat is being read. */\n opening: boolean;\n /**\n * Why the last run was not saved, or the last open failed. The conversation on screen carries\n * on either way; this is only so the view can say it is not saved.\n */\n storageError: string | null;\n /**\n * Set when it was a run that was not saved, so the view can offer what fixes it. Null for an\n * open.\n */\n saveFailure: AiChatSaveFailure | null;\n /**\n * The newest turn needs a model set up first. No question is taken until \"Try again\" (`retry`)\n * succeeds, so the view can stop taking input.\n */\n setupRequired: boolean;\n}\n\nexport interface IAdminAssistantPresenter {\n readonly vm: IAdminAssistantViewModel;\n /**\n * Ask a question in the chat on screen. A change still waiting on a decision is rejected.\n * Refused while `setupRequired`.\n */\n ask(question: string): void;\n /** Approve or reject the calls a turn paused on, then resume it. */\n decide(turnIndex: number, approved: boolean): void;\n /** Drop the conversation and stop anything in flight. The saved chat is kept. */\n reset(): void;\n /** Replace the conversation with a saved chat, so asking again continues it. */\n open(chatId: string): Promise<void>;\n /** Ask the newest question again, when its run failed or was not saved. */\n retry(): void;\n}\n\nexport const AdminAssistantPresenter =\n createAbstraction<IAdminAssistantPresenter>(\"AdminAssistantPresenter\");\n\nexport namespace AdminAssistantPresenter {\n export type Interface = IAdminAssistantPresenter;\n export type ViewModel = IAdminAssistantViewModel;\n export type Turn = AiTurnViewModel;\n}\n"],"names":["AdminAssistantGateway","createAbstraction","AdminAssistantPresenter"],"mappings":";AAgFO,MAAMA,wBACTC,kBAA0C;AA4FvC,MAAMC,0BACTD,kBAA4C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface AdminUsersCapabilitiesData {
|
|
2
|
+
/**
|
|
3
|
+
* A user's account is shared by all of their tenants, so a New User whose email has an account
|
|
4
|
+
* in another tenant is linked to this tenant instead of created. Needs the `adminUsers.checkEmail`
|
|
5
|
+
* query and the `adminUsers.linkUser` mutation.
|
|
6
|
+
*/
|
|
7
|
+
linkAccounts: boolean;
|
|
8
|
+
/** An administrator can reset another user's MFA. Needs the `adminUsers.resetUserMfa` mutation. */
|
|
9
|
+
resetMfa: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* What the identity provider behind the Users screen supports beyond creating, editing and deleting
|
|
13
|
+
* users. Set by the provider's admin extension through `<AdminUsers capabilities={...} />`.
|
|
14
|
+
*/
|
|
15
|
+
export declare const AdminUsersCapabilities: import("@webiny/di").Abstraction<AdminUsersCapabilitiesData>;
|
|
16
|
+
export declare namespace AdminUsersCapabilities {
|
|
17
|
+
type Interface = AdminUsersCapabilitiesData;
|
|
18
|
+
}
|