/** * AtlasExporter — serializes SQLite state to atlas.json. * * The entire read runs in a single transaction so concurrent writers * cannot corrupt the export (SQLite gives us snapshot isolation within * a transaction). Output is deterministic: key order is canonical, * arrays are sorted, nullish optional fields are omitted. * * Nullish convention (round-trip invariant): "" / undefined / null are * treated identically on export — all three omit the key. Importers * treat missing keys as absent. Any future field that must survive * round-trip through null states MUST NOT rely on this layer preserving * the distinction. * * In production, step 5 (extraction pipeline) decides whether an index * run was a no-op (skip re-export entirely) or a real run (pass an * explicit `generatedAt`). This exporter does not know which case it's * in — it correctly handles both by accepting an override and falling * back to the stored value. * * Atlas v1.1 adds `extracted_at_sha` and `git_commits` per ADR-11. The * exporter emits v1.1 unconditionally; the new optional fields are * omitted when no git data was collected (non-git source trees). */ import type { DatabaseInstance } from "./db.js"; import { type AtlasFileV1, type AtlasVersion } from "./types.js"; export interface ExportAtlasOptions { /** * Override the `generated_at` timestamp. If omitted, the value stored * in SQLite's `atlas_meta` is used — which is what enables lossless * round-trip (import → export yields the same timestamp). */ generatedAt?: string; /** Override the generator info. Falls back to stored values. */ contextatlasVersion?: string; /** * Override the contextatlas binary's git HEAD SHA captured at * extraction time (atlas schema v1.3+, v0.3 Theme 1.3). Defaults * to the value stored in `atlas_meta`. Pass `null` to explicitly * omit (e.g., when the binary is not in a git checkout). */ contextatlasCommitSha?: string | null; extractionModel?: string; /** * Override the git HEAD SHA captured at extraction time. Defaults to * the value stored in `atlas_meta` during the extraction run. Pass * `null` to explicitly omit the field (e.g., non-git source tree). */ extractedAtSha?: string | null; /** * Override the atlas version to emit. Defaults to the version stored * in `atlas_meta` (preserving round-trip for imported atlases), * falling back to the current {@link ATLAS_VERSION} for databases * with no version meta set. Pipeline's stage 7 writes * ATLAS_VERSION into meta after a real extraction run so upgraded * atlases export at the new version. */ version?: AtlasVersion; } /** * Serialize the current database state to a deterministically-ordered * AtlasFileV1 object. */ export declare function exportAtlas(db: DatabaseInstance, options?: ExportAtlasOptions): AtlasFileV1; /** * Serialize an atlas to canonical JSON text: 2-space indent, LF newlines, * exactly one trailing newline. Suitable for writing directly to disk. */ export declare function serializeAtlas(atlas: AtlasFileV1): string; /** * Export the database to atlas.json at the given path. Writes LF-only * output — a .gitattributes entry on the atlas file is the long-term * way to guarantee line-ending stability across OSes; this function * handles the serialization side of that pair. */ export declare function exportAtlasToFile(db: DatabaseInstance, filePath: string, options?: ExportAtlasOptions): void; //# sourceMappingURL=atlas-exporter.d.ts.map