← Public packages
@cameronpak/box
Full Box Public API v1 client: lifecycle, prompts, files, commands, snapshots, environments, webhooks, desktop, hosting, and account.
src/delete-box.ts
32 lines · 1.1 KB · TypeScriptimport { assertBoxId, boxRequest, failure, type Result } from './client.ts'
import type { DeletionOperation } from './types.ts'
export type DeleteBoxInput = {
boxId: string
/**
* Must exactly equal boxId. Defaults to boxId. A mismatch returns 409
* and nothing is deleted.
*/
confirmDelete?: string
}
export type DeleteAcceptedOutput = { operation: DeletionOperation }
/**
* Permanently delete a box and the snapshot data nothing else is using.
* This is not archive: the box cannot be resumed. Returns 202 with an
* operation; poll getDeletionOperation until status is completed.
* Sends X-Ascii-Confirm-Delete, which must equal the box id.
*/
export default async function deleteBox(
input: DeleteBoxInput,
): Promise<Result<DeleteAcceptedOutput>> {
const invalid = assertBoxId(input?.boxId)
if (invalid) return failure<DeleteAcceptedOutput>(invalid)
const confirm = input.confirmDelete ?? input.boxId
return boxRequest<DeleteAcceptedOutput>({
path: '/boxes/' + input.boxId,
method: 'DELETE',
headers: { 'X-Ascii-Confirm-Delete': confirm },
})
}