import { Channel, Event, Service } from "@eventcatalog/sdk"; import { ArchitectureSnapshot, ArchitectureSnapshot as ArchitectureSnapshot$1, EventObservation } from "autotel-subscribers/architecture-snapshot"; //#region src/snapshot.d.ts /** * Loads and validates an autotel architecture snapshot from disk. * * Throws a descriptive error when the file is missing, contains invalid * JSON, or is not recognisable as an autotel snapshot, so the CLI surfaces * an actionable message rather than a raw `ENOENT` or `SyntaxError`. */ export declare function loadSnapshot(path: string): Promise; //#endregion //#region src/generate.d.ts interface GenerateOptions { snapshot: ArchitectureSnapshot; catalogPath: string; dryRun?: boolean; edgesOnly?: boolean; /** Version to assign to newly created resources. Defaults to '1.0.0'. */ version?: string; } type GenerateSummaryItem = { kind: 'service' | 'event' | 'channel' | 'service-edge' | 'channel-edge'; id: string; action: 'create' | 'exists' | 'link' | 'would-create' | 'would-link'; detail?: string; /** For event items: where the JSON Schema came from. */ schemaSource?: 'declared' | 'inferred'; }; interface GenerateResult { operations: GenerateSummaryItem[]; } export declare const GENERATE_SUMMARY_SPEC: 'autotel-eventcatalog-generate-summary/v0.1.0'; type GenerateSummary = { spec: typeof GENERATE_SUMMARY_SPEC; dryRun: boolean; edgesOnly: boolean; attempted: number; /** Top-level totals for dashboards / status checks. */ totals: { created: number; linked: number; skipped: number; }; /** Per-kind counts so consumers can render detail without re-deriving from `operations`. */ created: { services: string[]; events: string[]; channels: string[]; }; edges: { sends: { service: string; event: string; }[]; receives: { service: string; event: string; }[]; messages: { channel: string; event: string; }[]; }; /** Counts of declared- vs inferred-schema events created. Reveals adoption of `defineEvent`. */ schemaSources: { declared: number; inferred: number; }; skipped: { services: string[]; events: string[]; channels: string[]; }; }; /** A JSON Schema node, as this generator builds one. */ interface JsonSchemaNode { $schema?: string; type?: string | string[]; enum?: Array; properties?: Record; items?: JsonSchemaNode; format?: string; description?: string; } export declare function generateCatalogFromSnapshot(opts: GenerateOptions): Promise; export declare function buildGenerateSummary(result: GenerateResult, options: { dryRun: boolean; edgesOnly: boolean; }): GenerateSummary; export declare function inferJsonSchemaFromObservation(observation: EventObservation): JsonSchemaNode; //#endregion //#region src/catalog.d.ts type SchemaConstraint = { types?: string[]; enumValues?: unknown[]; }; type CatalogEvent = Event & { /** Absolute path to the event's `index.mdx`, resolved via SDK. */ filePath: string; /** Field paths declared in the event's JSON Schema (if present). */ declaredFieldPaths?: string[]; declaredSchemaConstraints?: Record; }; type CatalogService = Service & { filePath: string; }; type CatalogChannel = Channel & { filePath: string; }; type CatalogState = { events: Map; services: Map; channels: Map; }; export declare function readCatalogState(catalogPath: string): Promise; /** * Extract field paths from a JSON Schema. Mirrors the dotted-path convention * used by the snapshot subscriber: arrays collapse to `[]`, nested objects * use `.`. We walk `properties` (objects) and `items` (arrays). */ export declare function extractDeclaredFieldPaths(schema?: JsonSchemaNode, prefix?: string): string[]; //#endregion //#region src/diff.d.ts type EventDrift = { /** Event names observed in the snapshot but not present in the catalog. */ observedButUndocumented: string[]; /** Event names declared in the catalog but never observed in the snapshot. */ documentedButUnseen: string[]; /** Per-event field-path mismatches. */ fieldDrift: FieldDrift[]; /** Per-event field type mismatches against declared schema types. */ typeDrift: TypeDrift[]; /** Per-event enum/value mismatches against declared schema enums. */ valueDrift: ValueDrift[]; }; type FieldDrift = { event: string; /** Field paths in the observed payload but not declared in the schema. */ extra: string[]; /** Field paths declared in the schema but never observed in a payload. */ missing: string[]; }; type TypeDrift = { event: string; path: string; declared: string[]; observed: string[]; }; type ValueDrift = { event: string; path: string; declared: unknown[]; observed: unknown[]; }; type ServiceDrift = { /** Producers in the snapshot but not present in the catalog as services. */ observedButUndocumented: string[]; }; type ChannelDrift = { /** Channels in the snapshot but not present in the catalog. */ observedButUndocumented: string[]; }; type DriftReport = { snapshotGeneratedAt: string; snapshotService: string; events: EventDrift; services: ServiceDrift; channels: ChannelDrift; }; /** True if the report contains any drift worth surfacing in a PR check. */ export declare function hasDrift(report: DriftReport): boolean; /** * Per-category counts for a DriftReport. Keeps the dashboard's hero meter, * the CLI's summary-output, and the action's structured output all agreeing * on what "N findings" means. */ type DriftCounts = { /** Total of all categories; what a dashboard "drift findings" badge shows. */ total: number; observedButUndocumentedEvents: number; documentedButUnseenEvents: number; /** Number of distinct events with field-path drift entries. */ fieldDriftEvents: number; /** Sum of every individual extra + missing path across all fieldDrift entries. */ fieldDriftPaths: number; typeDriftPaths: number; valueDriftPaths: number; undocumentedServices: number; undocumentedChannels: number; }; export declare function countDriftReport(report: DriftReport): DriftCounts; export declare function diffCatalogAgainstSnapshot(snapshot: ArchitectureSnapshot, catalog: CatalogState): DriftReport; //#endregion //#region src/diff-vs-base.d.ts type DriftDelta = { /** Drift entries present in head but not in base. */ introduced: DriftEntries; /** Drift entries present in base but not in head; the PR fixed these. */ resolved: DriftEntries; /** True if `introduced` has any non-empty section. */ hasNewDrift: boolean; }; type DriftEntries = { events: { observedButUndocumented: string[]; documentedButUnseen: string[]; fieldDrift: FieldDrift[]; typeDrift: TypeDrift[]; valueDrift: ValueDrift[]; }; services: { observedButUndocumented: string[]; }; channels: { observedButUndocumented: string[]; }; }; export declare function compareDriftReports(base: DriftReport, head: DriftReport): DriftDelta; /** * Per-category counts for one side of a DriftDelta (introduced or resolved). * Same shape as DriftCounts so dashboards and CI can render the * introduced/resolved sections with identical accounting. */ export declare function countDriftEntries(entries: DriftEntries): DriftCounts; export declare function countDriftDelta(delta: DriftDelta): { introduced: DriftCounts; resolved: DriftCounts; }; //#endregion //#region src/renderers/types.d.ts type RenderReport = (report: DriftReport) => string; type RenderDelta = (delta: DriftDelta) => string; interface Renderer { /** Short name used by the CLI's `--format` flag. */ readonly name: string; /** One-line human description shown in CLI help and the README. */ readonly description: string; readonly renderReport: RenderReport; readonly renderDelta: RenderDelta; } //#endregion //#region src/renderers/markdown.d.ts export declare function renderMarkdown(report: DriftReport): string; /** * Render the diff-of-diffs as a PR-comment-friendly markdown block. Sections * appear only when they have content, so a clean PR produces a tight message. */ export declare function renderDeltaMarkdown(delta: DriftDelta): string; //#endregion //#region src/renderers/terminal.d.ts export declare function renderTerminal(report: DriftReport): string; export declare function renderDeltaTerminal(delta: DriftDelta): string; //#endregion //#region src/renderers/json.d.ts /** * Versioned identifier baked into the JSON envelope. Bumping it is a * breaking change for downstream consumers; add fields rather than rename. */ export declare const REPORT_SPEC: 'autotel-eventcatalog-report/v0.2.0'; type JsonReport = { mode: 'all'; report: DriftReport; } | { mode: 'new-only'; delta: DriftDelta; }; type JsonReportEnvelope = { spec: typeof REPORT_SPEC; } & JsonReport; export declare function renderJson(data: JsonReport): string; //#endregion //#region src/eventcatalog-snapshot-diff.d.ts type SnapshotResourceType = 'event' | 'command' | 'query' | 'service' | 'domain' | 'channel'; type ResourceChangeType = 'added' | 'removed' | 'modified' | 'versioned'; type ResourceChange = { resourceId: string; version: string; type: SnapshotResourceType; changeType: ResourceChangeType; changedFields?: string[]; previousVersion?: string; newVersion?: string; }; type RelationshipChange = { serviceId: string; serviceVersion: string; resourceId: string; resourceVersion?: string; direction: 'sends' | 'receives'; changeType: 'added' | 'removed'; }; type EventCatalogSnapshotDiff = { snapshotA: { label: string; createdAt: string; }; snapshotB: { label: string; createdAt: string; }; summary: { totalChanges: number; resourcesAdded: number; resourcesRemoved: number; resourcesModified: number; resourcesVersioned: number; relationshipsAdded: number; relationshipsRemoved: number; }; resources: ResourceChange[]; relationships: RelationshipChange[]; }; export declare function toSnapshotDiffFromReport(report: DriftReport): EventCatalogSnapshotDiff; export declare function toSnapshotDiffFromDelta(delta: DriftDelta): EventCatalogSnapshotDiff; //#endregion //#region src/renderers/eventcatalog-snapshot-diff.d.ts export declare const EVENTCATALOG_SNAPSHOT_DIFF_SPEC: 'autotel-eventcatalog-snapshot-diff/v0.1.0'; type EventCatalogSnapshotDiffEnvelope = { spec: typeof EVENTCATALOG_SNAPSHOT_DIFF_SPEC; mode: 'all' | 'new-only'; diff: ReturnType; }; export declare function renderEventCatalogSnapshotDiffFromReport(report: DriftReport): string; export declare function renderEventCatalogSnapshotDiffFromDelta(delta: DriftDelta): string; //#endregion //#region src/renderers/index.d.ts /** * @deprecated Use `listRenderers()` for the full registry (built-ins plus * any registered at runtime). Kept for backwards compatibility. */ export declare const RENDERERS: readonly Renderer[]; /** * Names of the built-in renderers, narrowed to a string literal union via * `as const`. Custom renderers registered via `registerRenderer` widen the * runtime set but not this type; the CLI uses `listRendererNames()` for * runtime listings. */ export declare const RENDERER_NAMES: readonly ['markdown', 'terminal', 'json', 'eventcatalog-snapshot-diff']; type RendererName = (typeof RENDERER_NAMES)[number]; export declare function getRenderer(name: string): Renderer | undefined; //#endregion //#region src/policy.d.ts type DriftPolicyMode = 'all' | 'new-only'; type PolicyEvaluationInput = { mode: 'all'; report: DriftReport; } | { mode: 'new-only'; delta: DriftDelta; }; type PolicyEvaluationResult = { shouldFail: boolean; reason: string; }; export declare function evaluatePolicy(input: PolicyEvaluationInput): PolicyEvaluationResult; //#endregion //#region src/stamp.d.ts export declare const STAMP_START = ""; export declare const STAMP_END = ""; interface StampOptions { /** Loaded snapshot, OR pass `loadSnapshot(path)` from the caller. */ snapshot: ArchitectureSnapshot; /** Catalog root (the directory containing eventcatalog.config.*). */ catalogPath: string; /** If true, do not write files; just return the diff plan. */ dryRun?: boolean; /** Override "now" for deterministic tests. */ now?: () => Date; } type StampUpdate = { /** Catalog event id, e.g. `OrderPlaced`. */ catalogId: string; /** Snapshot event name, e.g. `order.placed`. */ snapshotName: string; /** Absolute path to the mdx file that was (or would be) updated. */ filePath: string; /** Was this an insert (no prior markers) or a replace? */ action: 'insert' | 'replace'; /** * True if the proposed content differs from what's on disk. False when a * replace would write byte-identical content; meaning no real change. * Used by `--summary-output` so CI can answer "did this PR need stamping?" * without diffing files. */ changed: boolean; }; type StampSkip = { snapshotName: string; reason: 'no-catalog-match'; }; type StampResult = { updates: StampUpdate[]; skips: StampSkip[]; }; export declare function stampCatalog(opts: StampOptions): Promise; /** * Render the evidence block. Designed to be readable in raw mdx AND visually * distinct when rendered by EventCatalog (uses the existing * `.evidence-callout` class, plus a small header label). */ export declare function buildStampBlock(obs: EventObservation): string; /** Versioned identifier for the stamp summary JSON file. */ export declare const STAMP_SUMMARY_SPEC: 'autotel-eventcatalog-stamp-summary/v0.1.0'; type StampSummary = { spec: typeof STAMP_SUMMARY_SPEC; dryRun: boolean; /** Total snapshot events the stamp run considered (matched + skipped). */ attempted: number; /** Skipped events (no catalog match). */ skipped: number; /** Matched events that resulted in an insert action. */ inserts: number; /** Matched events that resulted in a replace action. */ replaces: number; /** Number of files whose content actually changed (or would change in dry-run). */ changedFiles: number; /** * True when the run produced (or would produce) any real change. CI can * gate on this: "if the committed catalog is stamped, this should be * false after running stamp; if not, the PR forgot to re-stamp." */ hadChanges: boolean; }; export declare function buildStampSummary(result: StampResult, dryRun: boolean): StampSummary; //#endregion //#region src/suggest.d.ts type SuggestionConfidence = 'likely' | 'possible'; type RenameSuggestion = { /** Event name observed at runtime but absent from the catalog. */ observed: string; /** Catalog event id that is declared but was never seen. */ documented: string; /** 0..1, where 1 is an exact match of the normalised forms. */ similarity: number; confidence: SuggestionConfidence; }; /** * Pair each undocumented event with the closest documented-but-unseen one. * * Compared on the normalised form, so a pairing is never proposed for a * difference the matcher would already have absorbed — those events matched and * are not in either list to begin with. * * Each side is used at most once. Two undocumented events competing for the * same catalog entry cannot both be that rename, and offering both would send * someone to rename one thing twice. */ export declare function suggestRenames(report: DriftReport): RenameSuggestion[]; /** * The pairing itself, over two plain lists. * * Exported so the live map can reach the same answer from node liveness without * building a `DriftReport` — one rule, so the map and the report can never * disagree about whether something is a rename. */ export declare function suggestRenamesBetween(observed: string[], documented: string[]): RenameSuggestion[]; /** One line a human can act on, shared by every renderer. */ export declare function describeSuggestion(suggestion: RenameSuggestion): string; //#endregion //#region src/map.d.ts export declare const LIVE_MAP_SPEC = "autotel-eventcatalog-map/v0.1.0"; type MapLiveness = 'observed' | 'declared-only' | 'undocumented'; type MapEvidence = 'observed' | 'asserted'; type MapNodeKind = 'service' | 'event' | 'channel'; type MapEdgeKind = 'produces' | 'publishes-to' | 'consumed-by'; type MapNode = { id: string; kind: MapNodeKind; label: string; liveness: MapLiveness; /** Observations attributed to this node. 0 for anything never seen. */ count: number; lastSeen?: string; /** Snapshot event name, on event nodes that were observed. */ eventKey?: string; }; type MapEdge = { id: string; source: string; target: string; kind: MapEdgeKind; evidence: MapEvidence; liveness: MapLiveness; count: number; /** * False when the count came from an event-level total rather than a * per-relationship one — a snapshot written before `sources` existed cannot * tell two producers of the same event name apart. */ exactCount: boolean; lastSeen?: string; /** * The `track()` name that drives this edge. Live mode keys incoming events * by this, so an edge lights up only for the event that actually crossed it. */ eventKey?: string; }; type LiveMapSummary = { observedEdges: number; declaredOnlyEdges: number; undocumentedEdges: number; assertedEdges: number; observedNodes: number; declaredOnlyNodes: number; undocumentedNodes: number; totalObservations: number; }; type LiveMap = { spec: typeof LIVE_MAP_SPEC; generatedAt: string; service: string; nodes: MapNode[]; edges: MapEdge[]; summary: LiveMapSummary; /** * Pairings between an undocumented event and a declared-but-unseen one. * A rename shows up as two findings that are really one; saying so is the * difference between a tool people trust and one they stop opening. */ suggestions: RenameSuggestion[]; }; export declare function buildLiveMap(snapshot: ArchitectureSnapshot, catalog: CatalogState): LiveMap; //#endregion //#region src/renderers/map-html.d.ts type MapMode = 'static' | 'replay' | 'live'; type RenderMapOptions = { mode?: MapMode; /** SSE endpoint emitting `{ name, producer?, channel? }`. Live mode only. */ liveUrl?: string; /** * SSE event name to listen for. Defaults to `message`, which is what an * unnamed `data:` frame arrives as — a server that writes `event: track` * delivers nothing to a `message` listener, and the page would sit silently * claiming to be live. */ liveEventName?: string; /** * SSE event name carrying measured receipts, `{ event, consumer }`: a * consumer's own span linked to the message that carried the event. The only * frame that may promote, count or solidly mark a consumer edge. Unset means * consumer edges only ever move hollow, on producer frames. */ liveConsumeEventName?: string; title?: string; }; export declare function renderLiveMapHtml(map: LiveMap, options?: RenderMapOptions): string; //#endregion export type { ArchitectureSnapshot, CatalogChannel, CatalogEvent, CatalogService, CatalogState, ChannelDrift, DriftCounts, DriftDelta, DriftEntries, DriftPolicyMode, DriftReport, EventCatalogSnapshotDiff, EventCatalogSnapshotDiffEnvelope, EventDrift, EventObservation, FieldDrift, GenerateOptions, GenerateResult, GenerateSummary, GenerateSummaryItem, JsonReport, JsonReportEnvelope, LiveMap, LiveMapSummary, MapEdge, MapEdgeKind, MapEvidence, MapLiveness, MapMode, MapNode, MapNodeKind, PolicyEvaluationInput, PolicyEvaluationResult, RelationshipChange, RenameSuggestion, RenderMapOptions, Renderer, RendererName, ResourceChange, ServiceDrift, StampOptions, StampResult, StampSkip, StampSummary, StampUpdate, SuggestionConfidence };