/** * This Source Code is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright (c) Infonomic Company Limited */ import { ErrorCodes } from '../../lib/errors.js'; import type { StructuralMutationReceipt } from '../../@types/index.js'; import type { DocumentLifecycleContext } from './context.js'; export type DeleteDocumentOutcome = 'committed' | 'committed-with-side-effect-failures'; export type DeleteDocumentSideEffectPhase = 'afterTreeChange' | 'afterDelete'; export type DeleteDocumentSideEffectCode = typeof ErrorCodes.STORAGE | typeof ErrorCodes.UNHANDLED; export interface DeleteDocumentSideEffectFailure { phase: DeleteDocumentSideEffectPhase; code: DeleteDocumentSideEffectCode; } export interface DeleteDocumentCommittedResult extends StructuralMutationReceipt { documentId: string; revision: number; deletedVersionCount: number; outcome: 'committed'; sideEffectFailures: []; } export interface DeleteDocumentCommittedWithSideEffectFailuresResult extends StructuralMutationReceipt { documentId: string; revision: number; deletedVersionCount: number; outcome: 'committed-with-side-effect-failures'; sideEffectFailures: [DeleteDocumentSideEffectFailure, ...DeleteDocumentSideEffectFailure[]]; } export type DeleteDocumentResult = DeleteDocumentCommittedResult | DeleteDocumentCommittedWithSideEffectFailuresResult; /** * Soft-delete a document. * * Marks every version and path row for the document as deleted. Live views * and path resolution exclude those tombstones, while content, retained path * values, uploaded sources, and persisted variants remain available for a * later restoration workflow. * * Flow: * 1. Fetch current document metadata, including its original path * 2. `hooks.beforeDelete({ documentId, collectionPath })` * 3. `db.commands.documents.softDeleteDocument({ document_id })` * 4. Tree-change hooks, when applicable * 5. `hooks.afterDelete({ documentId, collectionPath })` */ export declare function deleteDocument(ctx: DocumentLifecycleContext, params: { documentId: string; expectedRevision: number; }): Promise;