← Public packages
@cameronpak/box
Full Box Public API v1 client: lifecycle, prompts, files, commands, snapshots, environments, webhooks, desktop, hosting, and account.
src/get-snapshot-download.ts
29 lines · 993 B · TypeScriptimport { assertSnapshotId, boxRequest, failure, type Result } from './client.ts'
import type { SnapshotChunk } from './types.ts'
export type GetSnapshotDownloadInput = { snapshotId: string }
export type GetSnapshotDownloadOutput = {
snapshotId: string
boxId: string
kind: 'base' | 'incremental' | 'legacy'
generation: number
expiresInSeconds: number
reconstruct: string
inventory?: { r2Key: string; signedUrl: string } | null
chunks: Array<SnapshotChunk>
}
/**
* Return time-limited signed URLs for every chunk needed to reconstruct the
* box filesystem at this snapshot. signedUrl values are secrets; redact them.
*/
export default async function getSnapshotDownload(
input: GetSnapshotDownloadInput,
): Promise<Result<GetSnapshotDownloadOutput>> {
const invalid = assertSnapshotId(input?.snapshotId)
if (invalid) return failure<GetSnapshotDownloadOutput>(invalid)
return boxRequest<GetSnapshotDownloadOutput>({
path: '/snapshots/' + input.snapshotId + '/download',
})
}