feat(scan): enforce table scope at fetch boundary

This commit is contained in:
Andrey Avtomonov 2026-05-22 18:36:53 +02:00
parent a698389bc9
commit 5b8292cacd
19 changed files with 208 additions and 160 deletions

View file

@ -1,5 +1,5 @@
import { hasTableRef, tableRefSet, type KtxTableRefKey } from './table-ref.js';
import type { KtxSchemaSnapshot, KtxTableRef } from './types.js';
import { tableRefSet, type KtxTableRefKey } from './table-ref.js';
import type { KtxTableRef } from './types.js';
/**
* Parses the `enabled_tables` field on a connection into a scope of
@ -61,16 +61,3 @@ function parseDottedEntry(value: string): KtxTableRef | null {
}
return null;
}
/** @internal — kept as a defensive backstop for the live-database adapter and tests. */
export function filterSnapshotTables(
snapshot: KtxSchemaSnapshot,
enabledTables: ReadonlySet<KtxTableRefKey>,
): KtxSchemaSnapshot {
return {
...snapshot,
tables: snapshot.tables.filter((table) =>
hasTableRef(enabledTables, { catalog: table.catalog, db: table.db, name: table.name }),
),
};
}