Class: Client

Client

The Client.js library class that provides methods to access the Open Cloud Server resources like Projects, Files, Issues etc.


new Client( [params])

Parameters:
Name Type Argument Description
params Object <optional>

An object containing client configuration parameters.

Properties
Name Type Description
serverUrl string

Open Cloud Server URL.

Members


options :Options

VisualizeJS parameters. Changes to these parameters are automatically applied to Viewer instances associated with that client.

Type:

<readonly> serverUrl :string

Open Cloud Server URL. Use configure() to change server URL.

Type:
  • string

Methods


addEventListener(type, listener)

Registers an event listener to a specific event type on the client.

Parameters:
Name Type Description
type string

The event type to listen for. Can be one of:

  • optionschange
  • uploadprogress
listener EventListener

A listener function that is called whenever an event of the specified type has been fired.

Returns:

Returns a reference to the Client, so that calls can be chained.

Type
Client

configure(params)

Change the client configuration parameters.

Parameters:
Name Type Description
params Object

An object containing new configuration parameters.

Properties
Name Type Description
serverUrl string

Open Cloud Server URL.

Returns:

Returns a reference to the Client.

Type
Client

<async> createAssembly(files, name, params)

Create a new assembly.

Parameters:
Name Type Description
files Array.<string>

List of file IDs.

name string

Assembly name.

params

An object containing upload parameters.

Properties
Name Type Default Description
waitForDone false

Wait until assembly is created.

Returns:
Type
Promise.<Assembly>

<async> createJob(fileId, outputFormat)

Create a new job to retrieve file geometry or property data.

Parameters:
Name Type Description
fileId string

File ID.

outputFormat string

Can be geometry or properties.

Returns:
Type
Promise.<Job>

<async> createProject(name, description, startDate, endDate, avatarUrl)

Create a new project.

Parameters:
Name Type Description
name string

Project name.

description string | null

Project description.

startDate Date | string

Project start date.

endDate Date | string

Project end date.

avatarUrl string

Project preview image URL. Can be Data URL.

Returns:
Type
Promise.<Project>

<async> createUser(email, password [, params])

Create a new user. Only admins can create users, if the current logged in user does not have administrator rights, an exception will be thrown.

Parameters:
Name Type Argument Description
email string

User email.

password string

User password.

params Object <optional>

Additionall user data.

Properties
Name Type Argument Description
isAdmin string <optional>

true if user is an administrator.

userName string <optional>

User name.

firstName string <optional>

First name.

lastName string <optional>

Last name.

canCreateProject string <optional>

true if user is allowed to create a project.

projectsLimit string <optional>

The maximum number of projects that the user can create.

storageLimit string <optional>

The size of the file storage available to the user.

Returns:
Type
Promise.<User>

<async> deleteAssembly(assemblyId)

Delete the assembly from the server.

Parameters:
Name Type Description
assemblyId string

Assembly ID.

Returns:
  • Returns the raw data of a deleted assembly.
Type
Promise.<Object>

<async> deleteFile(fileId)

Delete the drawing or reference file from the server.

Parameters:
Name Type Description
fileId string

File ID.

Returns:
  • Returns the raw data of a deleted file.
Type
Promise.<Object>

<async> deleteJob(jobId)

Remove a job from the server job list. The method does not delete or stop jobs that are already being executed.

Parameters:
Name Type Description
jobId string

Job ID.

Returns:
  • Returns the raw data of a deleted job.
Type
Promise.<Object>

<async> deleteProject(projectId)

Delete the project from the server.

Parameters:
Name Type Description
projectId string

Project ID.

Returns:
  • Returns the raw data of a deleted project.
Type
Promise.<Object>

<async> deleteUser(userId)

Delete a user from the server. Only admins can delete users, if the current logged in user does not have administrator rights, an exception will be thrown.

Admins can delete themselves or other admins. An admin can only delete himself if he is not the last administrator.

You need to re-login to continue working after deleting the current logged in user.

Parameters:
Name Type Description
userId string

User ID.

Returns:
  • Returns the raw data of a deleted user.
Type
Promise.<Object>

<async> downloadReferenceFile(fileId, onProgress, signal)

Download the source of the reference file.

Parameters:
Name Type Description
fileId string

File ID.

onProgress ProgressCallback

Download progress callback.

signal AbortSignal

An AbortSignal object instance. Allows to communicate with a fetch request and abort it if desired.

Returns:
Type
Promise.<ArrayBuffer>

emitEvent(event)

Fires the event. Calls each of the listeners registered with addEventListener() for the event type event.type, in the order they were registered.

Parameters:
Name Type Description
event Event

The event to fire.

Returns:

Returns true if the event had listeners.

Type
boolean

<async> getAssemblies(start, limit, name, ids, sortByDesc, sortField)

Returns a list of assemblies the user has access to.

Parameters:
Name Type Description
start number

The starting index in the assembly list. Used for paging.

limit number

The maximum number of assemblies that should be returned per request. Used for paging.

name string

Filter the assemblies by part of the name.

ids Array.<string> | string

List of assembly IDs to return. You can specify multiple IDs on one string by separating them with a "|".

sortByDesc boolean

