UNPKG

@inweb/client

Version:

JavaScript REST API client for the Open Cloud Server

93 lines (92 loc) 3.49 kB
import { IHttpClient } from "./IHttpClient"; import { Endpoint } from "./Endpoint"; import { IGrantedTo } from "./IFile"; /** * Provides properties and methods for obtaining information about {@link File | file} actions granted to * a specific user, project, or group. */ export declare class Permission extends Endpoint { private _data; /** * @param data - Raw permission data received from the server. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Permission | Open Cloud Permissions API}. * @param fileId - Owner file ID. * @param httpClient - HTTP client instance used to send requests to the REST API server. */ constructor(data: any, fileId: string, httpClient: IHttpClient); /** * Defines what actions are allowed to be performed on a file with this permission: * * - `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. * * @example Change file permissions for the the specified project. * * ```javascript * const myFile = client.getFile(myFileId); * const permissions = await myFile.getPermissions(); * const projectPermissions = permissions.filter((permission) => * permission.grantedTo.some((x) => x.project?.id === myProjectId) * ); * const newActions = ["read", "readSourceFile", "update"]; * await Promise.all( * projectPermissions.map((permission) => { * permission.actions = newActions; * return permission.save(); * }) * ); * ``` */ get actions(): string[]; set actions(value: string[]); /** * Raw permission data received from the server. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Permission | Open Cloud Permissions API}. * * @readonly */ get data(): any; private set data(value); /** * Unique permission ID. * * @readonly */ get id(): string; /** * A list of users, projects, or groups that will get access to the file. */ get grantedTo(): IGrantedTo[]; set grantedTo(value: IGrantedTo[]); /** * Specifies whether all users have access to the file or not. */ get public(): boolean; set public(value: boolean); /** * Reloads permission data from the server. */ checkout(): Promise<this>; /** * Updates permission data on the server. * * @param data - Raw permission data. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Permission | Open Cloud Permissions API}. */ update(data: any): Promise<this>; /** * Removes a permission from the file. * * @returns Returns the raw data of a deleted permission. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Permission | Open Cloud Permissions API}. */ delete(): Promise<any>; /** * Saves permission properties changes to the server. Call this method to update permission data on the * server after any property changes. */ save(): Promise<this>; }