Constructor
new Server(callbacks)
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
callbacks | object | callback functions for server connection eventsProperties
|
Classes
Members
_cachedToken
Cached Firebase ID token — refreshed on each getToken() call
backendUser :object|null
Backend user profile returned by /api/users/me.
Type:
- object |
null
firebaseUser :object|null
Firebase user object — set when signed in via Firebase Auth.
Type:
- object |
null
Methods
audioUrl(id) → {string}
Returns a URL that streams the project's audio. Uses the most recently cached token for
Parameters:
| Name | Type | Description |
|---|---|---|
id | string | The project's unique identifier. |
Returns:
The audio stream URL.
- Type:
- string
(async) checkAudioReady(projectId) → {Promise.<boolean>}
Checks whether audio.mp3 is ready for a project.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId | string | The project's unique identifier. |
Returns:
True if audio.mp3 is available.
- Type:
- Promise.<boolean>
(async) compressProject(projectId) → {Promise.<object>}
Compresses a project by deleting its original non-MP3 audio file.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId | string | The project's unique identifier. |
Returns:
{ ok, audio_format }
- Type:
- Promise.<object>
(async) connectLocal() → {Promise.<void>}
Connects to the local embedded server without Firebase authentication. Used in LOCAL_MODE where the backend accepts requests with no token.
Returns:
- Type:
- Promise.<void>
(async) connectWithFirebaseUser(serverUrl, firebaseUser) → {Promise.<void>}
Connects to the server using a Firebase-authenticated user. Gets a fresh ID token, verifies backend access via /api/users/me, then fires onConnect.
Parameters:
| Name | Type | Description |
|---|---|---|
serverUrl | string | Base URL of the server (trailing slash is stripped). |
firebaseUser | object | Signed-in Firebase user. |
Returns:
- Type:
- Promise.<void>
(async) createFolder(parentPath, name) → {Promise.<{name: string, path: string}>}
Creates a new folder on the server.
Parameters:
| Name | Type | Description |
|---|---|---|
parentPath | string | parent folder path ('' for root) |
name | string | name for the new folder |
Returns:
- Type:
- Promise.<{name: string, path: string}>
(async) createProject(metadata, waveformData, audioFile, transcriptFile, sampleFiles, onProgressopt, signalopt) → {Promise.<object>}
Creates a new project on the server.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
metadata | object | Project metadata (name, description, etc.). | |
waveformData | object | Pre-computed waveform data. | |
audioFile | File | | The audio file to upload, or null to create an empty project. | |
transcriptFile | File | The transcript CSV file to upload. | |
sampleFiles | Array.<File> | Speaker voice sample files to upload. | |
onProgress | function | <optional> | upload progress callback, fraction 0–1. |
signal | AbortSignal | <optional> | Optional signal to abort the request. |
Returns:
The newly created project object.
- Type:
- Promise.<object>
(async) deleteAudio(projectId) → {Promise.<void>}
Deletes the audio file for a project.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId | string | The project's unique identifier. |
Returns:
- Type:
- Promise.<void>
(async) deleteFolder(folderPath, merge) → {Promise.<{ok: boolean}>}
Deletes a folder on the server.
Parameters:
| Name | Type | Description |
|---|---|---|
folderPath | string | folder to delete |
merge | boolean | if true, move contents to parent first |
Returns:
- Type:
- Promise.<{ok: boolean}>
(async) deleteProject(projectId) → {Promise.<boolean>}
Deletes a project by ID.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId | string | The project's unique identifier. |
Returns:
True if deletion was successful.
- Type:
- Promise.<boolean>
(async) deleteTranscript(projectId) → {Promise.<void>}
Deletes the transcript for a project.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId | string | The project's unique identifier. |
Returns:
- Type:
- Promise.<void>
(async) disconnectFromServer()
Signs out of Firebase and resets all connection state.
(async) duplicateProject(projectId, folderPathopt) → {Promise.<object>}
Duplicates a project on the server and returns the new project object.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
projectId | string | The project's unique identifier. | |
folderPath | string | <optional> | Destination folder path for the duplicate. |
Returns:
The newly created duplicate project object.
- Type:
- Promise.<object>
(async) getAnnotations(projectId) → {Promise.<object>}
Retrieves the annotations (hyperlinks, etc.) for a project.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId | string | The project's unique identifier. |
Returns:
Annotations object with a 'hyperlinks' key.
- Type:
- Promise.<object>
(async) getCompressInfo(projectId) → {Promise.<object>}
Returns storage size info for a project before and after compression.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId | string | The project's unique identifier. |
Returns:
{ can_compress, before_bytes?, after_bytes?, audio_format?, reason? }
- Type:
- Promise.<object>
(async) getFolderCount(folderPath) → {Promise.<{projects: number, folders: number}>}
Gets the count of projects and subfolders within a folder.
Parameters:
| Name | Type | Description |
|---|---|---|
folderPath | string | folder to inspect |
Returns:
- Type:
- Promise.<{projects: number, folders: number}>
(async) getProject(projectId) → {Promise.<object>}
Retrieves a single project by ID.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId | string | The project's unique identifier. |
Returns:
The project object.
- Type:
- Promise.<object>
(async) getProjectList() → {Promise.<Array.<object>>}
Retrieves the list of all projects from the server.
Returns:
Array of project metadata objects.
- Type:
- Promise.<Array.<object>>
(async) getSharedFolders() → {Promise.<Array.<object>>}
Retrieves folders shared with the current user.
Returns:
Array of shared folder metadata objects.
- Type:
- Promise.<Array.<object>>
(async) getSharedProjects() → {Promise.<Array.<object>>}
Retrieves projects shared with the current user.
Returns:
Array of shared project metadata objects.
- Type:
- Promise.<Array.<object>>
(async) getSpeakerSample(projectId, speakerId) → {Promise.<ArrayBuffer>}
Retrieves a speaker's voice sample as an ArrayBuffer.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId | string | The project's unique identifier. |
speakerId | string | The speaker's unique identifier. |
Returns:
The raw audio data.
- Type:
- Promise.<ArrayBuffer>
(async) getSpeakers(projectId) → {Promise.<object>}
Retrieves the speakers dictionary for a project.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId | string | The project's unique identifier. |
Returns:
Dictionary of speaker objects keyed by speaker id.
- Type:
- Promise.<object>
(async) getToken() → {Promise.<(string|null)>}
Returns a fresh Firebase ID token (auto-refreshes if near expiry).
Returns:
- Type:
- Promise.<(string|null)>
(async) getTranscript(projectId) → {Promise.<{contentType: string, text: string}>}
Retrieves the transcript for a project.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId | string | The project's unique identifier. |
Returns:
The content type and raw text body.
- Type:
- Promise.<{contentType: string, text: string}>
(async) getWaveform(projectId) → {Promise.<object>}
Retrieves the waveform data for a project.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId | string | The project's unique identifier. |
Returns:
The waveform data object.
- Type:
- Promise.<object>
(async) listDirectory(folderPath) → {Promise.<{folders: Array.<object>, projects: Array.<object>}>}
Lists the immediate contents of a server folder.
Parameters:
| Name | Type | Description |
|---|---|---|
folderPath | string | relative folder path ('' for root) |
Returns:
- Type:
- Promise.<{folders: Array.<object>, projects: Array.<object>}>
(async) moveProjectToFolder(projectId, targetFolderPath) → {Promise.<object>}
Moves a project to a different folder.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId | string | the project's unique identifier |
targetFolderPath | string | destination folder path ('' for root) |
Returns:
updated project summary
- Type:
- Promise.<object>
(async) refreshUser() → {Promise.<void>}
Re-fetches /api/users/me and updates backendUser in place. Call this after operations that change storage usage so that subsequent file-size checks use current data.
Returns:
- Type:
- Promise.<void>
(async) renameFolder(folderPath, newName) → {Promise.<{name: string, path: string}>}
Renames a folder on the server.
Parameters:
| Name | Type | Description |
|---|---|---|
folderPath | string | current path of the folder |
newName | string | new name |
Returns:
- Type:
- Promise.<{name: string, path: string}>
(async) retranscribeSegments(projectId, segments, modelSizeopt) → {Promise.<{results: Array.<{idx: number, words: Array}>}>}
Retranscribes specific time-range segments and returns updated word-level timestamps.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
projectId | string | The project ID | ||
segments | Array.<{start: number, end: number, idx: number}> | Segments to retranscribe | ||
modelSize | string | <optional> | medium | Whisper model size to use |
Returns:
- Type:
- Promise.<{results: Array.<{idx: number, words: Array}>}>
sampleUrl(id, spkId) → {string}
Returns a URL for a specific speaker's voice sample file. Uses the most recently cached token for direct link compatibility.
Parameters:
| Name | Type | Description |
|---|---|---|
id | string | The project's unique identifier. |
spkId | string | The speaker's unique identifier. |
Returns:
The sample file URL.
- Type:
- string
(async) saveAnnotations(projectId, data) → {Promise.<void>}
Saves annotations (hyperlinks, etc.) for a project.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId | string | The project's unique identifier. |
data | object | Annotations object with a 'hyperlinks' key. |
Returns:
- Type:
- Promise.<void>
(async) saveWaveform(projectId, waveformData) → {Promise.<void>}
Saves waveform metadata (peaks, duration, sampleRate) to the server.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId | string | The project's unique identifier. |
waveformData | Object | Waveform peaks and audio metadata. |
Returns:
- Type:
- Promise.<void>
(async) transcribeProject(projectId, options, onEvent, signalopt) → {Promise.<void>}
Starts transcription and streams progress events via a callback.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
projectId | string | The project's unique identifier. | |
options | object | { modelSize, speakerCount } | |
onEvent | function | called with each SSE event object | |
signal | AbortSignal | <optional> | optional abort signal |
Returns:
- Type:
- Promise.<void>
transcriptUrl(id) → {string}
Returns the URL to download the project's transcript CSV.
Parameters:
| Name | Type | Description |
|---|---|---|
id | string | The project's unique identifier. |
Returns:
The transcript download URL.
- Type:
- string
(async) updateProject(projectId, metadata, speakersData, audioFile, transcriptFile, sampleFiles, onProgressopt, signalopt) → {Promise.<object>}
Updates an existing project on the server.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
projectId | string | The project's unique identifier. | |
metadata | object | Updated project metadata (name, created, modified). | |
speakersData | object | | Full speakers dict if speakers section is dirty, or null. | |
audioFile | File | | Replacement audio file, or null to leave unchanged. | |
transcriptFile | File | | Replacement transcript file, or null to leave unchanged. | |
sampleFiles | Object.<string, File> | Replacement sample files keyed by speaker id. | |
onProgress | function | <optional> | upload progress callback, fraction 0–1. |
signal | AbortSignal | <optional> | Optional signal to abort the request. |
Returns:
The updated project object.
- Type:
- Promise.<object>