Assembly comparison for jsii that detects breaking changes and compatibility violations between library versions
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Validation functions for API stability level transitions and consistency checks. This module ensures that stability annotations evolve according to allowed transition rules, preventing invalid stability changes that could confuse consumers.
Validates that API stability level changes follow allowed transition paths.
/**
* Validate that stability level changes between API versions follow allowed rules
* @param original - Original API element with stability annotation
* @param updated - Updated API element with (potentially different) stability
* @param mismatches - Reporter for recording any validation violations
*/
function validateStabilities(
original: reflect.Documentable & ApiElement,
updated: reflect.Documentable,
mismatches: IReport
): void;Usage Examples:
import { validateStabilities } from "jsii-diff/lib/stability";
import { Mismatches } from "jsii-diff/lib/types";
import { Stability } from "@jsii/spec";
// Create a mismatches reporter
const mismatches = new Mismatches({
defaultStability: Stability.Stable
});
// Validate stability transition for a method
validateStabilities(originalMethod, updatedMethod, mismatches);
// Check for any reported violations
if (mismatches.count > 0) {
for (const message of mismatches.messages()) {
console.log(`Stability violation: ${message}`);
}
}The validation enforces the following allowed transitions between stability levels:
The function reports two types of stability violations:
removed-stability)"stability was '{original}', has been removed"changed-stability)"stability not allowed to go from '{original}' to '{updated}'"Stability validation is automatically performed during assembly comparison and integrated with the diagnostic classification system:
import { compareAssemblies } from "jsii-diff";
import { classifyDiagnostics, treatAsError } from "jsii-diff/lib/diagnostics";
// Stability violations are included in compatibility analysis
const mismatches = compareAssemblies(original, updated);
// Stability violations can be classified as errors or warnings
const diagnostics = classifyDiagnostics(
mismatches,
treatAsError('prod') // stability violations on prod APIs cause errors
);// Good: Clear progression
@experimental → @stable → @deprecated
// Bad: Invalid transitions
@stable → @experimental // Not allowed
@deprecated → @experimental // Not allowedcompareAssemblies operation{rule}:{apiElementIdentifier}