Class UserManager

UserManager class handles all user related operations such as adding, getting, updating, deleting, listing users and their sessions. It uses the IZepClient interface to make requests to the server.

Constructors

Properties

client: IZepClient

Methods

  • Add a new user.

    Parameters

    Returns Promise<User>

    A Promise that resolves to a User object.

    Throws

    If the request fails.

  • Delete a user by their ID.

    Parameters

    • userId: string

      The ID of the user to be deleted.

    Returns Promise<string>

    A Promise that resolves to a string message confirming deletion.

    Throws

    If the request no user is found for the given ID.

    Throws

    If the request fails.

  • Get a user by their ID.

    Parameters

    • userId: string

      The ID of the user to be retrieved.

    Returns Promise<User>

    A Promise that resolves to a User object.

    Throws

    If the request no user is found for the given ID.

    Throws

    If the request fails.

  • Get all sessions for a user.

    Parameters

    • userId: string

      The ID of the user to retrieve sessions for.

    Returns Promise<Session[]>

    A Promise that resolves to an array of Session objects.

    Throws

    If no sessions are found for the given user ID.

    Throws

    If the request fails.

  • List all users.

    Parameters

    • Optional limit: number

      The maximum number of users to return.

    • Optional cursor: number

      The index to start listing users from.

    Returns Promise<User[]>

    A Promise that resolves to an array of User objects.

    Throws

    If the request fails.

  • List users in chunks.

    This method retrieves users in chunks of a specified size. It is a generator function that yields each chunk of users as they are retrieved.

    Parameters

    • chunkSize: number = 100

      The size of the user chunks to retrieve. Defaults to 100.

    Returns AsyncGenerator<User[], void, unknown>

    Yields

    A Promise that resolves to an array of User objects.

    Throws

    If the request fails.

  • Update a user's details.

    Parameters

    Returns Promise<User>

    A Promise that resolves to a User object with the updated details.

    Throws

    If the request no user is found for the given ID.

    Throws

    If the request fails.