← Public packages
@cameronpak/box
Full Box Public API v1 client: lifecycle, prompts, files, commands, snapshots, environments, webhooks, desktop, hosting, and account.
src/list-box-snapshots.ts
26 lines · 831 B · TypeScriptimport { assertBoxId, boxRequest, failure, type Result } from './client.ts'
import type { PageInfo, SnapshotSummary } from './types.ts'
export type ListBoxSnapshotsInput = {
boxId: string
limit?: number
cursor?: string | null
sort?: 'asc' | 'desc'
}
export type ListBoxSnapshotsOutput = {
snapshots: Array<SnapshotSummary>
pageInfo?: PageInfo
}
/** List visible completed snapshots for one box with cursor pagination. */
export default async function listBoxSnapshots(
input: ListBoxSnapshotsInput,
): Promise<Result<ListBoxSnapshotsOutput>> {
const invalid = assertBoxId(input?.boxId)
if (invalid) return failure<ListBoxSnapshotsOutput>(invalid)
return boxRequest<ListBoxSnapshotsOutput>({
path: '/boxes/' + input.boxId + '/snapshots',
query: { limit: input.limit, cursor: input.cursor, sort: input.sort },
})
}