UNPKG

@inweb/client

Version:

JavaScript REST API client for the Open Cloud Server

387 lines (386 loc) 16.1 kB
import { IHttpClient } from "./IHttpClient"; import { Endpoint } from "./Endpoint"; import { ICdaNode, IFileReferences } from "./IFile"; import { IAssociatedFileData, IAssemblyVersionInfo, IModelTransformMatrix } from "./IAssembly"; import { IShortUserDesc } from "./IUser"; import { Model } from "./Model"; import { ClashTest } from "./ClashTest"; import { ISharedLinkPermissions } from "./ISharedLink"; import { SharedLink } from "./SharedLink"; /** * Provides properties and methods for obtaining information about an assembly on the Open Cloud Server * and managing its data. */ export declare class Assembly extends Endpoint { private _data; /** * @param data - Raw assembly data received from the server. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}. * @param httpClient - HTTP client instance used to send requests to the REST API server. */ constructor(data: any, httpClient: IHttpClient); get activeVersion(): number; /** * List of unique files from which the assembly was created. * * @readonly */ get associatedFiles(): IAssociatedFileData[]; /** * Assembly creation time (UTC) in the format specified in * {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}. * * @readonly */ get created(): string; /** * Returns the raw assembly data received from the server. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}. */ get data(): any; private set data(value); /** * List of file IDs from which the assembly was created. * * @readonly */ get files(): string[]; /** * Assembly geometry data type: * * - `vsfx` - `VSFX` format, assembly can be opened in `VisualizeJS` viewer. * * Returns an empty string if the geometry data is not yet ready. */ get geometryType(): string; /** * Unique assembly ID. * * @readonly */ get id(): string; /** * Assembly name. */ get name(): string; set name(value: string); get originalAssemblyId(): string; /** * Assembly owner information. * * @readonly */ get owner(): IShortUserDesc; get previewUrl(): string; /** * List of assembly related job IDs. * * @readonly */ get relatedJobs(): string[]; /** * Assembly geometry data and properties status. Can be `waiting`, `inprogress`, `done` or `failed`. * * An assemblies without geometry data cannot be opened in viewer. * * @readonly */ get status(): string; /** * Assembly type. Returns an `assembly` string. * * @readonly */ get type(): string; get version(): number; get versions(): IAssemblyVersionInfo[]; /** * Reloads assembly data from the server. */ checkout(): Promise<this>; /** * Updates assembly data on the server. * * @param data - Raw assembly data. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}. */ update(data: any): Promise<this>; /** * Deletes an assembly from the server. * * @returns Returns the raw data of a deleted assembly. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}. */ delete(): Promise<any>; /** * Saves assembly properties changes to the server. Call this method to update assembly data on the * server after any property changes. */ save(): Promise<this>; setPreview(image?: BodyInit | null): Promise<this>; deletePreview(): Promise<this>; /** * Returns list of assembly models. */ getModels(): Promise<Model[]>; /** * Returns a model transformation. * * @param handle - Model original handle. */ getModelTransformMatrix(handle: string): IModelTransformMatrix; /** * Sets or removes a model transformation. * * @param handle - Model original handle. * @param transform - Transformation matrix. Specify `undefined` to remove transformation. */ setModelTransformMatrix(handle: string, transform?: IModelTransformMatrix): Promise<this>; /** * Object properties. * * @typedef {any} Properties * @property {string} handle - Object original handle. * @property {string | any} * - Object property. Can be `any` for nested properties. */ /** * Returns the properties for an objects in the assembly. * * @param handles - Object original handle or handles array. Specify `undefined` to get properties for * all objects in the assembly. */ getProperties(handles?: string | string[]): Promise<any[]>; /** * Returns the list of original handles for an objects in the file that match the specified patterns. * Search patterns may be combined using query operators. * * @example Simple search pattern. * * ```javascript * searchPattern = { * key: "Category", * value: "OST_Stairs", * }; * ``` * * @example Search patterns combination. * * ```javascript * searchPattern = { * $or: [ * { * $and: [ * { key: "Category", value: "OST_GenericModel" }, * { key: "Level", value: "03 - Floor" }, * ], * }, * { key: "Category", value: "OST_Stairs" }, * ], * }; * ``` * * @param searchPattern - Search pattern or combination of the patterns, see example below. */ searchProperties(searchPattern: any): Promise<any[]>; /** * Returns the CDA tree for an assembly. */ getCdaTree(): Promise<ICdaNode[]>; /** * Returns a list of assembly viewpoints. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#AssemblyViewpoints | Open Cloud Assembly Viewpoints API}. */ getViewpoints(): Promise<any[]>; /** * Saves a new assembly viewpoint to the server. To create a viewpoint use `Viewer.createViewpoint()`. * * @param viewpoint - Viewpoint object. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#AssemblyViewpoints | Open Cloud Assembly Viewpoints API}. */ saveViewpoint(viewpoint: any): Promise<any>; /** * Deletes the specified assembly viewpoint. * * @param guid - Viewpoint GUID. * @returns Returns a deleted viewpoint. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#AssemblyViewpoints | Open Cloud Assembly Viewpoints API}. */ deleteViewpoint(guid: string): Promise<any>; /** * Returns the viewpoint snapshot as base64-encoded * {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL}. * * @param guid - Viewpoint GUID. */ getSnapshot(guid: string): Promise<string>; /** * Returns the viewpoint snapshot data. * * @param guid - Viewpoint GUID. * @param bitmapGuid - Bitmap GUID. */ getSnapshotData(guid: string, bitmapGuid: string): Promise<string>; /** * Downloads an assembly resource file. Resource files are files that contain model scene descriptions, * or geometry data. * * @param dataId - Resource file name. * @param onProgress - Download progress callback. * @param signal - An * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} signal. Allows * to communicate with a fetch request and abort it if desired. */ downloadResource(dataId: string, onProgress?: (progress: number, chunk: Uint8Array) => void, signal?: AbortSignal): Promise<ArrayBuffer>; /** * Downloads a part of assembly resource file. Resource files are files that contain model scene * descriptions, or geometry data. * * @param dataId - Resource file name. * @param ranges - A range of resource file contents to download. * @param requestId - Request ID for download progress callback. * @param onProgress - Download progress callback. * @param signal - An * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} signal. Allows * to communicate with a fetch request and abort it if desired. */ downloadResourceRange(dataId: string, requestId: number, ranges: Array<{ begin: number; end: number; requestId: number; }>, onProgress?: (progress: number, chunk: Uint8Array, requestId: number) => void, signal?: AbortSignal): Promise<ArrayBuffer>; /** * Deprecated since `25.3`. Use {@link downloadResource | downloadResource()} instead. * * @deprecated */ partialDownloadResource(dataId: string, onProgress?: (progress: number, chunk: Uint8Array) => void, signal?: AbortSignal): Promise<ArrayBuffer>; /** * Deprecated since `25.3`. Use {@link downloadResourceRange | downloadResourceRange()} instead. */ downloadFileRange(requestId: number, records: any | null, dataId: string, onProgress?: (progress: number, chunk: Uint8Array, requestId: number) => void, signal?: AbortSignal): Promise<void>; /** * Returns a list of assembly references containing references from all the files from which the * assembly was created. * * References are images, fonts, or any other files to correct rendering of the assembly. * * @param signal - An * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} signal, which * can be used to abort waiting as desired. */ getReferences(signal?: AbortSignal): Promise<IFileReferences>; /** * Waits for assembly to be created. Assembly is created when it changes to `done` or `failed` status. * * @param params - An object containing waiting parameters. * @param params.timeout - The time, in milliseconds that the function should wait assembly. If * assembly is not created during this time, the `TimeoutError` exception will be thrown. * @param params.interval - The time, in milliseconds, the function should delay in between checking * assembly status. * @param params.signal - An * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} signal, which * can be used to abort waiting as desired. * @param params.onCheckout - Waiting progress callback. Return `true` to cancel waiting. */ waitForDone(params?: { timeout?: number; interval?: number; signal?: AbortSignal; onCheckout?: (assembly: Assembly, ready: boolean) => boolean; }): Promise<this>; /** * Returns a list of assembly clash tests. * * @param start - The starting index in the test list. Used for paging. * @param limit - The maximum number of tests that should be returned per request. Used for paging. * @param name - Filter the tests by part of the name. Case sensitive. * @param ids - List of tests IDs to return. * @param sortByDesc - Allows to specify the descending order of the result. By default tests are * sorted by name in ascending order. * @param sortField - Allows to specify sort field. */ getClashTests(start?: number, limit?: number, name?: string, ids?: string | string[], sortByDesc?: boolean, sortField?: string): Promise<{ allSize: number; start: number; limit: number; result: ClashTest[]; size: number; }>; /** * Returns information about the specified assembly clash test. * * @param testId - Test ID. */ getClashTest(testId: string): Promise<ClashTest>; /** * Creates an assembly clash test. Assembly must be in a `done` state, otherwise the test will fail. * * @param name - Test name. * @param selectionTypeA - The type of first selection set for clash detection. Can be one of: * * - `all` - All file/assembly objects. * - `handle` - Objects with original handles specified in the `selectionSetA`. * - `models` - All objects of the models with original handles specified in the `selectionSetA`. * - `searchquery` - Objects retrieved by the search queries specified in `selectionSetA`. * * @param selectionTypeB - The type of second selection set for clash detection. Can be one of: * * - `all` - All file/assembly objects. * - `handle` - Objects with original handles specified in the `selectionSetB`. * - `models` - All objects of the models with original handles specified in the `selectionSetB`. * - `searchquery` - Objects retrieved by the search queries specified in `selectionSetB`. * * @param selectionSetA - First selection set for clash detection. Objects from `selectionSetA` will be * tested against each others by objects from the `selectionSetB` during the test. * @param selectionSetB - Second selection set for clash detection. Objects from `selectionSetB` will * be tested against each others by objects from the `selectionSetA` during the test. * @param params - An object containing test parameters. * @param params.tolerance - The distance of separation between objects at which test begins detecting * clashes. * @param params.clearance - The type of the clashes that the test detects: * * - `true` - Сlearance clash. A clash in which the object A may or may not intersect with object B, but * comes within a distance of less than the `tolerance`. * - `false` - Hard clash. A clash in which the object A intersects with object B by a distance of more * than the `tolerance`. * * @param params.waitForDone - Wait for test to complete. * @param params.timeout - The time, in milliseconds that the function should wait test. If test is not * complete during this time, the `TimeoutError` exception will be thrown. * @param params.interval - The time, in milliseconds, the function should delay in between checking * test status. * @param params.signal - An * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} signal, which * can be used to abort waiting as desired. */ createClashTest(name: string, selectionTypeA: string, selectionTypeB: string, selectionSetA?: string | string[], selectionSetB?: string | string[], params?: { tolerance?: number | string; clearance?: boolean; waitForDone?: boolean; timeout?: number; interval?: number; signal?: AbortSignal; }): Promise<ClashTest>; /** * Deletes the specified assembly clash test. * * @param testId - Test ID. * @returns Returns the raw data of a deleted test. For more information, see * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}. */ deleteClashTest(testId: string): Promise<any>; updateVersion(files?: string[], params?: { waitForDone?: boolean; timeout?: number; interval?: number; signal?: AbortSignal; onProgress?: (progress: number, file: globalThis.File) => void; }): Promise<Assembly>; getVersions(): Promise<Assembly[] | undefined>; getVersion(version: number): Promise<Assembly>; deleteVersion(version: number): Promise<any>; setActiveVersion(version: number): Promise<this>; createSharedLink(permissions?: ISharedLinkPermissions): Promise<SharedLink>; getSharedLink(): Promise<SharedLink>; deleteSharedLink(): Promise<any>; }