UNPKG

@inweb/client

Version:

JavaScript REST API client for the Open Cloud Server

267 lines (266 loc) 9.39 kB
import { IHttpClient } from "./IHttpClient"; import { Endpoint } from "./Endpoint"; import { IShortUserDesc } from "./IUser"; import { Role } from "./Role"; import { IRoleActions } from "./IRole"; import { Member } from "./Member"; import { File } from "./File"; /** * Provides properties and methods for obtaining information about a project on the Open Cloud Server and * managing its {@link Role | roles}, {@link Member | members} and models. */ export declare class Project extends Endpoint { private _data; /** * @param data - Raw project data received from the server. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}. * @param httpClient - HTTP client instance used to send requests to the REST API server. */ constructor(data: any, httpClient: IHttpClient); /** * Project features the user has access to. * * @readonly */ get authorization(): { /** * Actions are allowed to be performed: * * - `update` - The ability to update the project details. * - `createTopic` - The ability to create a new topic. * - `createDocument` - The ability to create a new document. */ project_actions: string[]; }; /** * Project creation time (UTC) in the format specified in * {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}. * * @readonly */ get createdAt(): string; /** * Project custom fields object, to store custom data. */ get customFields(): any; set customFields(value: any); /** * Raw project data received from the server. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}. * * @readonly */ get data(): any; private set data(value); /** * Project description. */ get description(): string; set description(value: string); /** * Project end date in the format specified in * {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}. */ get endDate(): string; set endDate(value: string | Date); /** * Unique project ID. * * @readonly */ get id(): string; /** * The number of members in the project. * * @readonly */ get memberCount(): number; /** * The number of models in the project. * * @readonly */ get modelCount(): number; /** * Project name. */ get name(): string; set name(value: string); /** * Project owner information. * * @readonly */ get owner(): IShortUserDesc; /** * Project preview image URL or empty string if the project does not have a preview. Use * {@link Project.setPreview | setPreview()} to change preview image. * * @readonly */ get previewUrl(): string; /** * `true` if project is shared project. */ get public(): boolean; set public(value: boolean); /** * Project start date in the format specified in * {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}. */ get startDate(): string; set startDate(value: string | Date); /** * The number of topics in the project. * * @readonly */ get topicCount(): number; /** * Project last update time (UTC) in the format specified in * {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}. * * @readonly */ get updatedAt(): string; /** * Reloads project data from the server. */ checkout(): Promise<this>; /** * Updates project data on the server. * * @param data - Raw project data. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}. */ update(data: any): Promise<this>; /** * Deletes a project from the server. * * @returns Returns the raw data of a deleted project. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}. */ delete(): Promise<any>; /** * Saves project properties changes to the server. Call this method to update project data on the * server after any property changes. */ save(): Promise<this>; /** * Sets or removes the project preview. * * @param image - Preview 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 preview. */ setPreview(image?: BodyInit | null): Promise<this>; /** * Removes the project preview. */ deletePreview(): Promise<this>; /** * Returns a list of project roles. Project members have different abilities depending on the role they * have in a project. */ getRoles(): Promise<Role[]>; /** * Returns information about the specified project role. * * @param name - Role name. */ getRole(name: string): Promise<Role>; /** * Creates a new project role. * * @param name - Role name. * @param description - Role description. * @param permissions - Actions are allowed to be performed for the role. */ createRole(name: string, description: string, permissions: IRoleActions): Promise<Role>; /** * Deletes the specified project role. * * @param name - Role name. * @returns Returns the raw data of a deleted role. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}. */ deleteRole(name: string): Promise<any>; /** * Returns a list of project members. */ getMembers(): Promise<Member[]>; /** * Returns information about the specified project member. * * @param memberId - Member ID. */ getMember(memberId: string): Promise<Member>; /** * Adds a user to the project to become a member and have permission to perform actions. * * @param userId - User ID. * @param role - Role name from the list of project {@link getRoles | roles}. */ addMember(userId: string, role: string): Promise<Member>; /** * Removes the specified member from a project. * * @param memberId - Member ID. * @returns Returns the raw data of a deleted member. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}. */ removeMember(memberId: string): Promise<any>; /** * Information about the file (model) that can be reference in the project topics. * * @typedef {any} FileInformation * @property {any[]} display_information - The list of fields to allow users to associate the file with * a server model. * @property {string} display_information.field_display_name - Field display name. * @property {string} display_information.field_value - Field value. * @property {any} file - The file reference object. * @property {string} file.file_name - File name. * @property {string} file.reference - File ID. */ /** * Returns a list of project files. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/bcf3.html#ProjectFilesInformation | Open Cloud BCF3 API}. * * This list contains all files that the project has access to. To add a file to this list, create a * {@link IGrantedTo.project | project} permission on the file using * {@link File.createPermission | File.createPermission()}. */ getFilesInformation(): Promise<any[]>; /** * Returns a list of project files. */ getModels(): Promise<File[]>; /** * Adds a file to the project with specified permissions. * * To change file permissions for the project use {@link Permission.actions}. * * @param fileId - File ID. * @param actions - Actions are allowed to be performed on a file: * * - `read` - The ability to read file description, geometry data and properties. * - `readSourceFile` - The ability to download source file. * - `write` - The ability to modify file name, description and references. * - `readViewpoint` - The ability to read file viewpoints. * - `createViewpoint` - The ability to create file viewpoints. * * @param _public - Specifies whether all users have access to the file or not. * @returns Returns a file instance added to the project. */ addModel(fileId: string, actions: string | string[], _public: boolean): Promise<File>; /** * Removes the specified file from a project. * * @param fileId - File ID. * @returns Returns a file instance removed from the project. */ removeModel(fileId: string): Promise<File>; }