feat(ui): add sequence API helpers to api.js

This commit is contained in:
Zac Gaetano 2026-05-18 19:58:35 -04:00
parent 7d8ccc95e9
commit ad6e836345

View file

@ -456,3 +456,69 @@ async function createToken(data) {
async function revokeToken(id) {
return api(`/tokens/${id}`, { method: 'DELETE' });
}
// ============================================================
// SEQUENCE API CALLS
// ============================================================
async function getSequences(projectId) {
return api(`/sequences?project_id=${projectId}`);
}
async function createSequence(data) {
return api('/sequences', {
method: 'POST',
body: JSON.stringify(data),
});
}
async function getSequence(sequenceId) {
return api(`/sequences/${sequenceId}`);
}
async function updateSequence(sequenceId, data) {
return api(`/sequences/${sequenceId}`, {
method: 'PUT',
body: JSON.stringify(data),
});
}
async function deleteSequence(sequenceId) {
return api(`/sequences/${sequenceId}`, { method: 'DELETE' });
}
/**
* Replace all clips in a sequence.
* @param {string} sequenceId
* @param {Array<{asset_id, track, timeline_in_frames, timeline_out_frames, source_in_frames, source_out_frames}>} clips
*/
async function syncSequenceClips(sequenceId, clips) {
return api(`/sequences/${sequenceId}/clips`, {
method: 'PUT',
body: JSON.stringify(clips),
});
}
/**
* Download EDL for the V1 track of a sequence.
* Triggers a file download in the browser.
*/
async function exportSequenceEDL(sequenceId, filename) {
try {
const response = await fetch(`${API_BASE}/sequences/${sequenceId}/export/edl`, {
method: 'POST',
credentials: 'include',
});
if (!response.ok) throw new Error(`EDL export failed: ${response.status}`);
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = filename || 'sequence.edl';
a.click();
URL.revokeObjectURL(url);
return { success: true };
} catch (error) {
return { success: false, error: error.message };
}
}