TenantAtlas/apps/platform/.pnpm-store/v10/files/f6/593407c07db11367f6e51c3dba711bd60d9517697d19f7a6ba86679f7497b214c8c60b5e733764b6ca7adf9c1a70df2a187cb4379ad5d906400cb585edb0a4
ahmido 1fec9c6f9d
Some checks failed
Main Confidence / confidence (push) Failing after 45s
feat: compress governance operator outcomes (#253)
## Summary
- introduce surface-aware compressed governance outcomes and reuse the shared truth/explanation seams for operator-first summaries
- apply the compressed outcome hierarchy across baseline, evidence, review, review-pack, canonical review/evidence, and artifact-oriented operation-run surfaces
- expand spec 214 fixtures and Pest coverage, and fix tenant-panel route assertions by generating explicit tenant-panel URLs in the affected Filament tests

## Validation
- `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent`
- focused governance compression suite from `specs/214-governance-outcome-compression/quickstart.md` passed (`68` tests, `445` assertions)
- `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Filament/InventoryItemResourceTest.php tests/Feature/Filament/BackupSetUiEnforcementTest.php tests/Feature/Filament/RestoreRunUiEnforcementTest.php` passed (`18` tests, `81` assertions)

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #253
2026-04-19 12:30:36 +00:00

95 lines
3.6 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PrefixColorSelector = void 0;
function getConsoleColorsWithoutCustomColors(customColors) {
return PrefixColorSelector.ACCEPTABLE_CONSOLE_COLORS.filter(
// Consider the "Bright" variants of colors to be the same as the plain color to avoid similar colors
(color) => !customColors.includes(color.replace(/Bright$/, '')));
}
/**
* Creates a generator that yields an infinite stream of colors.
*/
function* createColorGenerator(customColors) {
// Custom colors should be used as is, except for "auto"
const nextAutoColors = getConsoleColorsWithoutCustomColors(customColors);
let lastColor;
for (const customColor of customColors) {
let currentColor = customColor;
if (currentColor !== 'auto') {
yield currentColor; // Manual color
}
else {
// Find the first auto color that is not the same as the last color
while (currentColor === 'auto' || lastColor === currentColor) {
if (!nextAutoColors.length) {
// There could be more "auto" values than auto colors so this needs to be able to refill
nextAutoColors.push(...PrefixColorSelector.ACCEPTABLE_CONSOLE_COLORS);
}
currentColor = String(nextAutoColors.shift());
}
yield currentColor; // Auto color
}
lastColor = currentColor;
}
const lastCustomColor = customColors[customColors.length - 1] || '';
if (lastCustomColor !== 'auto') {
while (true) {
yield lastCustomColor; // If last custom color was not "auto" then return same color forever, to maintain existing behavior
}
}
// Finish the initial set(s) of auto colors to avoid repetition
for (const color of nextAutoColors) {
yield color;
}
// Yield an infinite stream of acceptable console colors
//
// If the given custom colors use every ACCEPTABLE_CONSOLE_COLORS except one then there is a chance a color will be repeated,
// however its highly unlikely and low consequence so not worth the extra complexity to account for it
while (true) {
for (const color of PrefixColorSelector.ACCEPTABLE_CONSOLE_COLORS) {
yield color; // Repeat colors forever
}
}
}
class PrefixColorSelector {
colorGenerator;
constructor(customColors = []) {
const normalizedColors = typeof customColors === 'string' ? [customColors] : customColors;
this.colorGenerator = createColorGenerator(normalizedColors);
}
/** A list of colors that are readable in a terminal. */
static get ACCEPTABLE_CONSOLE_COLORS() {
// Colors picked randomly, can be amended if required
return [
// Prevent duplicates, in case the list becomes significantly large
...new Set([
// Text colors
'cyan',
'yellow',
'greenBright',
'blueBright',
'magentaBright',
'white',
'grey',
'red',
// Background colors
'bgCyan',
'bgYellow',
'bgGreenBright',
'bgBlueBright',
'bgMagenta',
'bgWhiteBright',
'bgGrey',
'bgRed',
]),
];
}
/**
* @returns The given custom colors then a set of acceptable console colors indefinitely.
*/
getNextColor() {
return this.colorGenerator.next().value;
}
}
exports.PrefixColorSelector = PrefixColorSelector;