import { IHttpClient } from "./IHttpClient"; import { IFileStatus, IFileReferences, IFileVersionInfo } from "./IFile"; import { IShortUserDescription } from "./IUser"; import { Model } from "./Model"; import { Permission } from "./Permission"; import { Job } from "./Job"; /** * The class representing a `file` entity. */ export declare class File { private _data; private _useVersion; httpClient: IHttpClient; path: string; /** * @param data - An object that implements file data storage. * @param httpClient - Http client for API. */ constructor(data: any, httpClient: IHttpClient); private appendVersionParam; private internalGet; private internalPost; private internalPut; private internalDelete; partialDownloadResource(dataId: string, onProgress?: (progress: number, downloaded: Uint8Array) => void, signal?: AbortSignal): Promise; downloadFileRange(requestId: number, records: any | null, dataId: string, onProgress?: (progress: number, downloaded: Uint8Array, requestId: number) => void, signal?: AbortSignal): Promise; /** * Active version number of the file. * * @readonly */ get activeVersion(): number; /** * File creation time (UTC) in the format specified in ISO 8601. * * @readonly */ get created(): string; /** * File custom fields object, to store custom data. * * @readonly */ get customFields(): any; set customFields(value: any); /** * Raw file data received from the server. * * @readonly */ get data(): any; private set data(value); /** * Returns a list of formats in which the active version of the file was exported. To export * file to one of the supported formats create File Converter job using * {@link File.createJob()}. To download exported file use {@link File.downloadResource()}. * * @readonly */ get exports(): string[]; /** * Geometry data type of the active file version. Can be one of: * * - `vsfx` - `VSFX`, file can be opened in `VisualizeJS` viewer. * - `gltf` - `glTF`, file can be opened in `Three.js` viewer. * * Returns an empty string if geometry data has not yet been extracted. A files without * geometry data can be exported to other formas, but cannot be opened in viewer. */ get geometryType(): string; /** * Unique file ID. * * @readonly */ get id(): string; /** * File name, including the extension. */ get name(): string; set name(value: string); /** * If the file is a version, then returns the ID of the original file. Otherwise, returns the file ID. * * @readonly */ get originalFileId(): string; /** * File owner information. * * @property {string} userId - User ID. * @property {string} userName - User name. * @property {string} name - First name. * @property {string} lastName - Last name. * @property {string} fullName - Full name. * @property {string} initials - Initials. * @property {string} email - User email. * @property {string} avatarUrl - User avatar image URL. * @readonly */ get owner(): IShortUserDescription; /** * File preview image URL. Use {@link File#setPreview | setPreview()} to change preview image. * * @readonly */ get previewUrl(): string; /** * The size of the active version of the file in bytes. * * @readonly */ get size(): number; /** * Total size of all versions of the file in the storage in bytes. * * @readonly */ get sizeTotal(): number; /** * Data status of the active version of the file. Contains: * * - `geometry` - status of geometry data of `VSFX` type. * - `geometryGltf` - status of geometry data of `glTF` type. * - `properties` - status of properties. * - `validation` - status of validation. * * Each status entity is a record with properties: * * - `state` - Data state. Can be `none`, `waiting`, `inprogress`, `done` or `failed`. * - `jobId` - Unique ID of the data job. * * @readonly */ get status(): IFileStatus; /** * File type, matches the file extension. * * @readonly */ get type(): string; /** * File last update time (UTC) in the format specified in ISO 8601. * * @readonly */ get updatedAt(): string; /** * Information about the user who made the last update. * * @property {string} userId - User ID. * @property {string} userName - User name. * @property {string} name - First name. * @property {string} lastName - Last name. * @property {string} fullName - Full name. * @property {string} initials - Initials. * @property {string} email - User email. * @property {string} avatarUrl - User avatar image URL. * @readonly */ get updatedBy(): IShortUserDescription; /** * Zero-based file version number for version files. The original file has version `0`. */ get version(): number; /** * List of the file versions. * * @readonly */ get versions(): IFileVersionInfo[]; /** * Refresh file data. * * @async */ checkout(): Promise; /** * Update file data on the server. * * @async * @param data - Raw file data. */ update(data: any): Promise; /** * Delete the file and all its versions from the server. * * @async * @returns Returns the raw data of a deleted file. */ delete(): Promise; /** * Save file data changes to the server. Call this method to update file data on the server * after any changes. * * @async */ save(): Promise; /** * Set or remove the file preview. * * @async * @param image - Preview image. Can be a Data URL string, ArrayBuffer, Blob or * Web API File object. Setting the `image` to `null` will remove the preview. */ setPreview(image?: ArrayBuffer | Blob | globalThis.File | FormData | string | null): Promise; /** * Returns a list of models of the active version of the file. * * @async */ getModels(): Promise; getModelTransformMatrix(handle: string): any; setModelTransformMatrix(handle: string, transform: any): Promise; /** * 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 active version of the file. * * @async * @param handles - Object original handle or handles array. Leave this parameter `undefined` * to get properties for all objects in the file. */ getProperties(handles?: string | string[]): Promise; /** * Search pattern. * * @typedef {any} SearchPattern * @property {string} key - Property name. * @property {string} value - Property value. */ /** * Query operator. Operator name can be `$and`, `$or`, `$not`, `$eq`, `$regex`. * * @typedef {any} QueryOperator * @property {string | SearchPattern[] | QueryOperator[]} * - Array of the query values or * patterns for operator. */ /** * Returns the list of original handles for an objects in the active version of the file that * match the specified patterns. Search patterns may be combined using query operators. * * @async * @example Simple search pattern. * searchPattern = { * key: "Category", * value: "OST_Stairs", * }; * * @example Search patterns combination. * searchPattern = { * $or: [ * { * $and: [ * { key: "Category", value: "OST_GenericModel" }, * { key: "Level", value: "03 - Floor" }, * ], * }, * { key: "Category", value: "OST_Stairs" }, * ], * }; * * @param {SearchPattern | QueryOperator} searchPattern - Search pattern or combination of * the patterns, see example below. * @returns {Promise} */ searchProperties(searchPattern: any): Promise; /** * Returns the cda.json for an active version of the file. * * @async */ getCdaTree(): Promise; /** * Returns a list of file viewpoints. * * @async */ getViewpoints(): Promise; /** * Add new file viewpoint. To create a new viewpoint use * {@link Viewer#createViewpoint | Viewer.createViewpoint()}. * * @async * @param viewpoint - Viewpoint. */ saveViewpoint(viewpoint: any): Promise; /** * Delete file viewpoint. * * @async * @param guid - Viewpoint GUID. * @returns Returns the raw data of a deleted viewpoint. */ deleteViewpoint(guid: string): Promise; /** * Returns viewpoint preview image as Data URL. * * @async * @param guid - Viewpoint GUID. */ getSnapshot(guid: string): Promise; /** * Returns viewpoint preview data. * * @async * @param guid - Viewpoint GUID. * @param bitmapGuid - Bitmap GUID. */ getSnapshotData(guid: string, bitmapGuid: string): Promise; /** * Download source of active version of the file. * * @async * @param onProgress - Download progress callback. * @param signal - An AbortSignal object instance. Allows to communicate with a fetch request * and abort it if desired. */ download(onProgress?: (progress: number) => void, signal?: AbortSignal): Promise; /** * Download file resource data of the active version of the file, such as exported file. * * @example Export file to DWG. * const job = await file.crateJob("dwg"); * await job.waitForDone(); * const resourceId = file.exports.find((x) => x.endsWith(".dwg")); * const arrayBuffer = await file.downloadResource(resourceId); * const blob = new Blob([arrayBuffer]); * const fileName = file.name.replace(/\.[^.]+$/, "") + ".dwg"; * FileSaver.saveAs(blob, fileName); * * @param dataId - Resource ID. * @param onProgress - Download progress callback. * @param signal - An AbortSignal object instance. Allows to communicate with a fetch request * and abort it if desired. */ downloadResource(dataId: string, onProgress?: (progress: number) => void, signal?: AbortSignal): Promise; /** * Returns a list of references to files used to correct rendering of the current file. * * @async * @param [signal] - An AbortController * signal object instance, which can be used to abort waiting as desired. */ getReferences(signal?: AbortSignal): Promise; /** * Set the file references. * * @async * @param references - File references. */ setReferences(references: IFileReferences): Promise; /** * Create a new job for the active version of the file. * * @async * @param outputFormat - The job type. Can be one of: * * - `geometry` - Extract file geometry data into `VSFX`. * - `geometryGltf` - Extract file geometry data into `glTF`. * - `properties` - Extract file properties. * - `validation` - Validate the file. Only for `IFC`. * - `dwg`, `obj`, `gltf`, `glb`, `vsf`, `pdf`, `3dpdf` - Export file to the one of the * supported format. Use {@link File.exports | File.exports()} to get the list of * completed file exports. Use {@link File.downloadResource | File.downloadResource()} * to download the exported file. * - Other custom job name. Custom job runner must be registered in the job templates table * before creating a job. * * @param parameters - Parameters for the job runner. Can be given as command line arguments * for the File Converter tool in form "--arg=value". */ createJob(outputFormat: string, parameters?: string | object): Promise; /** * Create job to extract geometry data of active version of the file. This is alias to * {@link File.createJob | File.createJob("geometry")}. * * @async * @param type - Geometry data type. Can be one of: * * - `vsfx` - `VSFX` (default), for opening a file in `VisualizeJS` viewer. * - `gltf` - `glTF`, for opening a file in `Three.js` viewer. * * @param parameters - Parameters for the job runner. Can be given as command line arguments * for the File Converter tool in form "--arg=value". */ extractGeometry(type?: string, parameters?: string | object): Promise; /** * Create job to extract properties of the active version of the file. This is alias to * {@link File.createJob | File.createJob("properties")}. * * @async * @param parameters - Parameters for the job runner. Can be given as command line arguments * for the File Converter tool in form "--arg=value". */ extractProperties(parameters?: string | object): Promise; /** * Create a job to validate the active version of the file. This is alias to * {@link File.createJob | File.createJob("validation")}. * * To get validation report use * {@link File.downloadResource | File.downloadResource("validation_report.json")}. * * @async * @param parameters - Parameters for the job runner. Can be given as command line arguments * for the File Converter tool in form "--arg=value". */ validate(parameters?: string | object): Promise; /** * Wait for jobs of the active version of the file to be done. Job is done when it changes to * `none`, `done` or `failed` status. * * @async * @param {string | string[]} jobs - Job or job array to wait on. Can be `geometry`, * `geometryGltf`, `properties`, `validation`, `dwg`, `obj`, `gltf`, `glb`, `vsf`, `pdf`, * `3dpdf` or custom job name. * @param {Boolean} [waitAll] - If this parameter is `true`, the function returns when all * the specified jobs have done. If `false`, the function returns when any one of the jobs are done. * @param {Object} [params] - An object containing waiting parameters. * @param {Number} [params.timeout] - The time, in milliseconds that the function should wait * jobs. If no one jobs are done during this time, the `TimeoutError` exception will be thrown. * @param {Number} [params.interval] - The time, in milliseconds, the function should delay * in between checking jobs status. * @param {AbortSignal} [params.signal] - An AbortController * signal object instance, which can be used to abort waiting as desired. * @param {function} [params.onCheckout] - Waiting progress callback. Return `true` to cancel waiting. * @returns {Promise} */ waitForDone(jobs: any, waitAll?: boolean, params?: { timeout?: number; interval?: number; signal?: AbortSignal; onCheckout?: (file: File, ready: boolean) => boolean; }): Promise; /** * Returns a list of file permissions. * * @async */ getPermissions(): Promise; /** * Returns the permission information. * * @async * @param permissionId - Permission ID. */ getPermission(permissionId: string): Promise; /** * Create a new file permission. * * @async * @param actions - Actions are allowed to be performed on a file with this permission. See * {@link Permission#actions | Permission.actions} for more details. * @param grantedTo - A collection of principials that will get access to the file. * @param public = false - Specifies whether all users have access to the file or not. */ createPermission(actions: string | string[], grantedTo: any[], _public: boolean): Promise; /** * Delete file permission. * * @async * @param permissionId - Permission ID. * @returns Returns the raw data of a deleted permission. */ deletePermission(permissionId: string): Promise; /** * Upload the new version of the file to the server and extract the geometry and properties as needed. * * @async * @param file - Web API File object are generally retrieved from a FileList * object returned as a result of a user selecting files using the HTML `` element. * @param params - An object containing upload parameters. * @param params.geometry=true - Create job to extract file geometry data. The geometry data * type is the same as the original file. * @param params.properties=false - Create job to extract file properties. * @param params.waitForDone=false - Wait for geometry and properties jobs to complete. * @param params.timeout - The time, in milliseconds that the function should wait jobs. If * no one jobs are done during this time, the `TimeoutError` exception will be thrown. * @param params.interval - The time, in milliseconds, the function should delay in between * checking jobs status. * @param params.signal - An AbortController * signal object instance, which can be used to abort waiting as desired. * @param params.onProgress - Upload progress callback. */ uploadVersion(file: globalThis.File, params?: { geometry?: boolean; properties?: boolean; waitForDone?: boolean; timeout?: number; interval?: number; signal?: AbortSignal; onProgress?: (progress: number, file: globalThis.File) => void; }): Promise; /** * Returns a list of version files. * * @async */ getVersions(): Promise; /** * Returns the version file. * * @async * @param version - Desired version. */ getVersion(version: number): Promise; /** * Delete version file. * * @async * @param version - Version to delete. */ deleteVersion(version: number): Promise; /** * Replace the active version of the file with the selected version. * * @async * @param version - Desired active version. */ setActiveVersion(version: number): Promise; /** * Use given version instead of active version for current file on client side. This version * change will affect the result: * * - getModels() * - getProperties() * - searchProperties() * - getCdaTree() * - download() * - downloadResource() * - createJob() * - extractGeometry() * - extractProperties() * - validate() * - waitForDone() * - Viewer.open() * * Other clients will still continue to use the currently active version of the file. Use * `undefined` to revert back to the active version. * * Note. You need to update the file data using [File.checkout()]{@link File#checkout} to * match the size and status fields to the version you selected. */ useVersion(version?: number): this; } //# sourceMappingURL=File.d.ts.map