@inweb/client
Version:
JavaScript REST API client for the Open Cloud Server
227 lines (226 loc) • 7.82 kB
TypeScript
import { IHttpClient } from "./IHttpClient";
import { Endpoint } from "./Endpoint";
/**
* Provides properties and methods for obtaining information about a Open Cloud Server user and manage
* its data.
*/
export declare class User extends Endpoint {
private _data;
/**
* @param data - Raw user data received from the server. For more information, see
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Users | Open Cloud Users API}.
* @param httpClient - HTTP client instance used to send requests to the REST API server.
*/
constructor(data: any, httpClient: IHttpClient);
/**
* User avatar image URL or empty string if the user does not have an avatar. Use
* {@link setAvatar | setAvatar()} to change avatar image.
*
* @readonly
*/
get avatarUrl(): string;
/**
* `true` if user is allowed to create a projects.
*
* Only administrators can change create project permission.
*/
get canCreateProject(): boolean;
set canCreateProject(value: boolean);
/**
* Account registration time (UTC) in the format specified in
* {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
*
* @readonly
*/
get createAt(): string;
/**
* User custom fields object, to store custom data.
*/
get customFields(): any;
set customFields(value: any);
/**
* Raw user data received from the server. For more information, see
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Users | Open Cloud Users API}.
*
* @readonly
*/
get data(): any;
private set data(value);
/**
* User email.
*/
get email(): string;
set email(value: string);
/**
* The user's email confirmation code, or an empty string if the email has already been confirmed.
*
* To send the confirmation code to the server, use
* {@link Client.confirmUserEmail | Client.confirmUserEmail()}.
*
* @readonly
*/
get emailConfirmationId(): string;
/**
* First name.
*/
get firstName(): string;
set firstName(value: string);
/**
* Full name. Returns the user's first and last name. If first name and last names are empty, returns
* the user name.
*
* @readonly
*/
get fullName(): string;
/**
* Unique user ID.
*
* @readonly
*/
get id(): string;
/**
* User initials. Returns a first letters of the user's first and last names. If first name and last
* names are empty, returns the first letter of the user name.
*
* @readonly
*/
get initials(): string;
/**
* `true` if user is an administrator.
*
* Only administrators can change user type.
*/
get isAdmin(): boolean;
set isAdmin(value: boolean);
/**
* `false` if the user has not yet confirmed his email address.
*
* @readonly
*/
get isEmailConfirmed(): boolean;
/**
* User last update time (UTC) in the format specified in
* {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
*/
get lastModified(): string;
/**
* Last name.
*/
get lastName(): string;
set lastName(value: string);
/**
* User last sign in time (UTC) in the format specified in
* {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
*/
get lastSignIn(): string;
/**
* The maximum number of projects that a user can create.
*
* Only administrators can change projects limit.
*/
get projectsLimit(): number;
set projectsLimit(value: number);
/**
* The identity provider used to create the account. Can be `ldap`, `oauth`, `saml` or empty for local
* accounts.
*
* @readonly
*/
get providerType(): string;
/**
* User storage size on the server for uploading files.
*
* Only administrators can change storage size.
*/
get storageLimit(): number;
set storageLimit(value: number);
/**
* The total size of the user's files in the storage.
*
* @readonly
*/
get storageUsed(): number;
/**
* The user's access token (API key). Use {@link Client.signInWithToken | Client.signInWithToken()} to
* sign in to the server using this token.
*
* @readonly
*/
get token(): string;
/**
* User name.
*/
get userName(): string;
set userName(value: string);
/**
* Reloads user data from the server.
*
* Only administrators can checkout other users. If the current logged in user is not an administrator,
* they can only checkout themselves, otherwise an exception will be thrown.
*/
checkout(): Promise<this>;
/**
* Updates user data on the server.
*
* Only administrators can update other users. If the current logged in user is not an administrator,
* they can only update themself, otherwise an exception will be thrown.
*
* @param data - Raw user data. For more information, see
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Users | Open Cloud Users API}.
*/
update(data: any): Promise<this>;
/**
* Deletes a user from the server.
*
* Only administrators can delete users. If the current logged in user is not an administrator, an
* exception will be thrown.
*
* Administrators can delete themselves or other administrators. An administrator can only delete
* themself if they is not the last administrator.
*
* You need to re-login after deleting the current logged in user.
*
* @returns Returns the raw data of a deleted user. For more information, see
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Users | Open Cloud Users API}.
*/
delete(): Promise<any>;
/**
* Saves user properties changes to the server. Call this method to update user data on the server
* after any property changes.
*/
save(): Promise<this>;
/**
* Sets or removes the user avatar.
*
* Only administrators can set the avatar of other users. If the current logged in user is not an
* administrator, they can only set their avatar, otherwise an exception will be thrown.
*
* @param image - Avatar image. Can be a
* {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL} string,
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
* {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob} or
* {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object. Setting the `image`
* to `null` will remove the avatar.
*/
setAvatar(image?: BodyInit | null): Promise<this>;
/**
* Removes the user avatar.
*
* Only administrators can remove the avatar of other users. If the current logged in user is not an
* administrator, they can only remove their avatar, otherwise an exception will be thrown.
*/
deleteAvatar(): Promise<this>;
/**
* Changes the user password.
*
* Only administrators can change the passwords of other users. If the current logged in user is not an
* administrator, they can only change their password, otherwise an exception will be thrown.
*
* To change their password, non-administrator users must specify their old password.
*
* @param newPassword - New user password.
* @param oldPassword - Old user password. Only required for non-administrator users to change their
* password.
*/
changePassword(newPassword: string, oldPassword?: string): Promise<this>;
}