import type { ArchiveSource } from "../io/archive-source.js"; import type { ZipEntryOptions } from "./index.js"; /** * Serializable operation types for ZipEditPlan */ export type ZipEditOp = { type: "set"; name: string; source: ArchiveSource; options?: ZipEntryOptions; } | { type: "delete"; name: string; } | { type: "deleteDirectory"; prefix: string; } | { type: "rename"; from: string; to: string; } | { type: "comment"; comment?: string; }; /** * Serialized form of a ZipEditOp. * * For "set" operations, the source is stored as base64-encoded data. * This allows the plan to be safely serialized to JSON and restored later. */ export type SerializedZipEditOp = { type: "set"; name: string; /** Base64-encoded source data */ data: string; options?: ZipEntryOptions; } | { type: "delete"; name: string; } | { type: "deleteDirectory"; prefix: string; } | { type: "rename"; from: string; to: string; } | { type: "comment"; comment?: string; }; /** * Serialized form of the entire ZipEditPlan. */ export interface SerializedZipEditPlan { version: 1; ops: SerializedZipEditOp[]; } /** * A reusable, serializable description of ZIP edits. * * This is intentionally decoupled from any particular ZIP input. * Apply it to a {@link ZipEditor} to execute. */ export declare class ZipEditPlan { private readonly _ops; constructor(ops?: ZipEditOp[]); getOperations(): readonly ZipEditOp[]; set(name: string, source: ArchiveSource, options?: ZipEntryOptions): this; delete(name: string): this; /** * Delete a directory and all its contents recursively. * * @param prefix - The directory path prefix to delete (with or without trailing slash) */ deleteDirectory(prefix: string): this; rename(from: string, to: string): this; setComment(comment?: string): this; /** * Apply this plan to a target editor-like object. */ applyTo(target: { set(name: string, source: ArchiveSource, options?: ZipEntryOptions): unknown; delete(name: string): unknown; deleteDirectory(prefix: string): unknown; rename(from: string, to: string): unknown; setComment(comment?: string): unknown; }): void; /** * Return a new plan which runs this plan, then `other`. */ concat(other: ZipEditPlan): ZipEditPlan; /** * Serialize this plan to a JSON-compatible object. * * All source data will be resolved to buffers and encoded as base64. * This is useful for storing the plan in a database, file, or sending over a network. * * @param signal - Optional abort signal for cancellation * @returns Serialized plan that can be safely JSON.stringify'd */ serialize(signal?: AbortSignal): Promise; /** * Serialize this plan to a JSON string. * * @param signal - Optional abort signal for cancellation * @returns JSON string representation of the plan */ toJSON(signal?: AbortSignal): Promise; /** * Create a ZipEditPlan from a serialized object. * * @param data - Serialized plan object * @returns Restored ZipEditPlan */ static deserialize(data: SerializedZipEditPlan): ZipEditPlan; /** * Create a ZipEditPlan from a JSON string. * * @param json - JSON string representation of a serialized plan * @returns Restored ZipEditPlan */ static fromJSON(json: string): ZipEditPlan; }