TenantAtlas/apps/platform/.pnpm-store/v10/files/1a/64e39c190366867ab42e55b189ec93ab693235ef095101e141d6bd32def1e3e254a81bee945fe027bd3e0c9d8e0fb524b50e0ef7e733ed2666978ca25199b3
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

103 lines
3.9 KiB
Plaintext

import { entityKind } from "../entity.js";
import { NoopLogger } from "../logger.js";
import { fillPlaceholders } from "../sql/sql.js";
import { SQLiteTransaction } from "../sqlite-core/index.js";
import {
SQLiteSession
} from "../sqlite-core/session.js";
import { SQLitePreparedQuery as PreparedQueryBase } from "../sqlite-core/session.js";
import { mapResultRow } from "../utils.js";
class SQLiteDOSession extends SQLiteSession {
constructor(client, dialect, schema, options = {}) {
super(dialect);
this.client = client;
this.schema = schema;
this.logger = options.logger ?? new NoopLogger();
}
static [entityKind] = "SQLiteDOSession";
logger;
prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
return new SQLiteDOPreparedQuery(
this.client,
query,
this.logger,
fields,
executeMethod,
isResponseInArrayMode,
customResultMapper
);
}
transaction(transaction, _config) {
const tx = new SQLiteDOTransaction("sync", this.dialect, this, this.schema);
return this.client.transactionSync(() => transaction(tx));
}
}
class SQLiteDOTransaction extends SQLiteTransaction {
static [entityKind] = "SQLiteDOTransaction";
transaction(transaction) {
const tx = new SQLiteDOTransaction("sync", this.dialect, this.session, this.schema, this.nestedIndex + 1);
return this.session.transaction(() => transaction(tx));
}
}
class SQLiteDOPreparedQuery extends PreparedQueryBase {
constructor(client, query, logger, fields, executeMethod, _isResponseInArrayMode, customResultMapper) {
super("sync", executeMethod, query, void 0, void 0, void 0);
this.client = client;
this.logger = logger;
this.fields = fields;
this._isResponseInArrayMode = _isResponseInArrayMode;
this.customResultMapper = customResultMapper;
}
static [entityKind] = "SQLiteDOPreparedQuery";
run(placeholderValues) {
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
params.length > 0 ? this.client.sql.exec(this.query.sql, ...params) : this.client.sql.exec(this.query.sql);
}
all(placeholderValues) {
const { fields, joinsNotNullableMap, query, logger, client, customResultMapper } = this;
if (!fields && !customResultMapper) {
const params = fillPlaceholders(query.params, placeholderValues ?? {});
logger.logQuery(query.sql, params);
return params.length > 0 ? client.sql.exec(query.sql, ...params).toArray() : client.sql.exec(query.sql).toArray();
}
const rows = this.values(placeholderValues);
if (customResultMapper) {
return customResultMapper(rows);
}
return rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
}
get(placeholderValues) {
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
const { fields, client, joinsNotNullableMap, customResultMapper, query } = this;
if (!fields && !customResultMapper) {
return (params.length > 0 ? client.sql.exec(query.sql, ...params) : client.sql.exec(query.sql)).next().value;
}
const rows = this.values(placeholderValues);
const row = rows[0];
if (!row) {
return void 0;
}
if (customResultMapper) {
return customResultMapper(rows);
}
return mapResultRow(fields, row, joinsNotNullableMap);
}
values(placeholderValues) {
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
const res = params.length > 0 ? this.client.sql.exec(this.query.sql, ...params) : this.client.sql.exec(this.query.sql);
return res.raw().toArray();
}
/** @internal */
isResponseInArrayMode() {
return this._isResponseInArrayMode;
}
}
export {
SQLiteDOPreparedQuery,
SQLiteDOSession,
SQLiteDOTransaction
};
//# sourceMappingURL=session.js.map