Allows to specify the descending order of the result. By default assemblies are sorted by name in ascending order.

sortField string

Allows to specify sort field.

Returns:
Type
Promise.<AssembliesResult>

<async> getAssembly(assemblyId)

Get assembly information.

Parameters:
Name Type Description
assemblyId string

Assembly ID.

Returns:
Type
Promise.<Assembly>

getCurrentUser()

Returns the current logged in user information. Returns null if the user is not logged in or the logged in user has deleted himself.

Returns:
Type
User

<async> getFile(fileId)

Returns the file information.

Parameters:
Name Type Description
fileId string

File ID.

Returns:
Type
Promise.<File>

<async> getFiles(start, limit, name, ext, ids, sortByDesc, sortField)

Returns a list of files the user has access to.

Parameters:
Name Type Description
start number

The starting index in the file list. Used for paging.

limit number

The maximum number of files that should be returned per request. Used for paging.

name string

Filter the files by part of the name.

ext string | Array.<string>

Filter the files by extension. Extension can be dgn, dwf, dwg, dxf, ifc, nwc, nwd, obj, pdf, rcs, rfa, rvt, stl, vsf, or any other supported file type extension. You can specify multiple extensions on one string by separating them with a "|".

ids Array.<string> | string

List of file IDs to return. You can specify multiple IDs on one string by separating them with a "|".

sortByDesc boolean

Allows to specify the descending order of the result. By default, files are sorted by name in ascending order.

sortField boolean

Allows to specify sort field.

Returns:
Type
Promise.<FilesResult>

<async> getJob(jobId)

Returns the job information.

Parameters:
Name Type Description
jobId string

Job ID.

Returns:
Type
Promise.<Job>

<async> getJobs(status, limit, start, sortByDesc, sortField)

Returns a list of jobs created by current user.

Parameters:
Name Type Description
status string | Array.<string>

Filter the jobs by status. Status can be waiting, inpogress, done or failed. You can specify multiple statuses on one string by separating them with a "|".

limit number

The maximum number of jobs that should be returned per request. Used for paging.

start number

The starting index in the job list. Used for paging.

sortByDesc boolean

Allows to specify the descending order of the result. By default, jobs are sorted by creation time in ascending order.

sortField boolean

Allows to specify sort field

Returns:
Type
Promise.<JobsResult>

<async> getProject(projectId)

Returns the project information.

Parameters:
Name Type Description
projectId string

Project ID.

Returns:
Type
Promise.<Project>

<async> getProjects(start, limit, name, ids, sortByDesc)

Returns a list of projects the user has access to.

Parameters:
Name Type Description
start number

The starting index in the project list. Used for paging.

limit number

The maximum number of projects that should be returned per request. Used for paging.

name string

Filter the projects by part of the name.

ids Array.<string> | string

List of project IDs to return. You can specify multiple IDs on one string by separating them with a "|".

sortByDesc boolean

Allows to specify the descending order of the result. By default projects are sorted by name in ascending order.

Returns:
Type
Promise.<ProjectsResult>

<async> getUser(userId)

Returns the user information. Only admins can get other users, if the current logged in user does not have administrator rights, hi can only get himself, otherwise an exception will be thrown.

Parameters:
Name Type Description
userId string

User ID.

Returns:
Type
Promise.<User>

<async> getUsers()

Returns a list of server users. Only admins can get a list of users, if the current logged in user does not have administrator rights, an exception will be thrown.

Returns:
Type
Promise.<Array.<User>>

removeAllListeners()

Removes all listeners previously registered with addEventListener() from the client.

Returns:

Returns a reference to the Client, so that calls can be chained.

Type
Client

removeEventListener(type, listener)

Removes the specified listener previously registered with addEventListener() from the client.

Parameters:
Name Type Description
type string

The event type for which to remove the listener.

listener EventListener

The listener function to remove.

Returns:

Returns a reference to the Client, so that calls can be chained.

Type
Client

<async> signInWithEmail(email, password)

Log in an existing user using email and password.

Parameters:
Name Type Description
email string

An email for authentication request.

password string

Password for authentication request. Password can only contain letters (a-z, A-Z), numbers (0-9), and special characters (~!@#$%^&*()_-+={}[]:;"'`<>,.?|/\ ), otherwise an exception will be thrown.

Returns:
Type
Promise.<User>

<async> signInWithToken(token)

Log in an existing user using API Key.

Parameters:
Name Type Description
token string

An access token for authentication request. See User.token for more details.

Returns:
Type
Promise.<User>

<async> uploadFile(file [, params])

Upload a drawing or reference file to the server.

Parameters:
Name Type Argument Description
file file

Web API File object are generally retrieved from a FileList object returned as a result of a user selecting files using the HTML <input> element.

params Object <optional>

An object containing upload parameters.

Properties
Name Type Argument Default Description
geometry boolean true

Create job to extract geometry.

properties boolean true

Create job to extract properties.

waitForDone boolean false

Wait until geometry or properties jobs complete.

onProgress FileProgressCallback <optional>

Upload progress callback.

Fires:
Returns:
Type
Promise.<File>

<async> version()

Returns server version.

Returns:
Type
Promise.<VersionResult>