Skip to content

Files ​

Asset ​

Asset = object

A static asset.

Properties ​

asArrayBuffer() ​

asArrayBuffer: () => Promise<ArrayBuffer>

Returns ​

Promise<ArrayBuffer>

asJson() ​

asJson: <T>() => Promise<T>

Type Parameters ​
Type ParameterDefault type
Tunknown
Returns ​

Promise<T>

asReadableStream() ​

asReadableStream: () => ReadableStream

Returns ​

ReadableStream

asString() ​

asString: () => Promise<string>

Returns ​

Promise<string>


AssetsSDK ​

AssetsSDK = object

Utilities to interact with the plugin's static assets.

Properties ​

get() ​

get: (path: string) => Promise<Asset>

Get a file from the assets folder.

Parameters ​
ParameterType
pathstring
Returns ​

Promise<Asset>

The asset file.


FilesPageContext ​

FilesPageContext = object

Files page context.

Properties ​

kind ​

kind: "Files"


FilesSDK ​

FilesSDK = object

SDK for interacting with the Files page.

Properties ​

create() ​

create: (file: File) => Promise<HostedFile>

Uploads a file to the host.

Parameters ​
ParameterTypeDescription
fileFileThe file to upload.
Returns ​

Promise<HostedFile>

The uploaded file.

delete() ​

delete: (id: string) => Promise<void>

Deletes a file from the host.

Parameters ​
ParameterTypeDescription
idstringThe ID of the file to delete.
Returns ​

Promise<void>

The deleted file.

getAll() ​

getAll: () => HostedFile[]

Gets all hosted files.

Returns ​

HostedFile[]

The files.

onDeletedHostedFile() ​

onDeletedHostedFile: (callback: (fileId: string) => void) => ListenerHandle

Listen for deleted hosted files.

Parameters ​
ParameterTypeDescription
callback(fileId: string) => voidThe callback function that receives the file ID.
Returns ​

ListenerHandle

A handle object with a stop method to stop listening.

Example ​
ts
const handle = sdk.files.onDeletedHostedFile((fileId) => {
  console.log(`Hosted file deleted:`, fileId);
});

// Later, stop listening
handle.stop();
onUpdatedHostedFile() ​

onUpdatedHostedFile: (callback: (event: HostedFile) => void) => ListenerHandle

Listen for updated hosted files.

Parameters ​
ParameterTypeDescription
callback(event: HostedFile) => voidThe callback function that receives the hosted file.
Returns ​

ListenerHandle

A handle object with a stop method to stop listening.

Example ​
ts
const handle = sdk.files.onUpdatedHostedFile((hostedFile) => {
  console.log(`Hosted file updated:`, hostedFile);
});

// Later, stop listening
handle.stop();
onUploadedHostedFile() ​

onUploadedHostedFile: (callback: (event: HostedFile) => void) => ListenerHandle

Listen for uploaded hosted files.

Parameters ​
ParameterTypeDescription
callback(event: HostedFile) => voidThe callback function that receives the hosted file.
Returns ​

ListenerHandle

A handle object with a stop method to stop listening.

Example ​
ts
const handle = sdk.files.onUploadedHostedFile((hostedFile) => {
  console.log(`Hosted file uploaded:`, hostedFile);
});

// Later, stop listening
handle.stop();
rename() ​

rename: (id: string, name: string) => Promise<HostedFile>

Renames a file on the host.

Parameters ​
ParameterTypeDescription
idstringThe ID of the file to rename.
namestringThe new name of the file.
Returns ​

Promise<HostedFile>

The renamed file.


HostedFile ​

HostedFile = object

A hosted file.

Properties ​

createdAt ​

createdAt: Date

The date the file was created.

id ​

id: string

The ID of the file.

name ​

name: string

The name of the file.

path ​

path: string

The path of the file.

size ​

size: number

The size of the file in bytes.

status ​

status: "ready" | "error"

The status of the file.

updatedAt ​

updatedAt: Date

The date the file was updated.