u
This commit is contained in:
31
src/api/backup.js
Normal file
31
src/api/backup.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { http } from './http.js';
|
||||
|
||||
/**
|
||||
* Backup API for listing backups, checking service status, and triggering manual backups.
|
||||
*/
|
||||
export const backup = {
|
||||
/**
|
||||
* GET /api/backup
|
||||
* Returns: 200 { status: BackupStatus, backups: { counts, hourly, daily, monthly } }
|
||||
*/
|
||||
// #region GET /api/backup — getStatus
|
||||
// MARK: calls GET /api/backup from ./api/index.js
|
||||
getStatus() {
|
||||
return http('/api/backup');
|
||||
},
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* POST /api/backup/run
|
||||
* Triggers a manual backup run.
|
||||
* Returns: 200 { success: bool, id: str, timestamp: str, promotedDaily: bool, promotedMonthly: bool, totalSizeBytes: int, pruneResult: { hourlyPruned: int, dailyPruned: int }, manifest: object }
|
||||
*/
|
||||
// #region POST /api/backup/run — run
|
||||
// MARK: calls POST /api/backup/run from ./api/index.js
|
||||
run() {
|
||||
return http('/api/backup/run', {
|
||||
method: 'POST',
|
||||
});
|
||||
},
|
||||
// #endregion
|
||||
};
|
||||
@@ -31,4 +31,4 @@ export { shipping } from './shipping.js';
|
||||
export { payment } from './payment.js';
|
||||
export { account } from './account.js';
|
||||
export { mcp } from './mcp.js';
|
||||
|
||||
export { backup } from './backup.js';
|
||||
|
||||
@@ -143,4 +143,42 @@ export const vfs = {
|
||||
});
|
||||
},
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* POST /api/vfs/drafts/response
|
||||
* Send response to virtual draft request (action: read or list).
|
||||
* @param {{ requestId: string, content?: object|string, files?: Array<object>, error?: string }} body
|
||||
*/
|
||||
// #region POST /api/vfs/drafts/response — respondDraft
|
||||
async respondDraft(body) {
|
||||
try {
|
||||
const res = await fetch('/api/vfs/drafts/response', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...clientIdHeaders(),
|
||||
},
|
||||
credentials: 'include',
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
if (!res.ok) {
|
||||
let errText = '';
|
||||
try {
|
||||
const errData = await res.json();
|
||||
errText = errData.error || errData.message;
|
||||
} catch {
|
||||
errText = await res.text().catch(() => '');
|
||||
}
|
||||
console.error('[vfs] respondDraft failed:', res.status, errText);
|
||||
return { ok: false, error: errText };
|
||||
}
|
||||
if (res.status === 204) return { ok: true };
|
||||
const text = await res.text();
|
||||
return text ? JSON.parse(text) : { ok: true };
|
||||
} catch (err) {
|
||||
console.error('[vfs] respondDraft error:', err);
|
||||
return { ok: false, error: err.message };
|
||||
}
|
||||
},
|
||||
// #endregion
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user