TenantAtlas/apps/platform/.pnpm-store/v10/files/12/3a581612f24af064eba5334ea4bbdc2075c3845f4475a5123cb085ebfdde18cccdaf59282e2cf20012d602904c64f9be97d3e02511b08d9f71a0aa9901b1b1
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

76 lines
2.2 KiB
Plaintext

import { ColumnAliasProxyHandler, TableAliasProxyHandler } from "./alias.js";
import { Column } from "./column.js";
import { entityKind, is } from "./entity.js";
import { SQL, View } from "./sql/sql.js";
import { Subquery } from "./subquery.js";
import { ViewBaseConfig } from "./view-common.js";
class SelectionProxyHandler {
static [entityKind] = "SelectionProxyHandler";
config;
constructor(config) {
this.config = { ...config };
}
get(subquery, prop) {
if (prop === "_") {
return {
...subquery["_"],
selectedFields: new Proxy(
subquery._.selectedFields,
this
)
};
}
if (prop === ViewBaseConfig) {
return {
...subquery[ViewBaseConfig],
selectedFields: new Proxy(
subquery[ViewBaseConfig].selectedFields,
this
)
};
}
if (typeof prop === "symbol") {
return subquery[prop];
}
const columns = is(subquery, Subquery) ? subquery._.selectedFields : is(subquery, View) ? subquery[ViewBaseConfig].selectedFields : subquery;
const value = columns[prop];
if (is(value, SQL.Aliased)) {
if (this.config.sqlAliasedBehavior === "sql" && !value.isSelectionField) {
return value.sql;
}
const newValue = value.clone();
newValue.isSelectionField = true;
return newValue;
}
if (is(value, SQL)) {
if (this.config.sqlBehavior === "sql") {
return value;
}
throw new Error(
`You tried to reference "${prop}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`
);
}
if (is(value, Column)) {
if (this.config.alias) {
return new Proxy(
value,
new ColumnAliasProxyHandler(
new Proxy(
value.table,
new TableAliasProxyHandler(this.config.alias, this.config.replaceOriginalName ?? false)
)
)
);
}
return value;
}
if (typeof value !== "object" || value === null) {
return value;
}
return new Proxy(value, new SelectionProxyHandler(this.config));
}
}
export {
SelectionProxyHandler
};
//# sourceMappingURL=selection-proxy.js.map