/** * Account Manager user management operations. * * This module provides high-level functions for managing users in Account Manager, * including CRUD operations, role management, and user lifecycle operations. * * ## Core User Functions * * - {@link getUser} - Get user details by ID * - {@link getUserByLogin} - Get user details by login (email) * - {@link listUsers} - List users with pagination * - {@link createUser} - Create a new user * - {@link updateUser} - Update an existing user * - {@link deleteUser} - Disable a user (soft delete) * - {@link purgeUser} - Purge a disabled user (hard delete) * - {@link resetUser} - Reset a user to INITIAL state * * ## Usage * * ```typescript * import { * getUserByLogin, * listUsers, * createUser, * grantRole, * } from '@salesforce/b2c-tooling-sdk/operations/users'; * import { createAccountManagerUsersClient } from '@salesforce/b2c-tooling-sdk/clients'; * import { OAuthStrategy } from '@salesforce/b2c-tooling-sdk/auth'; * * const auth = new OAuthStrategy({ * clientId: 'your-client-id', * clientSecret: 'your-client-secret', * }); * * const client = createAccountManagerUsersClient({}, auth); * * // Get a user by login * const user = await getUserByLogin(client, 'user@example.com'); * * // List users * const users = await listUsers(client, { size: 25, page: 0 }); * * // Create a new user * const newUser = await createUser(client, { * mail: 'newuser@example.com', * firstName: 'John', * lastName: 'Doe', * organizations: ['org-id'], * primaryOrganization: 'org-id', * }); * ``` * * ## Authentication * * User operations require OAuth authentication with appropriate Account Manager permissions. * * @module operations/users */ import type { AccountManagerUsersClient, AccountManagerUser, UserCreate, UserUpdate } from '../../clients/am-api.js'; import { getUser, listUsers, deleteUser, purgeUser, resetUser } from '../../clients/am-api.js'; /** * Options for creating a user. */ export interface CreateUserOptions { /** User details */ user: UserCreate; } /** * Options for updating a user. */ export interface UpdateUserOptions { /** User ID */ userId: string; /** Changes to apply */ changes: UserUpdate; } /** * Options for granting a role. * * The AM API uses mixed formats: role IDs (e.g. 'bm-admin') in the `roles` array, * and roleEnumNames (e.g. 'ECOM_ADMIN') in the `roleTenantFilter` string. * Both must be provided. Use `resolveToInternalRole` / `resolveFromInternalRole` to convert. */ export interface GrantRoleOptions { /** User ID */ userId: string; /** Role ID as used in the roles array (e.g. 'bm-admin'). */ role: string; /** Role enum name as used in roleTenantFilter (e.g. 'ECOM_ADMIN'). */ roleEnumName: string; /** Optional scope for the role (tenant IDs, comma-separated) */ scope?: string; } /** * Options for revoking a role. * * See {@link GrantRoleOptions} for details on the mixed role ID formats. */ export interface RevokeRoleOptions { /** User ID */ userId: string; /** Role ID as used in the roles array (e.g. 'bm-admin'). */ role: string; /** Role enum name as used in roleTenantFilter (e.g. 'ECOM_ADMIN'). */ roleEnumName: string; /** Optional scope to remove (if not provided, removes entire role) */ scope?: string; } export { getUser, listUsers, deleteUser, purgeUser, resetUser }; /** * Retrieves details of a user by login (email). * This searches through paginated results to find the user. * * @param client - Account Manager client * @param login - User login (email) * @returns User details * @throws Error if user is not found */ export declare function getUserByLogin(client: AccountManagerUsersClient, login: string): Promise; /** * Creates a new user. * * @param client - Account Manager client * @param options - Create options (user details) * @returns Created user */ export declare function createUser(client: AccountManagerUsersClient, options: CreateUserOptions): Promise; /** * Updates an existing user. * * @param client - Account Manager client * @param options - Update options (userId, changes) * @returns Updated user */ export declare function updateUser(client: AccountManagerUsersClient, options: UpdateUserOptions): Promise; /** * Grants a role to a user, optionally with scope. * This updates the user's roles and roleTenantFilter. * * @param client - Account Manager client * @param options - Grant options (userId, role, optional scope) * @returns Updated user */ export declare function grantRole(client: AccountManagerUsersClient, options: GrantRoleOptions): Promise; /** * Revokes a role from a user, optionally removing specific scope. * * @param client - Account Manager client * @param options - Revoke options (userId, role, optional scope) * @returns Updated user */ export declare function revokeRole(client: AccountManagerUsersClient, options: RevokeRoleOptions): Promise; export type { AccountManagerUser, UserCreate, UserUpdate, UserCollection } from '../../clients/am-api.js';