Mostly mirrors functions found in the Server class, but keeps the actual request logic out of that class.
- Source
Methods
(static) _checkAudioReady(baseUrl, token, projectId) → {Promise.<boolean>}
Checks whether the audio.mp3 for a project is ready for transcription.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
projectId | string | the project's unique identifier |
Returns:
true if audio.mp3 exists and is ready
- Type:
- Promise.<boolean>
(static) _compressProject(baseUrl, token, projectId) → {Promise.<object>}
Compress a project by deleting the original non-MP3 audio file.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
projectId | string | the project's unique identifier |
Returns:
{ ok, audio_format }
- Type:
- Promise.<object>
(static) _createFolder(baseUrl, token, parentPath, name) → {Promise.<{name: string, path: string}>}
Creates a new folder on the server.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
parentPath | string | path of the parent folder ('' for root) |
name | string | name of the new folder |
Returns:
- Type:
- Promise.<{name: string, path: string}>
(static) _createProject(baseUrl, token, metadata, waveformData, audioFile, transcriptFile, sampleFiles) → {Promise.<object>}
Upload a brand-new project (first push from local).
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
metadata | object | general project metadata and speakers; no waveform details |
waveformData | object | | { sampleRate, duration, filename, peaks } |
audioFile | File | the audio file to upload |
transcriptFile | File | | the transcript CSV file, or null if none |
sampleFiles | Object.<string, File> | speaker sample files keyed by speaker id |
Returns:
the newly created project object
- Type:
- Promise.<object>
(static) _deleteAudio(baseUrl, token, projectId) → {Promise.<void>}
Deletes the audio file for a project.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
projectId | string | the project's unique identifier |
Returns:
- Type:
- Promise.<void>
(static) _deleteFolder(baseUrl, token, folderPath, merge) → {Promise.<{ok: boolean}>}
Deletes a folder on the server.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
folderPath | string | path of the folder to delete |
merge | boolean | if true, move contents to parent before deleting |
Returns:
- Type:
- Promise.<{ok: boolean}>
(static) _deleteProject(baseUrl, token, projectId) → {Promise.<object>}
Permanently delete a project from the server.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
projectId | string | the project's unique identifier |
Returns:
server response object
- Type:
- Promise.<object>
(static) _deleteTranscript(baseUrl, token, projectId) → {Promise.<void>}
Deletes the transcript for a project.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
projectId | string | the project's unique identifier |
Returns:
- Type:
- Promise.<void>
(static) _duplicateProject(baseUrl, token, projectId, folderPathopt) → {Promise.<object>}
Duplicate a project on the server and return the new project object.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
baseUrl | string | base URL of the server | |
token | string | auth token for the current session | |
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>
(static) _fetch(baseUrl, path, optionsopt, tokenopt) → {Promise.<Response>}
Authenticated fetch wrapper. Attaches the auth token header and throws on non-2xx responses, parsing any JSON error body for the message.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
baseUrl | string | server origin (e.g. "http://localhost:5000") | |
path | string | request path (e.g. "/api/projects") | |
options | object | <optional> | fetch init options (method, body, headers, etc.) |
token | string | <optional> | optional auth token; added as X-Auth-Token header |
Returns:
resolved fetch Response
- Type:
- Promise.<Response>
(static) _getAnnotations(baseUrl, token, projectId) → {Promise.<object>}
Fetch the annotations (hyperlinks, etc.) for a project.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
projectId | string | the project's unique identifier |
Returns:
annotations object with a 'hyperlinks' key
- Type:
- Promise.<object>
(static) _getCompressInfo(baseUrl, token, projectId) → {Promise.<object>}
Fetch storage size info for a project before/after compression.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
projectId | string | the project's unique identifier |
Returns:
{ can_compress, before_bytes?, after_bytes?, audio_format?, reason? }
- Type:
- Promise.<object>
(static) _getFolderCount(baseUrl, token, folderPath) → {Promise.<{projects: number, folders: number}>}
Gets the count of projects and subfolders within a folder.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
folderPath | string | path of the folder to count |
Returns:
- Type:
- Promise.<{projects: number, folders: number}>
(static) _getProject(baseUrl, token, projectId) → {Promise.<object>}
Fetch a single project by id.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
projectId | string | the project's unique identifier |
Returns:
the project metadata object
- Type:
- Promise.<object>
(static) _getProjectList(baseUrl, token) → {Promise.<Array.<object>>}
Fetch the list of all server-side projects.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | the base url of the server |
token | string | the access token of the server |
Returns:
array of project metadata objects
- Type:
- Promise.<Array.<object>>
(static) _getSharedFolders(baseUrl, token) → {Promise.<Array.<object>>}
Fetch folders shared with the current user.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | Base URL of the server. |
token | string | Auth token for the current session. |
Returns:
Array of shared folder metadata objects.
- Type:
- Promise.<Array.<object>>
(static) _getSharedProjects(baseUrl, token) → {Promise.<Array.<object>>}
Fetch projects shared with the current user.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | Base URL of the server. |
token | string | Auth token for the current session. |
Returns:
Array of shared project metadata objects.
- Type:
- Promise.<Array.<object>>
(static) _getSpeakerSample(baseUrl, token, projectId, speakerId) → {Promise.<ArrayBuffer>}
Fetches a speaker's voice sample as an ArrayBuffer.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
projectId | string | the project's unique identifier |
speakerId | string | the speaker's unique identifier |
Returns:
raw audio data for the speaker's voice sample
- Type:
- Promise.<ArrayBuffer>
(static) _getSpeakers(baseUrl, token, projectId) → {Promise.<object>}
Fetches the speakers dictionary for a project.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
projectId | string | the project's unique identifier |
Returns:
dictionary of speaker objects keyed by speaker id
- Type:
- Promise.<object>
(static) _getTranscript(baseUrl, token, projectId) → {Promise.<{contentType: string, text: string}>}
Fetches the transcript CSV text for a project.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
projectId | string | the project's unique identifier |
Returns:
the content type and raw body text
- Type:
- Promise.<{contentType: string, text: string}>
(static) _getUserMe(baseUrl, token) → {Promise.<object>}
Fetches the current user's profile from the backend. Used to verify backend access after Firebase sign-in.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | Firebase ID token |
Returns:
the user profile object
- Type:
- Promise.<object>
(static) _getWaveform(baseUrl, token, projectId) → {Promise.<object>}
Fetches the waveform metadata (sampleRate, duration, filename, peaks) for a project.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
projectId | string | the project's unique identifier |
Returns:
waveform metadata object
- Type:
- Promise.<object>
(static) _listDirectory(baseUrl, token, folderPath) → {Promise.<{folders: Array.<object>, projects: Array.<object>}>}
Lists the immediate contents of a server folder.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
folderPath | string | relative folder path ('' for root) |
Returns:
- Type:
- Promise.<{folders: Array.<object>, projects: Array.<object>}>
(static) _moveProjectToFolder(baseUrl, token, projectId, targetFolderPath) → {Promise.<object>}
Moves a project to a different folder on the server.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
projectId | string | the project's unique identifier |
targetFolderPath | string | destination folder path ('' for root) |
Returns:
updated project summary
- Type:
- Promise.<object>
(static) _renameFolder(baseUrl, token, folderPath, newName) → {Promise.<{name: string, path: string}>}
Renames a folder on the server.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
folderPath | string | current path of the folder to rename |
newName | string | new name for the folder |
Returns:
- Type:
- Promise.<{name: string, path: string}>
(static) _retranscribeSegments(baseUrl, token, 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 | Description |
|---|---|---|---|
baseUrl | string | Base URL of the server | |
token | string | Auth token | |
projectId | string | The project ID | |
segments | Array.<{start: number, end: number, idx: number}> | Segments to retranscribe | |
modelSize | string | <optional> | Whisper model size to use |
Returns:
- Type:
- Promise.<{results: Array.<{idx: number, words: Array}>}>
(static) _saveAnnotations(baseUrl, token, projectId, data) → {Promise.<void>}
Save annotations (hyperlinks, etc.) for a project.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
projectId | string | the project's unique identifier |
data | object | annotations object with a 'hyperlinks' key |
Returns:
- Type:
- Promise.<void>
(static) _saveWaveform(baseUrl, token, projectId, waveformData) → {Promise.<void>}
Saves waveform metadata (peaks, duration, sampleRate) back to the server.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
projectId | string | the project's unique identifier |
waveformData | Object | Waveform peaks and audio metadata. |
Returns:
- Type:
- Promise.<void>
(static) _transcribeProject(baseUrl, token, projectId, options, onEvent, signalopt) → {Promise.<void>}
Starts transcription and streams SSE progress events via a callback. Resolves when the stream closes (after a 'result' or 'error' event). Each event object has a 'type' field: 'status', 'progress', 'result', or 'error'.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
baseUrl | string | base URL of the server | |||||||||||||
token | string | auth token for the current session | |||||||||||||
projectId | string | the project's unique identifier | |||||||||||||
options | object | transcription optionsProperties
| |||||||||||||
onEvent | function | called with each parsed SSE event object | |||||||||||||
signal | AbortSignal | <optional> | optional abort signal |
Returns:
- Type:
- Promise.<void>
(static) _updateProject(baseUrl, token, projectId, id, metadata, speakersData, transcriptFile, sampleFiles) → {Promise.<object>}
Push updated data for an existing server project. Audio is immutable once uploaded — only metadata, speakers, and transcript can be updated.
Parameters:
| Name | Type | Description |
|---|---|---|
baseUrl | string | base URL of the server |
token | string | auth token for the current session |
projectId | string | the project's unique identifier |
id | string | the project id (included in metadata) |
metadata | object | | { name, created, modified } (no speakers) |
speakersData | object | | full speakers dict if speakers section is dirty |
transcriptFile | File | | the updated transcript file, or null to leave unchanged |
sampleFiles | Object.<string, File> | updated speaker sample files keyed by speaker id |
Returns:
the updated project object
- Type:
- Promise.<object>
(inner) _encodeFolderPath(folderPath) → {string}
Encode a folder path for use in a URL, preserving slashes between segments.
Parameters:
| Name | Type | Description |
|---|---|---|
folderPath | string | relative folder path ('' for root) |
Returns:
URL-encoded path with slashes preserved.
- Type:
- string
(inner) _xhrRequest(url, method, body, token, onProgress, signalopt) → {Promise.<object>}
XHR-based request with upload progress support. Returns parsed JSON.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
url | string | Full URL to request | |
method | string | HTTP method | |
body | FormData | Request body | |
token | string | | Auth token | |
onProgress | function | | Called with fraction (0–1) as upload progresses | |
signal | AbortSignal | <optional> | Optional abort signal. |
Returns:
- Type:
- Promise.<object>