import type { ApiDeps } from '../http/client.js'; import type { Environment } from '../config/environments.js'; export interface RehostResult { /** URLs successfully copied onto the target environment. */ rehosted: number; /** URLs left pointing at the foreign bucket, with the reason each one failed. */ failed: Array<{ url: string; reason: string; }>; /** Bytes actually stored on the target. */ storedBytes: number; /** Project files whose contents changed. */ filesRewritten: string[]; } /** Reports progress as `completed` of `total` assets finish, in either direction. */ export type RehostProgress = (completed: number, total: number) => void; /** * The group an environment's assets belong on. * * `local` maps to dev because a local api-server signs uploads into the dev bucket — its games' * assets are dev assets, and treating localhost as its own group would copy the whole dev bucket * into itself on every local import. */ export declare function environmentGroup(environment: Environment): 'prod' | 'dev'; /** * The content type to upload with: a specific `Content-Type` from the source response, else the * extension's. Generic octet-stream headers are ignored so the extension wins — a `.vxl` served * as `application/octet-stream` and a `.png` served the same way are not the same file, and * api-server chooses whether to gzip from this value. */ export declare function inferContentType(url: string, headerValue: string | null): string; /** * A bare, storage-safe basename for the copied object. api-server refuses a path separator * outright and prefixes its own unique component, so this only has to be recognisable — two * assets that reduce to the same name do not collide. */ export declare function safeBasename(url: string): string; export interface RehostOptions { /** The imported project's root. */ root: string; /** The environment the project belongs to — the destination for every foreign asset. */ environment: Environment; token: string; /** The game the copies are stored under. Must be owned by the caller on `environment`. */ gameId: string; deps: ApiDeps; onProgress?: RehostProgress; } /** * Which of the project's asset URLs live on an environment other than this project's. * * Exported for the command, which reports the count before spending several minutes on the copy — * and for the tests, which is where the "a foreign host, not merely a remote one" rule is pinned. */ export declare function foreignAssetUrls(root: string, environment: Environment): string[]; /** * Copy every foreign asset onto `environment` and rewrite the project's references to it. * * Returns without touching a file when there is nothing foreign to move, which is the ordinary * case for an import that stayed on one environment. */ export declare function rehostForeignAssets(options: RehostOptions): Promise;