import { type Sphere } from "./did.js"; import { type Identity } from "./identity.js"; import { type Author } from "./author.js"; import { type ManifestV03 } from "./bundle-v03.js"; /** Fields to set on a section. Absent fields are kept; `clearTags` wins over `tags`. */ export interface SectionChange { title?: string; body?: string; tags?: string[]; clearTags?: boolean; } export interface EditSectionV03Args { /** Owner identity or an Author (owner/delegate). */ author: Identity | Author; /** Current bundle directory (the predecessor edition). */ bundleDir: string; /** Directory to write the new edition into. */ outDir: string; zone: Sphere; sectionId: string; /** The change to apply (upsert). Omit/`undefined` only for a delete. */ change?: SectionChange; /** Gamma ref to stamp on the mutated section (defaults to a fresh id). */ gammaRef?: string; now?: Date; } /** * Upsert one section (modify if present, add if absent) and write a new edition. * Re-encrypts only the touched section; all others carry forward byte-identical. */ export declare function editSectionV03(args: EditSectionV03Args): ManifestV03; /** Remove one section by id and write a new edition (the rest carry forward). */ export declare function deleteSectionV03(args: Omit): ManifestV03; /** * One resolved entry of a batch: upsert (add/modify) or delete. `sectionId` * is always explicit here — callers mint ids for adds (the storage layer * uses `newSectionId()`), so a batch is fully addressable before it runs. */ export type BatchSectionEdit = { readonly op: "upsert"; readonly zone: Sphere; readonly sectionId: string; readonly change: SectionChange; readonly gammaRef?: string; } | { readonly op: "delete"; readonly zone: Sphere; readonly sectionId: string; }; export interface EditSectionsV03Args { /** Owner identity or an Author (owner/delegate). */ author: Identity | Author; /** Current bundle directory (the predecessor edition). */ bundleDir: string; /** Directory to write the new edition into. */ outDir: string; /** Edits, applied IN ORDER (later edits see earlier ones in the batch). */ edits: readonly BatchSectionEdit[]; now?: Date; } /** * Apply N section edits and write ONE new edition (the transactional * counterpart of {@link editSectionV03} / {@link deleteSectionV03}). * * Semantics: * - Edits resolve sequentially against (persisted state + earlier edits in * the SAME batch): modify-after-add composes, delete-after-add cancels * out (and is dropped from the patch), the second upsert of a section * wins over the first. * - Only touched sections are (re)encrypted; untouched siblings carry * forward byte-identical via {@link patchEditionV03} — exactly one * manifest re-sign for the whole batch. * - A batch that nets out to zero changes throws (`empty batch`): callers * (the MCP `ethos_commit` handler, SdkStorage) treat that as a refusal, * not a no-op edition. * - Authorization mirrors the single-edit path: every edit's zone must be * authored by `author` (owner: all zones; delegate: its actor sphere). */ export declare function editSectionsV03(args: EditSectionsV03Args): ManifestV03;