/** * Rolling-spec drift detection for aws, azure, and github lexicons. * * These lexicons have no pinned version constant — "latest" is fetched on every * regen. An upgrade means regenerating from current-latest and diffing the * produced API surface against the committed baseline (surface.snapshot.json). * If the surface changed and validation passed, a PR can be opened with the * delta as the review payload. * * This module contains only pure business logic (detecting drift, classifying * it, formatting the report). It calls regenLexicon from #524 for the actual * regen/validate work, and never runs a live regen itself. * * azure extra delta: * The Azure regen depends on `latestVersionPerProvider`, which picks one API * version per ARM provider. When new providers appear or existing ones get a * newer GA/preview version, that shows up in the surface diff. In addition, * this module computes an `apiVersionDelta` to surface those version changes * separately, so reviewers can see "Microsoft.Compute moved 2022-03-01 → * 2023-07-01" without reading the raw surface diff. */ import { type SurfaceDelta, type ChangeSeverity, type SurfaceSnapshot } from "./surface-snapshot.js"; import { type RegenOptions, type RegenResult } from "./lexicon-regen.js"; export type RollingLexicon = "aws" | "azure" | "github" | "fly"; /** * An API-version change for one Azure ARM provider. * Only populated for the azure lexicon. */ export interface AzureApiVersionChange { provider: string; before: string | null; after: string | null; /** "added" when provider is new; "updated" when version bumped; "removed" when gone. */ kind: "added" | "updated" | "removed"; } /** * The result of a rolling-upgrade check for one lexicon. */ export interface RollingUpgradeResult { /** Lexicon identifier. */ lexicon: RollingLexicon; /** True when the surface changed versus the committed baseline. */ hasUpgrade: boolean; /** Severity of the surface delta. "none" when the surface is unchanged. */ severity: ChangeSeverity; /** Structured surface delta. */ delta: SurfaceDelta; /** Human-readable delta text. Empty when no changes. */ deltaText: string; /** Whether regen+validation passed. False means the delta is unreliable. */ validationOk: boolean; /** Failures captured during regen. */ failures: RegenResult["failures"]; /** azure-only: per-provider API version changes. Empty for aws/github. */ apiVersionDelta: AzureApiVersionChange[]; /** The fresh snapshot produced by the regen. Null when regen failed. */ freshSnapshot: SurfaceSnapshot | null; } /** * Options for checkRollingUpgrade. */ export interface CheckRollingUpgradeOptions { /** Root of the lexicon package (must contain package.json and surface.snapshot.json). */ lexiconDir: string; /** Force re-fetch of the upstream spec (bypass cache). Default: false. */ force?: boolean; /** Print subprocess output while running. Default: false. */ verbose?: boolean; /** * Override for the regen function — inject a mock in tests. * Defaults to the production regenLexicon. */ _regenFn?: (opts: RegenOptions) => Promise; } /** * Check whether the rolling spec has drifted since the committed baseline. * * Calls regenLexicon (from #524) to regenerate from current-latest, then diffs * the resulting surface against the committed surface.snapshot.json. Returns * hasUpgrade=true when the surface changed and validation passed. * * For azure, also computes an apiVersionDelta showing which ARM providers gained * a new latest API version since the baseline was snapshotted. * * Never throws — all failures are captured in the result. */ export declare function checkRollingUpgrade(opts: CheckRollingUpgradeOptions): Promise; /** * Compute provider-level additions and removals between two azure snapshots. * * The snapshot resourceType values for azure look like * "Microsoft.Storage/storageAccounts". This function extracts the provider * name (the part before the first "/") and reports which providers appeared, * disappeared, or (when version strings are supplied via diffAzureApiVersions) * bumped their API version. * * Use diffAzureApiVersions when you have access to actual API version strings * (e.g. from the lexicon's latestVersionPerProvider output in a CI run). */ export declare function computeAzureApiVersionDelta(baseline: SurfaceSnapshot, fresh: SurfaceSnapshot): AzureApiVersionChange[]; /** * Extract the Azure ARM provider name from a resourceType string. * * Input: "Microsoft.Storage/storageAccounts" * Output: "Microsoft.Storage" * * Returns null for non-ARM resource types (e.g. empty string or non-Microsoft prefix). */ export declare function extractAzureProvider(resourceType: string): string | null; /** * Diff actual API version strings per provider between two regen runs. * * Use this when the caller has access to the azure lexicon's * latestVersionPerProvider output. Produces a richer delta that includes * version bumps ("updated"), not just provider additions/removals. * * @param baseVersions Map from the previous regen. * @param freshVersions Map from the current regen. */ export declare function diffAzureApiVersions(baseVersions: Map, freshVersions: Map): AzureApiVersionChange[]; /** * Diff two surface snapshots. * * Pure function re-exported for callers that import rolling-upgrade and want to * compute the delta without importing surface-snapshot directly. */ export declare function diffRollingSurface(baseline: SurfaceSnapshot, fresh: SurfaceSnapshot): SurfaceDelta; /** * Classify a delta as an upgrade and determine its severity. * * Pure function — no I/O. Unit-testable with fixture snapshots. * Used by the CLI and the checkRollingUpgrade entry point. */ export declare function classifyDelta(delta: SurfaceDelta): { hasUpgrade: boolean; severity: ChangeSeverity; }; //# sourceMappingURL=rolling-upgrade.d.ts.map