← Public packages
@cameronpak/box
Full Box Public API v1 client: lifecycle, prompts, files, commands, snapshots, environments, webhooks, desktop, hosting, and account.
src/upgrade-environment.ts
31 lines · 1020 B · TypeScriptimport { assertEnvironmentId, boxRequest, failure, type Result } from './client.ts'
export type UpgradeEnvironmentInput = {
environmentId: string
/** Restrict the upgrade to these box ids. Omit to upgrade all older boxes. */
agentIds?: Array<string>
}
export type UpgradeEnvironmentOutput = {
success: boolean
upgraded?: number
failed?: number
}
/**
* Repoint the caller's active boxes from an older version of this environment
* to its latest version, scrubbing any owner secrets the new version drops.
*/
export default async function upgradeEnvironment(
input: UpgradeEnvironmentInput,
): Promise<Result<UpgradeEnvironmentOutput>> {
const invalid = assertEnvironmentId(input?.environmentId)
if (invalid) return failure<UpgradeEnvironmentOutput>(invalid)
const body: Record<string, unknown> = {}
if (input.agentIds !== undefined) body.agentIds = input.agentIds
return boxRequest<UpgradeEnvironmentOutput>({
path: '/environments/' + input.environmentId + '/upgrade',
method: 'POST',
body,
})
}