Skip to content
← Public packages

@cameronpak/box

Full Box Public API v1 client: lifecycle, prompts, files, commands, snapshots, environments, webhooks, desktop, hosting, and account.

src/get-snapshot-tree.ts

27 lines · 842 B · TypeScript
import { assertSnapshotId, boxRequest, failure, type Result } from './client.ts'
import type { SnapshotTreeEntry } from './types.ts'

export type GetSnapshotTreeInput = { snapshotId: string }

export type GetSnapshotTreeOutput = {
	snapshotId: string
	boxId?: string
	generation?: number
	treeAvailable?: boolean
	truncated?: boolean
	fileCount?: number
	totalSizeBytes?: number
	entries?: Array<SnapshotTreeEntry>
	reason?: string
}

/** List the files and folders captured in a snapshot, with sizes. */
export default async function getSnapshotTree(
	input: GetSnapshotTreeInput,
): Promise<Result<GetSnapshotTreeOutput>> {
	const invalid = assertSnapshotId(input?.snapshotId)
	if (invalid) return failure<GetSnapshotTreeOutput>(invalid)
	return boxRequest<GetSnapshotTreeOutput>({
		path: '/snapshots/' + input.snapshotId + '/tree',
	})
}