/** * 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 type { AuditActorRealm, AuditLogAppendInput, CollectionDefinition, IDbAdapter, TreeDeleteMutationResult, TreeMutationResult } from '../../@types/index.js'; import type { DocumentLifecycleContext } from './context.js'; /** Namespaced audit actions for document-grain changes. */ export declare const AUDIT_ACTIONS: { readonly pathChanged: 'document.path.changed'; readonly orderChanged: 'document.order.changed'; readonly localesChanged: 'document.locales.changed'; readonly statusChanged: 'document.status.changed'; readonly publishScheduled: 'document.publish.scheduled'; readonly publishRescheduled: 'document.publish.rescheduled'; readonly publishReconfirmed: 'document.publish.reconfirmed'; readonly publishScheduleCancelled: 'document.publish.schedule.cancelled'; readonly publishScheduleSuspended: 'document.publish.schedule.suspended'; readonly publishScheduleDiscarded: 'document.publish.schedule.discarded'; readonly deleted: 'document.deleted'; readonly treePlaced: 'document.tree.placed'; readonly treeReparented: 'document.tree.reparented'; readonly treeReordered: 'document.tree.reordered'; readonly treeRemoved: 'document.tree.removed'; }; /** * The actor id + realm for an audit-log row. Mirrors `actorId()`: a real * persisted user carries a UUID id and is recorded with realm `'admin'` * (these write-points are admin-gated, document-grain operations). A synthetic * script/seed actor (non-UUID) or no actor is a system/tooling write — NULL id, * realm `'system'`. (A future `UserAuth`-driven write-point would extend this * to `'user'`.) */ export declare function auditActor(ctx: DocumentLifecycleContext): { actorId: string | undefined; actorRealm: AuditActorRealm; }; /** A non-null audit capability resolved from an adapter that supports it. */ export interface AuditCapability { withTransaction: (fn: () => Promise) => Promise; append: (input: AuditLogAppendInput) => Promise<{ id: string; }>; } /** Auditing plus the locked mutation primitives required by document trees. */ export interface TreeAuditCapability extends AuditCapability { place: (input: Parameters[0]) => Promise; remove: (input: Parameters[0]) => Promise; promoteAndRemove: (input: { collectionId: string; documentId: string; }) => Promise; } /** * Assert the adapter can record an audited write atomically — it must provide * **both** `withTransaction` and `commands.audit`. Returns a non-null * capability the caller composes; throws `ERR_AUDIT_UNSUPPORTED` otherwise, * rather than silently skipping the audit row or running it non-atomically. * See docs/03-architecture/03-transactions.md and docs/07-auth-and-security/02-auditability.md. */ export declare function requireAuditCapability(db: IDbAdapter): AuditCapability; /** * Require the complete audited-tree capability. Called at bootstrap and before * create so a tree collection can never silently strand a document merely * because its adapter lacks atomic audit/reconciliation support. */ export declare function requireTreeAuditCapability(db: IDbAdapter): TreeAuditCapability; /** Fail fast during server bootstrap when any tree collection lacks support. */ export declare function validateTreeAuditCapability(definitions: readonly CollectionDefinition[], db: IDbAdapter): void; /** Order-insensitive equality for the advertised-locale set. */ export declare function sameLocaleSet(a: readonly string[], b: readonly string[]): boolean;