@jini-ai/user-management 0.7.1 → 0.7.3-next.1
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/CHANGELOG.md +1 -1
- package/README.md +9 -5
- package/dist/admin/adapters/http.js +25 -20
- package/dist/admin/adapters/memory.js +164 -82
- package/dist/admin/auth.module.d.ts +2 -2
- package/dist/admin/auth.module.js +1 -1
- package/dist/admin/conformance/index.js +40 -18
- package/dist/admin/controllers/auth.controller.js +3 -1
- package/dist/admin/controllers/members.controller.js +56 -31
- package/dist/admin/controllers/roles.controller.d.ts +3 -3
- package/dist/admin/controllers/roles.controller.js +188 -122
- package/dist/admin/controllers/users.controller.js +151 -72
- package/dist/admin/members.module.d.ts +2 -2
- package/dist/admin/members.module.js +1 -1
- package/dist/admin/models.d.ts +1 -0
- package/dist/admin/ports.d.ts +3 -0
- package/dist/admin/react/components/DestructiveDialog.d.ts +1 -1
- package/dist/admin/react/components/DestructiveDialog.js +1 -1
- package/dist/admin/react/components/MemberRow.d.ts +3 -1
- package/dist/admin/react/components/MemberRow.js +2 -2
- package/dist/admin/react/components/MembersConfirmation.d.ts +4 -1
- package/dist/admin/react/components/MembersConfirmation.js +2 -2
- package/dist/admin/react/components/PermissionPanel.d.ts +4 -2
- package/dist/admin/react/components/PermissionPanel.js +2 -2
- package/dist/admin/react/components/PolicyRow.d.ts +4 -2
- package/dist/admin/react/components/PolicyRow.js +2 -2
- package/dist/admin/react/components/RoleRow.d.ts +4 -2
- package/dist/admin/react/components/RoleRow.js +2 -2
- package/dist/admin/react/components/UserRow.d.ts +3 -1
- package/dist/admin/react/components/UserRow.js +2 -2
- package/dist/admin/react/components/UsersConfirmation.d.ts +4 -1
- package/dist/admin/react/components/UsersConfirmation.js +2 -2
- package/dist/admin/react/hooks/AuthBinding.hooks.d.ts +1 -1
- package/dist/admin/react/hooks/AuthScope.hooks.d.ts +1 -1
- package/dist/admin/react/hooks/MembersBinding.hooks.d.ts +1 -1
- package/dist/admin/react/hooks/MembersScope.hooks.d.ts +1 -1
- package/dist/admin/react/hooks/PeopleController.hooks.js +6 -4
- package/dist/admin/react/hooks/RolesBinding.hooks.d.ts +1 -1
- package/dist/admin/react/hooks/RolesController.hooks.d.ts +4 -4
- package/dist/admin/react/hooks/RolesController.hooks.js +4 -3
- package/dist/admin/react/hooks/RolesPage.hooks.d.ts +8 -8
- package/dist/admin/react/hooks/RolesScope.hooks.d.ts +1 -1
- package/dist/admin/react/hooks/UsersBinding.hooks.d.ts +1 -1
- package/dist/admin/react/hooks/UsersScope.hooks.d.ts +1 -1
- package/dist/admin/react/index.d.ts +9 -9
- package/dist/admin/react/pages/LoginPage.d.ts +4 -1
- package/dist/admin/react/pages/LoginPage.js +2 -2
- package/dist/admin/react/pages/MembersPage.d.ts +4 -1
- package/dist/admin/react/pages/MembersPage.js +2 -2
- package/dist/admin/react/pages/RolesPage.d.ts +4 -1
- package/dist/admin/react/pages/RolesPage.js +2 -2
- package/dist/admin/react/pages/UsersPage.d.ts +4 -1
- package/dist/admin/react/pages/UsersPage.js +2 -2
- package/dist/admin/react/tabs/AuthTab.d.ts +4 -2
- package/dist/admin/react/tabs/AuthTab.js +2 -2
- package/dist/admin/react/tabs/MembersTab.d.ts +4 -2
- package/dist/admin/react/tabs/MembersTab.js +2 -2
- package/dist/admin/react/tabs/PoliciesTab.d.ts +4 -2
- package/dist/admin/react/tabs/PoliciesTab.js +2 -2
- package/dist/admin/react/tabs/RolesTab.d.ts +4 -2
- package/dist/admin/react/tabs/RolesTab.js +2 -2
- package/dist/admin/react/tabs/UsersTab.d.ts +3 -1
- package/dist/admin/react/tabs/UsersTab.js +2 -2
- package/dist/admin/roles.module.d.ts +2 -2
- package/dist/admin/roles.module.js +1 -1
- package/dist/admin/users.module.d.ts +4 -4
- package/dist/admin/users.module.js +1 -1
- package/dist/react/auth/Login.js +1 -1
- package/dist/react/auth/OwnerRecovery.hooks.d.ts +93 -0
- package/dist/react/auth/OwnerRecovery.hooks.js +105 -0
- package/dist/react/auth/Passkeys.d.ts +8 -3
- package/dist/react/auth/Passkeys.hooks.d.ts +38 -0
- package/dist/react/auth/Passkeys.hooks.js +72 -0
- package/dist/react/auth/Passkeys.js +6 -64
- package/dist/react/auth/TotpSettings.d.ts +5 -2
- package/dist/react/auth/TotpSettings.hooks.d.ts +41 -0
- package/dist/react/auth/TotpSettings.hooks.js +82 -0
- package/dist/react/auth/TotpSettings.js +10 -77
- package/dist/react/auth/hooks/use-login.hooks.d.ts +1 -1
- package/dist/react/auth/hooks/use-login.hooks.js +1 -0
- package/dist/react/errors.d.ts +1 -1
- package/dist/react/errors.js +1 -0
- package/dist/react/index.d.ts +6 -2
- package/dist/react/index.js +3 -1
- package/dist/react/kit.d.ts +91 -0
- package/dist/react/kit.js +63 -0
- package/dist/react/members/Members.d.ts +1 -1
- package/dist/react/members/Members.js +19 -5
- package/dist/react/members/hooks/use-members.hooks.d.ts +1 -1
- package/dist/react/members/hooks/use-members.hooks.js +49 -27
- package/dist/react/members/rules.d.ts +2 -2
- package/dist/react/members/rules.js +1 -0
- package/dist/react/ports.d.ts +2 -0
- package/dist/react/testing.js +47 -22
- package/dist/react/users/ChangeUsernameDialog.d.ts +2 -2
- package/dist/react/users/ChangeUsernameDialog.js +4 -3
- package/dist/react/users/UserRowParts.d.ts +3 -3
- package/dist/react/users/UserRowParts.js +2 -1
- package/dist/react/users/Users.d.ts +3 -3
- package/dist/react/users/Users.js +14 -27
- package/dist/react/users/UsersDialogs.d.ts +7 -0
- package/dist/react/users/UsersDialogs.js +64 -0
- package/dist/react/users/UsersTable.d.ts +118 -0
- package/dist/react/users/UsersTable.js +55 -0
- package/dist/react/users/hooks/use-change-username.hooks.d.ts +1 -1
- package/dist/react/users/hooks/use-change-username.hooks.js +2 -1
- package/dist/react/users/hooks/use-reset-password-fields.hooks.d.ts +8 -0
- package/dist/react/users/hooks/use-reset-password-fields.hooks.js +11 -0
- package/dist/react/users/hooks/use-users-form-state.hooks.d.ts +81 -0
- package/dist/react/users/hooks/use-users-form-state.hooks.js +68 -0
- package/dist/react/users/hooks/use-users-password.hooks.d.ts +24 -0
- package/dist/react/users/hooks/use-users-password.hooks.js +85 -0
- package/dist/react/users/hooks/use-users-roster.hooks.d.ts +42 -0
- package/dist/react/users/hooks/use-users-roster.hooks.js +133 -0
- package/dist/react/users/hooks/use-users-state.hooks.d.ts +102 -0
- package/dist/react/users/hooks/use-users-state.hooks.js +19 -0
- package/dist/react/users/hooks/use-users-status.hooks.d.ts +26 -0
- package/dist/react/users/hooks/use-users-status.hooks.js +97 -0
- package/dist/react/users/hooks/use-users.hooks.d.ts +13 -5
- package/dist/react/users/hooks/use-users.hooks.js +23 -503
- package/dist/react/users/hooks/users-controller.d.ts +14 -0
- package/dist/react/users/hooks/users-controller.js +29 -0
- package/dist/react/users/hooks/users-grant-actions.d.ts +26 -0
- package/dist/react/users/hooks/users-grant-actions.js +124 -0
- package/dist/react/users/rules.d.ts +5 -4
- package/dist/react/users/rules.js +3 -2
- package/dist/server/admin-crud-service.d.ts +2 -2
- package/dist/server/admin-crud-service.js +38 -71
- package/dist/server/agent-tool-input.d.ts +7 -3
- package/dist/server/agent-tool-input.js +47 -14
- package/dist/server/agent-tool-registrations.d.ts +5 -2
- package/dist/server/agent-tool-registrations.js +250 -199
- package/dist/server/agent-tools.d.ts +1 -1
- package/dist/server/auth-service.js +1 -1
- package/dist/server/grant-service.d.ts +8 -0
- package/dist/server/grant-service.js +24 -22
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/link-policy.d.ts +23 -0
- package/dist/server/link-policy.js +30 -0
- package/dist/server/permission-migrations.d.ts +3 -3
- package/dist/server/repo.memory-transactions.js +24 -20
- package/dist/server/repo.memory.d.ts +21 -33
- package/dist/server/repo.memory.js +13 -34
- package/dist/server/seed.d.ts +3 -3
- package/dist/server/seed.js +10 -10
- package/dist/session-bootstrap/ensure.d.ts +13 -0
- package/dist/session-bootstrap/ensure.js +11 -0
- package/dist/session-bootstrap/index.d.ts +5 -0
- package/dist/session-bootstrap/index.js +4 -0
- package/dist/session-bootstrap/loopback.d.ts +14 -0
- package/dist/session-bootstrap/loopback.js +25 -0
- package/dist/session-bootstrap/read-initial.d.ts +25 -0
- package/dist/session-bootstrap/read-initial.js +27 -0
- package/package.json +20 -24
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { interpolate } from "@jini-ai/core/text";
|
|
3
|
+
import { useFetchMutation as useFetchMutationDefault } from "../../kit.js";
|
|
4
|
+
export function useUsersPasswordLink({ users, ownPrincipalId, ownProfile, resetPasswordFor }, { openOwnPasswordReset, onOwnPasswordResetClosed, openResetPassword }) {
|
|
5
|
+
/** Guards the one-shot deep-link auto-open effect below so it fires at most once per mount, even
|
|
6
|
+
* as `users`/`ownPrincipalId` keep changing identity across the renders it's waiting on (list
|
|
7
|
+
* reloads, `me()` settling). Separate from {@link openedViaDeepLinkRef}, which tracks a DIFFERENT
|
|
8
|
+
* question ("should closing the dialog navigate away") over the dialog's own open/close lifetime
|
|
9
|
+
* — this one is "has the auto-open already been attempted", which must stay true forever once it
|
|
10
|
+
* fires, including after the dialog this effect opened has since been closed. */
|
|
11
|
+
const deepLinkAttemptedRef = useRef(false);
|
|
12
|
+
/** Set true exactly when this effect opens the dialog, cleared by the close-effect below the first
|
|
13
|
+
* time it observes `resetPasswordFor` go back to `null`. Read there to decide whether to navigate
|
|
14
|
+
* — an operator resetting a DIFFERENT row's password from the ordinary row menu, or cancelling a
|
|
15
|
+
* normal reset, must not also get shoved to `/users`. */
|
|
16
|
+
const openedViaDeepLinkRef = useRef(false);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
// `ownProfile` is derived from exactly `users`/`ownPrincipalId` (see `selectCaller`), so it is
|
|
19
|
+
// `null` until both have settled and the caller's own row is in the roster.
|
|
20
|
+
if (!openOwnPasswordReset || deepLinkAttemptedRef.current || !ownProfile)
|
|
21
|
+
return;
|
|
22
|
+
deepLinkAttemptedRef.current = true;
|
|
23
|
+
openedViaDeepLinkRef.current = true;
|
|
24
|
+
openResetPassword(ownProfile);
|
|
25
|
+
}, [openOwnPasswordReset, users, ownPrincipalId]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (resetPasswordFor !== null || !openedViaDeepLinkRef.current)
|
|
28
|
+
return;
|
|
29
|
+
openedViaDeepLinkRef.current = false;
|
|
30
|
+
onOwnPasswordResetClosed?.();
|
|
31
|
+
}, [resetPasswordFor, onOwnPasswordResetClosed]);
|
|
32
|
+
}
|
|
33
|
+
export function useUsersResetMutation({ port }, { useFetchMutation = useFetchMutationDefault } = {}) {
|
|
34
|
+
// No `invalidates` — matches the pre-migration `confirmResetPassword`, which never called
|
|
35
|
+
// `reload()` either (a password reset changes nothing the users table shows).
|
|
36
|
+
const resetPasswordMutation = useFetchMutation({
|
|
37
|
+
run: ({ input }) => port.resetUserPassword(input),
|
|
38
|
+
});
|
|
39
|
+
return resetPasswordMutation;
|
|
40
|
+
}
|
|
41
|
+
export function createUsersOpenResetAction({ state }, _optional = {}) {
|
|
42
|
+
const { rowCapabilities, toggleSavingId, resetPassword, setNewPassword, setResetPasswordFor } = state;
|
|
43
|
+
/** Opens the reset-password dialog for `user` — the `RowMenu` item's `onSelect`. Guards against
|
|
44
|
+
* opening a second one while a toggle or a previous reset is still in flight, same discipline
|
|
45
|
+
* packages/admin/src/redirects/react/hooks/RedirectsPage.hooks.ts uses for its own `RowMenu` items (no per-item `disabled` on `RowMenu` itself). */
|
|
46
|
+
function openResetPassword(user) {
|
|
47
|
+
if (!rowCapabilities(user).canResetPassword)
|
|
48
|
+
return;
|
|
49
|
+
if (toggleSavingId || resetPassword.saving)
|
|
50
|
+
return;
|
|
51
|
+
resetPassword.setError(null);
|
|
52
|
+
setNewPassword("");
|
|
53
|
+
setResetPasswordFor(user);
|
|
54
|
+
}
|
|
55
|
+
return openResetPassword;
|
|
56
|
+
}
|
|
57
|
+
export function createUsersConfirmResetAction({ state, resetPasswordMutation }, { passwordResetNotice } = {}) {
|
|
58
|
+
const { resetPasswordFor, newPassword, rowCapabilities, resetPassword, ownPrincipalId, translate, setNotice, setResetPasswordFor, setNewPassword, describeError } = state;
|
|
59
|
+
async function confirmResetPassword() {
|
|
60
|
+
if (!resetPasswordFor || !newPassword || !rowCapabilities(resetPasswordFor).canResetPassword)
|
|
61
|
+
return;
|
|
62
|
+
// Dialog stays open on failure (unlike the Disable/Delete-style dialogs elsewhere in this app,
|
|
63
|
+
// which close either way) — closing would discard the password the operator just typed for no
|
|
64
|
+
// reason; there's nothing sensitive left on screen once they retry or cancel. `resetPasswordFor`/
|
|
65
|
+
// `newPassword` are therefore only cleared in the success path below, never as a `finally`.
|
|
66
|
+
await resetPassword.run({ action: async () => {
|
|
67
|
+
await resetPasswordMutation.mutate({ input: { principalId: resetPasswordFor.principalId, password: newPassword } });
|
|
68
|
+
// A self-reset (own row, deep-linked or from the ordinary row menu — see `ownPrincipalId`'s
|
|
69
|
+
// own doc comment) gets the "sign in again" notice instead of the per-username one: the reset
|
|
70
|
+
// just revoked the CALLER'S OWN session, so the next request 401s and the host app's `src/App.hooks.ts` sends
|
|
71
|
+
// them to the login screen — the generic notice naming a DIFFERENT user would be misleading
|
|
72
|
+
// here, since it's actually their own sign-in that just ended.
|
|
73
|
+
setNotice(resetPasswordFor.principalId === ownPrincipalId
|
|
74
|
+
? translate("Password changed. Sign in again with your new password.")
|
|
75
|
+
: passwordResetNotice?.({ username: resetPasswordFor.username }) ?? interpolate({
|
|
76
|
+
template: translate('Password reset for "{username}" — every active session for this user was revoked.'),
|
|
77
|
+
vars: { username: resetPasswordFor.username },
|
|
78
|
+
}));
|
|
79
|
+
setResetPasswordFor(null);
|
|
80
|
+
setNewPassword("");
|
|
81
|
+
}, describeError: (e) => describeError(e, translate("failed to reset password")) });
|
|
82
|
+
}
|
|
83
|
+
return confirmResetPassword;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=use-users-password.hooks.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { AdminIdentityUser, AdminPolicy, AdminRole } from "../../models.js";
|
|
2
|
+
import type { UsersPort } from "../../ports.js";
|
|
3
|
+
import { type UserAccountCapabilities } from "../rules.js";
|
|
4
|
+
import type { UsersDependencies } from "./use-users.hooks.js";
|
|
5
|
+
import type { createUsersErrorDescriber } from "./use-users-state.hooks.js";
|
|
6
|
+
import { useFetchQuery as useFetchQueryDefault } from "../../kit.js";
|
|
7
|
+
import { useChangeUsername as useChangeUsernameDefault } from "./use-change-username.hooks.js";
|
|
8
|
+
export declare function useUsersRoster({ port, translate, queryScope, describeError }: UsersDependencies & {
|
|
9
|
+
describeError: ReturnType<typeof createUsersErrorDescriber>;
|
|
10
|
+
}, { useFetchQuery }?: {
|
|
11
|
+
useFetchQuery?: typeof useFetchQueryDefault;
|
|
12
|
+
}): {
|
|
13
|
+
portRef: import("react").RefObject<UsersPort>;
|
|
14
|
+
users: AdminIdentityUser[] | null;
|
|
15
|
+
roles: AdminRole[] | null;
|
|
16
|
+
policies: AdminPolicy[] | null;
|
|
17
|
+
canGrant: boolean;
|
|
18
|
+
error: string | null;
|
|
19
|
+
};
|
|
20
|
+
export declare function useUsersCallerState({ portRef }: {
|
|
21
|
+
portRef: ReturnType<typeof useUsersRoster>["portRef"];
|
|
22
|
+
}, _optional?: Record<string, never>): {
|
|
23
|
+
ownPrincipalId: string | null;
|
|
24
|
+
effectivePermissions: string[];
|
|
25
|
+
canManageUserTrash: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare function createUsersCapabilities({ users, roles, ownPrincipalId, effectivePermissions, canManageUserTrash }: ReturnType<typeof useUsersRoster> & ReturnType<typeof useUsersCallerState>): {
|
|
28
|
+
ownProfile: AdminIdentityUser | null;
|
|
29
|
+
rowCapabilities: (user: AdminIdentityUser) => UserAccountCapabilities;
|
|
30
|
+
canRenameUser: (user: AdminIdentityUser) => boolean;
|
|
31
|
+
};
|
|
32
|
+
export declare function useUsersRename({ port, queryScope, translate, canRenameUser, ownProfile }: UsersDependencies & ReturnType<typeof createUsersCapabilities>, { useChangeUsername }?: {
|
|
33
|
+
useChangeUsername?: typeof useChangeUsernameDefault;
|
|
34
|
+
}): {
|
|
35
|
+
changeUsername: import("./use-change-username.hooks.js").ChangeUsernameController;
|
|
36
|
+
canRenameOwnProfile: boolean;
|
|
37
|
+
openOwnRename: () => void;
|
|
38
|
+
renameUserHandler: ({ user }: {
|
|
39
|
+
user: AdminIdentityUser;
|
|
40
|
+
}, _options?: Record<string, never>) => ((target: AdminIdentityUser) => void) | undefined;
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=use-users-roster.hooks.d.ts.map
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { KEYS, isOwnerAccount, userAccountCapabilities } from "../rules.js";
|
|
3
|
+
import { useFetchQuery as useFetchQueryDefault } from "../../kit.js";
|
|
4
|
+
import { useChangeUsername as useChangeUsernameDefault } from "./use-change-username.hooks.js";
|
|
5
|
+
/**
|
|
6
|
+
* Roles and policies for the grant controls, or `null` when the server refuses them with 403 (the
|
|
7
|
+
* caller lacks `role.manage`). Any other failure still rejects, so a real outage keeps surfacing as
|
|
8
|
+
* the screen's load error.
|
|
9
|
+
*
|
|
10
|
+
* @complexity O(1) requests (two, concurrent).
|
|
11
|
+
*/
|
|
12
|
+
async function loadGrantOptions(port) {
|
|
13
|
+
try {
|
|
14
|
+
const [r, p] = await Promise.all([port.listRoles({}), port.listPolicies({})]);
|
|
15
|
+
return { roles: r.roles, policies: p.policies };
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
if (e && typeof e === "object" && "status" in e && e.status === 403)
|
|
19
|
+
return null;
|
|
20
|
+
throw e;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The combined read split into the controller's list fields: all `null` (and `canGrant` false)
|
|
25
|
+
* until the read settles, then `[]` roles/policies with `canGrant` false when `loadGrantOptions`
|
|
26
|
+
* reported a 403. Pure so `useUsers` stays a flat wiring list.
|
|
27
|
+
*/
|
|
28
|
+
function selectUsersList({ data }) {
|
|
29
|
+
if (!data)
|
|
30
|
+
return { users: null, roles: null, policies: null, canGrant: false };
|
|
31
|
+
const grantOptions = data.grantOptions;
|
|
32
|
+
return { users: data.users, roles: grantOptions?.roles ?? [], policies: grantOptions?.policies ?? [], canGrant: grantOptions != null };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The signed-in caller as the row-level permission checks see it: their own roster row (`null`
|
|
36
|
+
* while `me()` or the roster is unsettled, or when the caller is not in it), whether that row is an
|
|
37
|
+
* owner, and the role lookup both checks share. Computed once per render rather than once per row.
|
|
38
|
+
*
|
|
39
|
+
* @complexity O(users + roles) per render.
|
|
40
|
+
*/
|
|
41
|
+
function selectCaller({ users, roles, ownPrincipalId }) {
|
|
42
|
+
const roleMap = new Map((roles ?? []).map(role => [role.id, role]));
|
|
43
|
+
const ownProfile = users?.find(user => user.principalId === ownPrincipalId) ?? null;
|
|
44
|
+
return { roleMap, ownProfile, callerIsOwner: ownProfile !== null && isOwnerAccount({ user: ownProfile, roles: roleMap }) };
|
|
45
|
+
}
|
|
46
|
+
export function useUsersRoster({ port, translate, queryScope, describeError }, { useFetchQuery = useFetchQueryDefault } = {}) {
|
|
47
|
+
// `portRef` (password-banner plan, 2026-09-24 Slice 3 deep-link half): captured once at mount and
|
|
48
|
+
// never written again, same discipline and same reasoning as `use-assistant-chats.hooks.ts`'s own
|
|
49
|
+
// `portRef` — the one-shot `me()` effect below must not spin if a caller builds a fresh port object
|
|
50
|
+
// per render (the host admin guidance's "Two traps" section). Every OTHER `port.xxx()` call in this
|
|
51
|
+
// file stays a direct closure read, unaffected — this ref exists only for the raw `useEffect` below,
|
|
52
|
+
// which is not a `useFetchQuery`/`useFetchMutation` closure and so does not get that discipline for
|
|
53
|
+
// free.
|
|
54
|
+
const portRef = useRef(port);
|
|
55
|
+
const list = useFetchQuery({
|
|
56
|
+
key: [queryScope, ...KEYS.list],
|
|
57
|
+
fetch: async () => {
|
|
58
|
+
const [u, grantOptions] = await Promise.all([port.listUsers({}), loadGrantOptions(port)]);
|
|
59
|
+
return { users: u.users, grantOptions };
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
const { users, roles, policies, canGrant } = selectUsersList({ data: list.data });
|
|
63
|
+
const error = list.error ? describeError(list.error, translate("failed to load users")) : null;
|
|
64
|
+
return { portRef, users, roles, policies, canGrant, error };
|
|
65
|
+
}
|
|
66
|
+
export function useUsersCallerState({ portRef }, _optional = {}) {
|
|
67
|
+
/** The signed-in caller's own principal id (password-banner plan, 2026-09-24 Slice 3), from
|
|
68
|
+
* `port.me()`. `null` until that call settles, or forever if it fails — both are treated as
|
|
69
|
+
* "unknown", which the deep-link effect below and `confirmResetPassword`'s notice branch both
|
|
70
|
+
* already handle as "not a self-reset".
|
|
71
|
+
*
|
|
72
|
+
* Fetched unconditionally (not gated on `openOwnPasswordReset`) — a deliberate choice, not an
|
|
73
|
+
* oversight: it makes the "sign in again" notice below correct for ANY self-reset, including an
|
|
74
|
+
* admin resetting their OWN row from the ordinary row-menu (no deep link involved), not just the
|
|
75
|
+
* one opened via `/users/change-password`. One extra `me()` call per screen load is cheaper than
|
|
76
|
+
* threading two different notice code paths for what is, to the operator, the same event. */
|
|
77
|
+
const [ownPrincipalId, setOwnPrincipalId] = useState(null);
|
|
78
|
+
const [effectivePermissions, setEffectivePermissions] = useState([]);
|
|
79
|
+
// `canManageUserTrash` (delete-user plan v2, Slice 4): resolved by this SAME one-shot `me()` call
|
|
80
|
+
// rather than a second request — see `UsersController.canManageUserTrash`'s own doc comment.
|
|
81
|
+
const [canManageUserTrash, setCanManageUserTrash] = useState(false);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
let cancelled = false;
|
|
84
|
+
portRef.current
|
|
85
|
+
.me({})
|
|
86
|
+
.then((res) => {
|
|
87
|
+
if (!cancelled) {
|
|
88
|
+
setOwnPrincipalId(res.user.id);
|
|
89
|
+
setEffectivePermissions(res.effectivePermissions ?? []);
|
|
90
|
+
setCanManageUserTrash(res.canManageUserTrash);
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
.catch(() => {
|
|
94
|
+
// Best-effort, see `ownPrincipalId`'s own doc comment above — a failure just means the
|
|
95
|
+
// deep link can't auto-open and self-resets fall back to the per-username notice.
|
|
96
|
+
// `canManageUserTrash` stays `false`, the same "unknown means no affordance" default.
|
|
97
|
+
});
|
|
98
|
+
return () => {
|
|
99
|
+
cancelled = true;
|
|
100
|
+
};
|
|
101
|
+
}, []);
|
|
102
|
+
return { ownPrincipalId, effectivePermissions, canManageUserTrash };
|
|
103
|
+
}
|
|
104
|
+
export function createUsersCapabilities({ users, roles, ownPrincipalId, effectivePermissions, canManageUserTrash }) {
|
|
105
|
+
const { roleMap, ownProfile, callerIsOwner } = selectCaller({ users, roles, ownPrincipalId });
|
|
106
|
+
function rowCapabilities(user) {
|
|
107
|
+
return userAccountCapabilities({ user, callerPrincipalId: ownPrincipalId, callerIsOwner, canManageUserTrash, roles: roleMap });
|
|
108
|
+
}
|
|
109
|
+
function canRenameUser(user) {
|
|
110
|
+
if (user.canRename === false)
|
|
111
|
+
return false;
|
|
112
|
+
if (!ownPrincipalId || (!effectivePermissions.includes("*") && !effectivePermissions.includes("user.manage")))
|
|
113
|
+
return false;
|
|
114
|
+
// Server-supplied owner flags remain authoritative when role.manage is unavailable.
|
|
115
|
+
const targetIsOwner = user.isOwner ?? (user.roleIds.some(id => !roleMap.has(id)) || isOwnerAccount({ user, roles: roleMap }));
|
|
116
|
+
return !targetIsOwner || callerIsOwner;
|
|
117
|
+
}
|
|
118
|
+
return { ownProfile, rowCapabilities, canRenameUser };
|
|
119
|
+
}
|
|
120
|
+
export function useUsersRename({ port, queryScope, translate, canRenameUser, ownProfile }, { useChangeUsername = useChangeUsernameDefault } = {}) {
|
|
121
|
+
const changeUsername = useChangeUsername({ port, queryScope, translate, canRename: canRenameUser });
|
|
122
|
+
const canRenameOwnProfile = ownProfile !== null && canRenameUser(ownProfile);
|
|
123
|
+
/** Profile and row actions enter the same guarded dialog; the view only renders affordances. */
|
|
124
|
+
function openOwnRename() {
|
|
125
|
+
if (ownProfile)
|
|
126
|
+
changeUsername.open({ user: ownProfile });
|
|
127
|
+
}
|
|
128
|
+
function renameUserHandler({ user }, _options = {}) {
|
|
129
|
+
return canRenameUser(user) ? (target) => changeUsername.open({ user: target }) : undefined;
|
|
130
|
+
}
|
|
131
|
+
return { changeUsername, canRenameOwnProfile, openOwnRename, renameUserHandler };
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=use-users-roster.hooks.js.map
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { Translate } from "@jini-ai/core/text";
|
|
2
|
+
import type { UsersDependencies } from "./use-users.hooks.js";
|
|
3
|
+
import { useUsersRoster as useUsersRosterDefault, useUsersCallerState as useUsersCallerStateDefault, useUsersRename as useUsersRenameDefault } from "./use-users-roster.hooks.js";
|
|
4
|
+
import { useUsersCreationState as useUsersCreationStateDefault, useUsersGrantState as useUsersGrantStateDefault, useUsersStatusState as useUsersStatusStateDefault } from "./use-users-form-state.hooks.js";
|
|
5
|
+
export declare function createUsersErrorDescriber({ translate }: {
|
|
6
|
+
translate: Translate;
|
|
7
|
+
}, _optional?: Record<string, never>): (error: unknown, fallback: string) => string;
|
|
8
|
+
export declare function useUsersState(deps: UsersDependencies, { useUsersRoster, useUsersCreationState, useUsersGrantState, useUsersStatusState, useUsersCallerState, useUsersRename }?: {
|
|
9
|
+
useUsersRoster?: typeof useUsersRosterDefault;
|
|
10
|
+
useUsersCreationState?: typeof useUsersCreationStateDefault;
|
|
11
|
+
useUsersGrantState?: typeof useUsersGrantStateDefault;
|
|
12
|
+
useUsersStatusState?: typeof useUsersStatusStateDefault;
|
|
13
|
+
useUsersCallerState?: typeof useUsersCallerStateDefault;
|
|
14
|
+
useUsersRename?: typeof useUsersRenameDefault;
|
|
15
|
+
}): {
|
|
16
|
+
changeUsername: import("./use-change-username.hooks.js").ChangeUsernameController;
|
|
17
|
+
canRenameOwnProfile: boolean;
|
|
18
|
+
openOwnRename: () => void;
|
|
19
|
+
renameUserHandler: ({ user }: {
|
|
20
|
+
user: import("../../models.js").AdminIdentityUser;
|
|
21
|
+
}, _options?: Record<string, never>) => ((target: import("../../models.js").AdminIdentityUser) => void) | undefined;
|
|
22
|
+
ownProfile: import("../../models.js").AdminIdentityUser | null;
|
|
23
|
+
rowCapabilities: (user: import("../../models.js").AdminIdentityUser) => import("../rules.js").UserAccountCapabilities;
|
|
24
|
+
canRenameUser: (user: import("../../models.js").AdminIdentityUser) => boolean;
|
|
25
|
+
ownPrincipalId: string | null;
|
|
26
|
+
effectivePermissions: string[];
|
|
27
|
+
canManageUserTrash: boolean;
|
|
28
|
+
toggleSavingId: string | null;
|
|
29
|
+
setToggleSavingId: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
30
|
+
toggleError: string | null;
|
|
31
|
+
setToggleError: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
32
|
+
notice: string | null;
|
|
33
|
+
setNotice: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
34
|
+
toggleStatusMutation: import("@jini-ai/ui").MutationResult<import("../../models.js").AdminIdentityUser, {
|
|
35
|
+
user: import("../../models.js").AdminIdentityUser;
|
|
36
|
+
}>;
|
|
37
|
+
confirmingDisable: import("../../models.js").AdminIdentityUser | null;
|
|
38
|
+
setConfirmingDisable: import("react").Dispatch<import("react").SetStateAction<import("../../models.js").AdminIdentityUser | null>>;
|
|
39
|
+
resetPasswordFor: import("../../models.js").AdminIdentityUser | null;
|
|
40
|
+
setResetPasswordFor: import("react").Dispatch<import("react").SetStateAction<import("../../models.js").AdminIdentityUser | null>>;
|
|
41
|
+
newPassword: string;
|
|
42
|
+
setNewPassword: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
43
|
+
resetPassword: import("../../kit.js").AsyncActionState;
|
|
44
|
+
expandedId: string | null;
|
|
45
|
+
setExpandedId: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
46
|
+
toggleGenerationRef: import("react").RefObject<number>;
|
|
47
|
+
pendingRoleId: string;
|
|
48
|
+
setPendingRoleId: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
49
|
+
pendingPolicyId: string;
|
|
50
|
+
setPendingPolicyId: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
51
|
+
grantSaving: boolean;
|
|
52
|
+
setGrantSaving: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
53
|
+
grantError: string | null;
|
|
54
|
+
setGrantError: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
55
|
+
assignRoleMutation: import("@jini-ai/ui").MutationResult<{
|
|
56
|
+
principalId: string;
|
|
57
|
+
roleId: string;
|
|
58
|
+
}, {
|
|
59
|
+
assignment: unknown;
|
|
60
|
+
}>;
|
|
61
|
+
attachPolicyMutation: import("@jini-ai/ui").MutationResult<{
|
|
62
|
+
principalId: string;
|
|
63
|
+
policyId: string;
|
|
64
|
+
}, {
|
|
65
|
+
attachment: unknown;
|
|
66
|
+
}>;
|
|
67
|
+
editEmail: string;
|
|
68
|
+
setEditEmail: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
69
|
+
updateEmailMutation: import("@jini-ai/ui").MutationResult<{
|
|
70
|
+
principalId: string;
|
|
71
|
+
email: string;
|
|
72
|
+
}, {
|
|
73
|
+
user: import("../../models.js").AdminIdentityUser;
|
|
74
|
+
}>;
|
|
75
|
+
formOpen: boolean;
|
|
76
|
+
setFormOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
77
|
+
username: string;
|
|
78
|
+
setUsername: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
79
|
+
email: string;
|
|
80
|
+
setEmail: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
81
|
+
password: string;
|
|
82
|
+
setPassword: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
83
|
+
createUser: import("../../kit.js").AsyncActionState;
|
|
84
|
+
createUserMutation: import("@jini-ai/ui").MutationResult<{
|
|
85
|
+
username: string;
|
|
86
|
+
password: string;
|
|
87
|
+
email: string | undefined;
|
|
88
|
+
}, {
|
|
89
|
+
user: import("../../models.js").AdminIdentityUser;
|
|
90
|
+
}>;
|
|
91
|
+
portRef: import("react").RefObject<import("../../ports.js").UsersPort>;
|
|
92
|
+
users: import("../../models.js").AdminIdentityUser[] | null;
|
|
93
|
+
roles: import("../../models.js").AdminRole[] | null;
|
|
94
|
+
policies: import("../../models.js").AdminPolicy[] | null;
|
|
95
|
+
canGrant: boolean;
|
|
96
|
+
error: string | null;
|
|
97
|
+
describeError: (error: unknown, fallback: string) => string;
|
|
98
|
+
port: import("../../ports.js").UsersPort;
|
|
99
|
+
translate: Translate;
|
|
100
|
+
queryScope: string;
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=use-users-state.hooks.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { describeApiError } from "../rules.js";
|
|
2
|
+
import { useUsersRoster as useUsersRosterDefault, useUsersCallerState as useUsersCallerStateDefault, useUsersRename as useUsersRenameDefault } from "./use-users-roster.hooks.js";
|
|
3
|
+
import { createUsersCapabilities } from "./use-users-roster.hooks.js";
|
|
4
|
+
import { useUsersCreationState as useUsersCreationStateDefault, useUsersGrantState as useUsersGrantStateDefault, useUsersStatusState as useUsersStatusStateDefault } from "./use-users-form-state.hooks.js";
|
|
5
|
+
export function createUsersErrorDescriber({ translate }, _optional = {}) {
|
|
6
|
+
return (error, fallback) => describeApiError({ error, fallback, translate });
|
|
7
|
+
}
|
|
8
|
+
export function useUsersState(deps, { useUsersRoster = useUsersRosterDefault, useUsersCreationState = useUsersCreationStateDefault, useUsersGrantState = useUsersGrantStateDefault, useUsersStatusState = useUsersStatusStateDefault, useUsersCallerState = useUsersCallerStateDefault, useUsersRename = useUsersRenameDefault } = {}) {
|
|
9
|
+
const describeError = createUsersErrorDescriber({ translate: deps.translate });
|
|
10
|
+
const roster = useUsersRoster({ ...deps, describeError });
|
|
11
|
+
const creation = useUsersCreationState(deps);
|
|
12
|
+
const grant = useUsersGrantState(deps);
|
|
13
|
+
const status = useUsersStatusState(deps);
|
|
14
|
+
const caller = useUsersCallerState({ portRef: roster.portRef });
|
|
15
|
+
const capabilities = createUsersCapabilities({ ...roster, ...caller });
|
|
16
|
+
const rename = useUsersRename({ ...deps, ...capabilities });
|
|
17
|
+
return { ...deps, describeError, ...roster, ...creation, ...grant, ...status, ...caller, ...capabilities, ...rename };
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=use-users-state.hooks.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AdminIdentityUser } from "../../models.js";
|
|
2
|
+
import type { UsersController } from "./use-users.hooks.js";
|
|
3
|
+
import type { useUsersState } from "./use-users-state.hooks.js";
|
|
4
|
+
import { useFetchMutation as useFetchMutationDefault } from "../../kit.js";
|
|
5
|
+
export declare function createUsersToggleAction({ state }: {
|
|
6
|
+
state: ReturnType<typeof useUsersState>;
|
|
7
|
+
}, _optional?: Record<string, never>): (user: AdminIdentityUser) => Promise<void>;
|
|
8
|
+
export declare function createUsersDisableActions({ state, onToggleStatus }: {
|
|
9
|
+
state: ReturnType<typeof useUsersState>;
|
|
10
|
+
onToggleStatus: UsersController['onToggleStatus'];
|
|
11
|
+
}, _optional?: Record<string, never>): {
|
|
12
|
+
requestDisable: (user: AdminIdentityUser) => void;
|
|
13
|
+
confirmDisable: () => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
export declare function useUsersDeletion({ state }: {
|
|
16
|
+
state: ReturnType<typeof useUsersState>;
|
|
17
|
+
}, { useFetchMutation }?: {
|
|
18
|
+
useFetchMutation?: typeof useFetchMutationDefault;
|
|
19
|
+
}): {
|
|
20
|
+
deleteUserMutation: import("@jini-ai/ui").MutationResult<string, void>;
|
|
21
|
+
confirmingDelete: AdminIdentityUser | null;
|
|
22
|
+
setConfirmingDelete: import("react").Dispatch<import("react").SetStateAction<AdminIdentityUser | null>>;
|
|
23
|
+
requestDelete: (user: AdminIdentityUser) => void;
|
|
24
|
+
confirmDelete: () => Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=use-users-status.hooks.d.ts.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { KEYS } from "../rules.js";
|
|
3
|
+
import { useFetchMutation as useFetchMutationDefault } from "../../kit.js";
|
|
4
|
+
export function createUsersToggleAction({ state }, _optional = {}) {
|
|
5
|
+
const { rowCapabilities, setToggleSavingId, setToggleError, toggleStatusMutation, describeError, translate } = state;
|
|
6
|
+
/** `setToggleSavingId`'s `finally` reset (2026-09-05 fix, same bug class as
|
|
7
|
+
* `use-roles.hooks.ts`'s `onSaveRole`/`runRowDelete`) is a functional update keyed on THIS call's
|
|
8
|
+
* own `principalId`: Enable fires with no confirmation gate, so two calls — on different users —
|
|
9
|
+
* can genuinely overlap, and an unconditional reset would clear the busy indicator (which
|
|
10
|
+
* `openResetPassword` below reads to refuse opening while a toggle is in flight) out from under a
|
|
11
|
+
* still-in-flight, unrelated toggle. */
|
|
12
|
+
async function onToggleStatus(user) {
|
|
13
|
+
const capabilities = rowCapabilities(user);
|
|
14
|
+
if (user.status === "active" ? !capabilities.canDisable : !capabilities.canEnable)
|
|
15
|
+
return;
|
|
16
|
+
setToggleSavingId(user.principalId);
|
|
17
|
+
setToggleError(null);
|
|
18
|
+
try {
|
|
19
|
+
await toggleStatusMutation.mutate({ input: user });
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
setToggleError(describeError(e, translate("failed to change status")));
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
setToggleSavingId((current) => (current === user.principalId ? null : current));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return onToggleStatus;
|
|
29
|
+
}
|
|
30
|
+
export function createUsersDisableActions({ state, onToggleStatus }, _optional = {}) {
|
|
31
|
+
const { rowCapabilities, setToggleError, setConfirmingDisable, confirmingDisable } = state;
|
|
32
|
+
/** Opens the Disable confirm dialog for `user` — the `RowMenu` "Disable" item's `onSelect` when
|
|
33
|
+
* the user is currently active. Was an inline closure inside the old `rowMenuItems`; named here
|
|
34
|
+
* now that the item builder itself moved to `rules.ts` and needs a callback to hand it. */
|
|
35
|
+
function requestDisable(user) {
|
|
36
|
+
if (!rowCapabilities(user).canDisable)
|
|
37
|
+
return;
|
|
38
|
+
setToggleError(null);
|
|
39
|
+
setConfirmingDisable(user);
|
|
40
|
+
}
|
|
41
|
+
/** Confirms the Disable that `RowMenu`'s "Disable" item asked about. Closes the dialog either
|
|
42
|
+
* way (matching the host app's src/features/posts/Posts.tsx and packages/admin/src/redirects/react/pages/RedirectsPage.tsx's own Disable/Delete `ConfirmDialog` convention) — a
|
|
43
|
+
* failure surfaces via `toggleError` above the table, not by leaving the modal open.
|
|
44
|
+
*
|
|
45
|
+
* 2026-09-05 fix, same bug class as `use-roles.hooks.ts`'s `runRowDelete`: `setConfirmingDisable`
|
|
46
|
+
* is exposed directly on the controller, so nothing at the hook level stops the operator opening
|
|
47
|
+
* a DIFFERENT user's Disable confirmation while this one's toggle is still in flight. The close
|
|
48
|
+
* below only clears it when it still names the SAME user this call started for — otherwise a
|
|
49
|
+
* stale toggle's settlement would silently dismiss a newer, still-undecided confirmation. */
|
|
50
|
+
async function confirmDisable() {
|
|
51
|
+
if (!confirmingDisable)
|
|
52
|
+
return;
|
|
53
|
+
const user = confirmingDisable;
|
|
54
|
+
await onToggleStatus(user);
|
|
55
|
+
setConfirmingDisable((current) => (current?.principalId === user.principalId ? null : current));
|
|
56
|
+
}
|
|
57
|
+
return { requestDisable, confirmDisable };
|
|
58
|
+
}
|
|
59
|
+
export function useUsersDeletion({ state }, { useFetchMutation = useFetchMutationDefault } = {}) {
|
|
60
|
+
const { port, queryScope, rowCapabilities, setToggleError, describeError, translate } = state;
|
|
61
|
+
// Delete-user plan v2 (2026-09-24), Slice 4 — mirrors Disable's request/confirm pair above with
|
|
62
|
+
// its OWN state (see `confirmingDelete`'s own doc comment for why not shared). `deleteUserMutation`
|
|
63
|
+
// invalidates `KEYS.list` like every other write on this screen; the route already filters a newly
|
|
64
|
+
// trashed principal out of `listUsers()`, so the row disappears on the next render with no extra
|
|
65
|
+
// client-side bookkeeping.
|
|
66
|
+
const deleteUserMutation = useFetchMutation({
|
|
67
|
+
run: ({ input: principalId }) => port.deleteUser({ principalId })
|
|
68
|
+
}, {
|
|
69
|
+
invalidates: [[queryScope, ...KEYS.list]],
|
|
70
|
+
});
|
|
71
|
+
const [confirmingDelete, setConfirmingDelete] = useState(null);
|
|
72
|
+
function requestDelete(user) {
|
|
73
|
+
if (!rowCapabilities(user).canDelete)
|
|
74
|
+
return;
|
|
75
|
+
setToggleError(null);
|
|
76
|
+
setConfirmingDelete(user);
|
|
77
|
+
}
|
|
78
|
+
/** Confirms the Delete that `RowMenu`'s "Delete" item asked about. Closes the dialog either way
|
|
79
|
+
* (matching `confirmDisable`'s and the host app's src/features/posts/Posts.tsx and packages/admin/src/redirects/react/pages/RedirectsPage.tsx's own Delete `ConfirmDialog`
|
|
80
|
+
* convention) — a failure surfaces via `toggleError` above the table, not by leaving the modal
|
|
81
|
+
* open. Same stale-call guard as `confirmDisable`: only clears `confirmingDelete` when it still
|
|
82
|
+
* names the SAME user this call started for. */
|
|
83
|
+
async function confirmDelete() {
|
|
84
|
+
if (!confirmingDelete || !rowCapabilities(confirmingDelete).canDelete)
|
|
85
|
+
return;
|
|
86
|
+
const user = confirmingDelete;
|
|
87
|
+
try {
|
|
88
|
+
await deleteUserMutation.mutate({ input: user.principalId });
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
setToggleError(describeError(e, translate("failed to delete user")));
|
|
92
|
+
}
|
|
93
|
+
setConfirmingDelete((current) => (current?.principalId === user.principalId ? null : current));
|
|
94
|
+
}
|
|
95
|
+
return { deleteUserMutation, confirmingDelete, setConfirmingDelete, requestDelete, confirmDelete };
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=use-users-status.hooks.js.map
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Dispatch, FormEvent, SetStateAction } from "react";
|
|
2
2
|
import type { AdminIdentityUser, AdminPolicy, AdminRole } from "../../models.js";
|
|
3
|
-
import { type Translate } from "@jini-ai/ui/panel-kit";
|
|
4
|
-
import { type UserAccountCapabilities } from "../rules.js";
|
|
5
3
|
import type { UsersPort } from "../../ports.js";
|
|
6
|
-
import {
|
|
4
|
+
import type { Translate } from "@jini-ai/core/text";
|
|
5
|
+
import type { UserAccountCapabilities } from "../rules.js";
|
|
6
|
+
import type { useChangeUsername } from "./use-change-username.hooks.js";
|
|
7
|
+
import { useUsersState as useUsersStateDefault } from "./use-users-state.hooks.js";
|
|
8
|
+
import { useUsersPasswordLink as useUsersPasswordLinkDefault, useUsersResetMutation as useUsersResetMutationDefault } from "./use-users-password.hooks.js";
|
|
9
|
+
import { useUsersDeletion as useUsersDeletionDefault } from "./use-users-status.hooks.js";
|
|
7
10
|
/**
|
|
8
11
|
* @file Everything the Users screen does, so `Users.tsx` is only markup.
|
|
9
12
|
*
|
|
@@ -199,5 +202,10 @@ export interface UsersOptions {
|
|
|
199
202
|
* @param deps - Injected collaborators; production callers get these from {@link useWiredUsers}.
|
|
200
203
|
* @returns The full `UsersController` the view renders from — see that interface for every field.
|
|
201
204
|
*/
|
|
202
|
-
export declare function useUsers({ port, translate, queryScope }: UsersDependencies, { openOwnPasswordReset, onOwnPasswordResetClosed, passwordResetNotice, }?: UsersOptions
|
|
205
|
+
export declare function useUsers({ port, translate, queryScope }: UsersDependencies, { openOwnPasswordReset, onOwnPasswordResetClosed, passwordResetNotice, useUsersState, useUsersPasswordLink, useUsersResetMutation, useUsersDeletion, }?: UsersOptions & {
|
|
206
|
+
useUsersState?: typeof useUsersStateDefault;
|
|
207
|
+
useUsersPasswordLink?: typeof useUsersPasswordLinkDefault;
|
|
208
|
+
useUsersResetMutation?: typeof useUsersResetMutationDefault;
|
|
209
|
+
useUsersDeletion?: typeof useUsersDeletionDefault;
|
|
210
|
+
}): UsersController;
|
|
203
211
|
//# sourceMappingURL=use-users.hooks.d.ts.map
|