import { type Diagnostic, type WorkspaceSource } from './compiler.js'; import type { ResolvedWorkspace } from './workspace.js'; import type { PendingWrite, SourceStore, WriteConflict } from './source-store.js'; /** * The directory part of a workspace path, in the `/`-separated terms a * manifest is written in rather than the platform's. * * Both separators by hand rather than `node:path`'s `sep`: this module is * reachable from a browser (#252), where there is no platform separator to * ask about, and a manifest path is `/`-separated wherever it is read. */ export declare const posixDirectoryOf: (path: string) => string; import type { YarramateApplyResult } from './operations.js'; export type ApplyOutcome = { readonly ok: true; /** * The documents this batch changed, for the caller to write. Core * returns them rather than writing them, so the store's comparison is * the last thing that happens before bytes land (ADR 0100). */ readonly sources: readonly WorkspaceSource[]; readonly result: YarramateApplyResult; } | { readonly ok: false; readonly diagnostics: readonly Diagnostic[]; }; /** * Everything `applyOperations` is allowed to know. The workspace is already * resolved and the sources are already read, because Core does not reach for * either (ADR 0100). */ export interface ApplyInput { /** The workspace this batch is addressed to, already resolved. */ readonly workspace: ResolvedWorkspace; /** Every source that workspace resolves to, keyed by its manifest path. */ readonly sources: readonly WorkspaceSource[]; /** The operations document itself. */ readonly operations: WorkspaceSource; /** * Where the manifest sits relative to the paths in `workspace`, so an * operation may address a document the way the manifest names it as well as * the way the workspace lists it (#216). String arithmetic, not a lookup. */ readonly manifestDirectory: string; } export declare const applyOperations: (input: ApplyInput) => ApplyOutcome; export type PlannedOperations = { readonly ok: true; readonly outcome: ApplyOutcome & { readonly ok: true; }; /** What this batch would write, unwritten. Empty when it changes nothing. */ readonly writes: readonly PendingWrite[]; } | { readonly ok: false; readonly outcome: ApplyOutcome & { readonly ok: false; }; }; /** * Reads a workspace through a store and applies a batch, stopping short of * writing (ADR 0100). * * Separated from {@link landOperations} because a caller may have writes of * its own to land in the same batch: the visual runtime commits a projection * beside the model it belongs to, and one `writeAll` is what makes the two * arrive together or not at all (ADR 0103). A caller with nothing to add wants * `landOperations` and should not see this. */ export declare const planOperations: (store: SourceStore, input: { readonly workspace: ResolvedWorkspace; readonly operations: WorkspaceSource; readonly manifestDirectory: string; }) => PlannedOperations; /** * The diagnostics a refused `writeAll` becomes, in the workspace range * (ADR 0100). Shared so a caller that merges writes of its own into the batch * reports a conflict the same way the CLI does. */ export declare const writeConflictDiagnostics: (conflicts: readonly WriteConflict[], operationsPath: string) => readonly Diagnostic[]; /** * Reads a workspace through a store, applies a batch, and writes what changed * back only if every document still holds what was read (ADR 0100). * * This is the composition Core deliberately does not perform: `applyOperations` * is a pure function, and the comparison that decides whether a batch lands * belongs to the store. */ export declare const landOperations: (store: SourceStore, input: { readonly workspace: ResolvedWorkspace; readonly operations: WorkspaceSource; readonly manifestDirectory: string; }) => ApplyOutcome;