Open Design

Class DesignExportFacade

Identification Accessors

id
get id(): string

The ID of the export task.

returns string

Data Accessors

resultFormat
get resultFormat(): "sketch"

The target format to which the design is exported.

returns "sketch"
status
get status(): "uploading" | "processing" | "done" | "failed"

The status of the export task.

returns "uploading" | "processing" | "done" | "failed"

Reference Accessors

designId
get designId(): string

The ID of the exported design.

returns string

Serialization Methods

exportDesignFile
exportDesignFile(filePath: string, options?: { cancelToken?: null | CancelToken }): Promise<void>

Downloads the produced design file to the file system.

A file system has to be available when using this method.

Example:

await export.exportDesignFile('./exports/design.sketch')

Parameters:

filePath: string

An absolute path to which to save the design file or a path relative to the current working directory.

options: default: {}

Options

OptionalcancelToken?: null | CancelToken

A cancellation token which aborts the asynchronous operation. When the token is cancelled, the promise is rejected and side effects are not reverted (e.g. a partially downloaded file is not deleted). A cancellation token can be created via createCancelToken.

returns Promise<void>
getResultStream
getResultStream(options?: { cancelToken?: null | CancelToken }): Promise<ReadableStream>

Returns a readable binary stream of the produced design file.

Example:

const resultStream = await export.getResultStream()

const writeStream = fs.createWriteStream('./exports/design.sketch')
resultStream.pipe(writeStream)

Parameters:

options: default: {}

Options

OptionalcancelToken?: null | CancelToken

A cancellation token which aborts the asynchronous operation. When the token is cancelled, the promise is rejected. A cancellation token can be created via createCancelToken.

returns Promise<ReadableStream>

A readable file stream.

getResultUrl
getResultUrl(options?: { cancelToken?: null | CancelToken }): Promise<string>

Returns the URL of the produced design file.

Example:

const url = await export.getResultUrl()

const response = await fetch(url)
if (response.status !== 200) throw new Error('Export result unavailable')

const writeStream = fs.createWriteStream('./exports/design.sketch')
response.pipe(writeStream)

Parameters:

options: default: {}

Options

OptionalcancelToken?: null | CancelToken

A cancellation token which aborts the asynchronous operation. When the token is cancelled, the promise is rejected. A cancellation token can be created via createCancelToken.

returns Promise<string>

A URL string.

Was this article helpful?