Some checks failed
Main Confidence / confidence (push) Failing after 45s
## 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
47 lines
1.6 KiB
Plaintext
47 lines
1.6 KiB
Plaintext
import { addDatabaseChangeListener } from "expo-sqlite";
|
|
import { useEffect, useState } from "react";
|
|
import { is } from "../entity.js";
|
|
import { SQL } from "../sql/sql.js";
|
|
import { getTableConfig, getViewConfig, SQLiteTable, SQLiteView } from "../sqlite-core/index.js";
|
|
import { SQLiteRelationalQuery } from "../sqlite-core/query-builders/query.js";
|
|
import { Subquery } from "../subquery.js";
|
|
const useLiveQuery = (query, deps = []) => {
|
|
const [data, setData] = useState(
|
|
is(query, SQLiteRelationalQuery) && query.mode === "first" ? void 0 : []
|
|
);
|
|
const [error, setError] = useState();
|
|
const [updatedAt, setUpdatedAt] = useState();
|
|
useEffect(() => {
|
|
const entity = is(query, SQLiteRelationalQuery) ? query.table : query.config.table;
|
|
if (is(entity, Subquery) || is(entity, SQL)) {
|
|
setError(new Error("Selecting from subqueries and SQL are not supported in useLiveQuery"));
|
|
return;
|
|
}
|
|
let listener;
|
|
const handleData = (data2) => {
|
|
setData(data2);
|
|
setUpdatedAt(/* @__PURE__ */ new Date());
|
|
};
|
|
query.then(handleData).catch(setError);
|
|
if (is(entity, SQLiteTable) || is(entity, SQLiteView)) {
|
|
const config = is(entity, SQLiteTable) ? getTableConfig(entity) : getViewConfig(entity);
|
|
listener = addDatabaseChangeListener(({ tableName }) => {
|
|
if (config.name === tableName) {
|
|
query.then(handleData).catch(setError);
|
|
}
|
|
});
|
|
}
|
|
return () => {
|
|
listener?.remove();
|
|
};
|
|
}, deps);
|
|
return {
|
|
data,
|
|
error,
|
|
updatedAt
|
|
};
|
|
};
|
|
export {
|
|
useLiveQuery
|
|
};
|
|
//# sourceMappingURL=query.js.map |